From patchwork Fri Feb 24 10:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vlastimil Babka X-Patchwork-Id: 13151080 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B641C6FA99 for ; Fri, 24 Feb 2023 10:01:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DC2C6B0080; Fri, 24 Feb 2023 05:00:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2647D6B0083; Fri, 24 Feb 2023 05:00:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 090276B0085; Fri, 24 Feb 2023 05:00:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id E9DAD6B0080 for ; Fri, 24 Feb 2023 05:00:47 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BC66114180D for ; Fri, 24 Feb 2023 10:00:47 +0000 (UTC) X-FDA: 80501741334.06.A139379 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf24.hostedemail.com (Postfix) with ESMTP id A3BE618000C for ; Fri, 24 Feb 2023 10:00:45 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=KWXyMuNX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=f0IpufU3; spf=pass (imf24.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677232846; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=U0wR3jwDHdRrK2cxRZw/xy12wIZu3wsnwhuoBXj0MMQ=; b=7fQOpVsCwVBGVVAVvwCEmSHxPgiuUGz9r8OqD+k0U6Nb+Pl94THUTRSDKbN2rw/yxtYL6F uQpGMNshQ1OJpeNvrR52pymhTKXM6ADl74ODyOR7nFl7I3X4EBSNdVaa6DooGMvosb03oD uhSeS4KrZBX/6i65ze44E5Lhpr9WV/A= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=KWXyMuNX; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=f0IpufU3; spf=pass (imf24.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677232846; a=rsa-sha256; cv=none; b=KPEPDWQapQDZnTvHBvePxEzf9V3/zL8/5HhZsykBcKGvtQwUTDDMSSdr9IsvksY+mi1NNZ 3lk+eJD4p0ggzSaVuGt2U/QSoT1Nau4ia3mzhcaXGLGByUpVZlLiYIsvH1EPKwECNa4L6C +pAoGy7HQmUhM+cjNbsabOM4OZYUEqo= 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 531353438B; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1677232842; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U0wR3jwDHdRrK2cxRZw/xy12wIZu3wsnwhuoBXj0MMQ=; b=KWXyMuNXAW1CBLQTUubfz3ZaB4JYVNhcclgO1jGZo5VjK6IDmNbuyTJUDOInBfy+/ZGReA Y+HFC5k0Wq59VWumMLMp6pHq3RbsWuvQGG0vn2V82+czWBpqRgGUMY2x503sc+riFul2hW 56TNM/afvXjy39C5sTvBMDTsk9V5GCo= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1677232842; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=U0wR3jwDHdRrK2cxRZw/xy12wIZu3wsnwhuoBXj0MMQ=; b=f0IpufU3BmvceE+pCst74byvq0uqDgv/mlVa6jatNSqcFHEa2tIXy68JhhykiA7j/U+YuX DMu+EH3Z7aJfuQDQ== 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 3820713A3C; Fri, 24 Feb 2023 10:00:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id eN3yDMqK+GPeTgAAMHmgww (envelope-from ); Fri, 24 Feb 2023 10:00:42 +0000 From: Vlastimil Babka To: linux-mm@kvack.org, "Liam R. Howlett" Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, maple-tree@lists.infradead.org, Vlastimil Babka Subject: [RFC 09/11] mm/mmap/vma_merge: convert mergeability checks to return bool Date: Fri, 24 Feb 2023 11:00:20 +0100 Message-Id: <20230224100022.11268-10-vbabka@suse.cz> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230224100022.11268-1-vbabka@suse.cz> References: <20230224100022.11268-1-vbabka@suse.cz> MIME-Version: 1.0 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: A3BE618000C X-Stat-Signature: xzgqxjjdurex1qb5o4m19yr7r4quc66z X-Rspam-User: X-HE-Tag: 1677232845-936062 X-HE-Meta: U2FsdGVkX1/E1P5CvWN7/IT+sRxvlXrb4OHjSYnDSIc+HQsoLMO6caAhzkLxrKtIjqHO1xkb5jLNao4Kb6Te2ebC5YS4SjbVyr6KbWs4qj+cmeOE7GWCSQMfbmhBwiVPqQqR6EHE8Sz1rvGTGurohsI4/RMbtsvGjtoqUhbuo16l/3Xwsgs7choOlMEa8h29uLNOgTcYCzfvrmYfffB0LTtlyLWhe4Ed48vfa+MxhHGZiaB+vNBuXbiZzuIf1uT/EpE34kRBq4J5HDzWuuvdR1yS1DY1glQ0ij8pnXH7Dan0ne7g0GAvFIsg7jK3oujfc9hoAf2fl+ch3NQoE2PjedMSKon4i06xjUEOvvoxwydJ5lTf2fIUG3Avnupf4kpobOrVvgxKo3kcILwJYVgF+rwcQmBglNGRpxSQVCxk4IgdMeN06lb7x1SOArH/DEYZr1nYWnnb0HyOUx3qOyM5CmsHTsjUZszzrNTrnPvB9SFvFtif0lRIIBErCnJJF/EkhQJpWM6d5VcxCcQJjh8XTIMtgwsjl7OSvR9lEmGUVc7n6JTV1PBZ/3DtDJtkdb1ecVBdXSfBT425H4gy9tgAE3bpbp3msg5ZT8l52+6VhXjQEBx0EKgGuVwdcBDrQ+7RvBtnawAhaN2JbnuugtPnt+Qe427BsomO9N+KDV81Lwd8hY0+VJML0ATUyoM8XHn/VSPoUFdghe9r6JOjax0xxbwh89q2hiUINmYKr2qgHGyeDspp4EA7FOYXxy8YjvpuVzWArqE6sQHn/4SXEjH3YsD3N0beBz8zyAPVYZurf8bijzsZRJ5ElfQBskESRD2Pr+NW7LCEGjL+20m+5ca3Eh2Ekj1CWYBlxXlawRxFTiY7+kAuIIB6sa81Yn157WAdf2EMRinWmUVh7stX33STaTupk7I1ZlugZPwOCpwEa9kw9MJL7kxjLv9QyIvtw4yOD5p/m4oZzMN+fi+Xjdf aX4qCYOH /zWRMKzcxbaryc1PSbIjvhTHxBhO92GflYINGO+QmT7SHIpTvsKxiDzUdCKmEPUKoSLblT4JrbwHK5Sn8G5gPdMiI1/G7clbSDK2j1Ny436lokgJp2EQV1vfTNFoQjgKPLTnTQ0YzWUYQcKtkZNEOfsmlcyKeJj61CxulvCcwPenCEbBkBBfGUMp7G8LlG7kGrf7DO8YCHrTem0R3HnpsQaNMXNxIGP1fXP+Ln3M0mdJJCDRJUXE3LpixqQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The comments already mention returning 'true' so make the code match them. Signed-off-by: Vlastimil Babka --- mm/mmap.c | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 8c2bdf9e3f94..6e439806d4ac 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -744,10 +744,10 @@ int vma_shrink(struct vma_iterator *vmi, struct vm_area_struct *vma, * If the vma has a ->close operation then the driver probably needs to release * per-vma resources, so we don't attempt to merge those. */ -static inline int is_mergeable_vma(struct vm_area_struct *vma, - struct file *file, unsigned long vm_flags, - struct vm_userfaultfd_ctx vm_userfaultfd_ctx, - struct anon_vma_name *anon_name) +static inline bool is_mergeable_vma(struct vm_area_struct *vma, + struct file *file, unsigned long vm_flags, + struct vm_userfaultfd_ctx vm_userfaultfd_ctx, + struct anon_vma_name *anon_name) { /* * VM_SOFTDIRTY should not prevent from VMA merging, if we @@ -758,21 +758,21 @@ static inline int is_mergeable_vma(struct vm_area_struct *vma, * extended instead. */ if ((vma->vm_flags ^ vm_flags) & ~VM_SOFTDIRTY) - return 0; + return false; if (vma->vm_file != file) - return 0; + return false; if (vma->vm_ops && vma->vm_ops->close) - return 0; + return false; if (!is_mergeable_vm_userfaultfd_ctx(vma, vm_userfaultfd_ctx)) - return 0; + return false; if (!anon_vma_name_eq(anon_vma_name(vma), anon_name)) - return 0; - return 1; + return false; + return true; } -static inline int is_mergeable_anon_vma(struct anon_vma *anon_vma1, - struct anon_vma *anon_vma2, - struct vm_area_struct *vma) +static inline bool is_mergeable_anon_vma(struct anon_vma *anon_vma1, + struct anon_vma *anon_vma2, + struct vm_area_struct *vma) { /* * The list_is_singular() test is to avoid merging VMA cloned from @@ -780,7 +780,7 @@ static inline int is_mergeable_anon_vma(struct anon_vma *anon_vma1, */ if ((!anon_vma1 || !anon_vma2) && (!vma || list_is_singular(&vma->anon_vma_chain))) - return 1; + return true; return anon_vma1 == anon_vma2; } @@ -795,7 +795,7 @@ static inline int is_mergeable_anon_vma(struct anon_vma *anon_vma1, * indices (16TB on ia32) because do_mmap() does not permit mmap's which * wrap, nor mmaps which cover the final page at index -1UL. */ -static int +static bool can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags, struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff, @@ -805,9 +805,9 @@ can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags, if (is_mergeable_vma(vma, file, vm_flags, vm_userfaultfd_ctx, anon_name) && is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) { if (vma->vm_pgoff == vm_pgoff) - return 1; + return true; } - return 0; + return false; } /* @@ -817,7 +817,7 @@ can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags, * We cannot merge two vmas if they have differently assigned (non-NULL) * anon_vmas, nor if same anon_vma is assigned but offsets incompatible. */ -static int +static bool can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff, @@ -829,9 +829,9 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags, pgoff_t vm_pglen; vm_pglen = vma_pages(vma); if (vma->vm_pgoff + vm_pglen == vm_pgoff) - return 1; + return true; } - return 0; + return false; } /*