From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A94DBC7EE23 for ; Tue, 23 May 2023 13:13:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236762AbjEWNNz (ORCPT ); Tue, 23 May 2023 09:13:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236720AbjEWNNx (ORCPT ); Tue, 23 May 2023 09:13:53 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39996184 for ; Tue, 23 May 2023 06:13:45 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id E931E22AB7; Tue, 23 May 2023 13:13:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1684847623; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bgL1MIRZX3Y+FVWSNOkU++9NMPuYvd0QkuZ4FyLBVfU=; b=EEwAnJIezFPmi/jB0fiajqlAZJHIaxDV0zOANdyOK0hO689bBOzb/mtstSMAicqCiLWpgi VWoRDfh9JktX8kDoVzhMX+5Z7Yhu0Y3fuI6S5Upzq2H1mcROy/h9kdyzxNLHX6CGYpdroW q+ItsLN02lg13wI4KBgfd1VsfG5wYK8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1684847623; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bgL1MIRZX3Y+FVWSNOkU++9NMPuYvd0QkuZ4FyLBVfU=; b=Xv3rH11f9CNEqWknjeqH8ehvmD/QHsE90UXWMIa04KXsgEt4haFtk2+5bTJJ9k28zp5kuR GK2i3+MUcqaFjODQ== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CF16713A10; Tue, 23 May 2023 13:13:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id 6ojXMQe8bGTUPwAAMHmgww (envelope-from ); Tue, 23 May 2023 13:13:43 +0000 Message-ID: <856dbc05-5046-04c8-cf6f-9d0b13e9d229@suse.cz> Date: Tue, 23 May 2023 15:13:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] mm/mmap: refactor mlock_future_check() Content-Language: en-US To: Lorenzo Stoakes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton Cc: Mike Rapoport , "Liam R . Howlett" References: <20230522082412.56685-1-lstoakes@gmail.com> From: Vlastimil Babka In-Reply-To: <20230522082412.56685-1-lstoakes@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/22/23 10:24, Lorenzo Stoakes wrote: > In all but one instance, mlock_future_check() is treated as a boolean > function despite returning an error code. In one instance, this error code > is ignored and replaced with -ENOMEM. > > This is confusing, and the inversion of true -> failure, false -> success > is not warranted. Convert the function to a bool, lightly refactor and > return true if the check passes, false if not. > > Signed-off-by: Lorenzo Stoakes Acked-by: Vlastimil Babka > --- > mm/internal.h | 4 ++-- > mm/mmap.c | 33 +++++++++++++++++---------------- > mm/mremap.c | 2 +- > mm/secretmem.c | 2 +- > 4 files changed, 21 insertions(+), 20 deletions(-) > > diff --git a/mm/internal.h b/mm/internal.h > index bb6542279599..66dd214b302a 100644 > --- a/mm/internal.h > +++ b/mm/internal.h > @@ -576,8 +576,8 @@ extern long populate_vma_page_range(struct vm_area_struct *vma, > extern long faultin_vma_page_range(struct vm_area_struct *vma, > unsigned long start, unsigned long end, > bool write, int *locked); > -extern int mlock_future_check(struct mm_struct *mm, unsigned long flags, > - unsigned long len); > +extern bool mlock_future_check(struct mm_struct *mm, unsigned long flags, > + unsigned long bytes); This would have been good opportunity to drop the extern.