From patchwork Mon Nov 18 06:39:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 11248967 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD77314DB for ; Mon, 18 Nov 2019 06:39:23 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B3DA220726 for ; Mon, 18 Nov 2019 06:39:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B3DA220726 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DBE786B0007; Mon, 18 Nov 2019 01:39:22 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D6ECE6B0008; Mon, 18 Nov 2019 01:39:22 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C83E96B000A; Mon, 18 Nov 2019 01:39:22 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0038.hostedemail.com [216.40.44.38]) by kanga.kvack.org (Postfix) with ESMTP id B0C096B0007 for ; Mon, 18 Nov 2019 01:39:22 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with SMTP id 3F4BE180AD806 for ; Mon, 18 Nov 2019 06:39:22 +0000 (UTC) X-FDA: 76168446564.20.fire65_17896819de947 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,linmiaohe@huawei.com,:akpm@linux-foundation.org:richardw.yang@linux.intel.com:sfr@canb.auug.org.au:rppt@linux.ibm.com:jannh@google.com:steve.capper@arm.com:catalin.marinas@arm.com:aarcange@redhat.com:chenjianhong2@huawei.com:walken@google.com:dave.hansen@linux.intel.com:tiny.windzz@gmail.com:jhubbard@nvidia.com:david@redhat.com:linmiaohe@huawei.com::linux-kernel@vger.kernel.org,RULES_HIT:30012:30054:30064:30075,0,RBL:45.249.212.32:@huawei.com:.lbl8.mailshell.net-62.18.2.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: fire65_17896819de947 X-Filterd-Recvd-Size: 3463 Received: from huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 Nov 2019 06:39:21 +0000 (UTC) Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 61B1DEE64FB8E6ED1E0D; Mon, 18 Nov 2019 14:39:12 +0800 (CST) Received: from huawei.com (10.175.105.18) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.439.0; Mon, 18 Nov 2019 14:38:56 +0800 From: linmiaohe To: , , , , , , , , , , , , , CC: , , Subject: [PATCH v3] mm: get rid of odd jump labels in find_mergeable_anon_vma() Date: Mon, 18 Nov 2019 14:39:07 +0800 Message-ID: <1574059147-13678-1-git-send-email-linmiaohe@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.175.105.18] X-CFilter-Loop: Reflected 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: From: Miaohe Lin The jump labels try_prev and none are not really needed in find_mergeable_anon_vma(), eliminate them to improve readability. Reviewed-by: David Hildenbrand Reviewed-by: John Hubbard Signed-off-by: Miaohe Lin --- -v2: Fix commit descriptions and further simplify the code as suggested by David Hildenbrand and John Hubbard. -v3: Rewrite patch version info. Don't show this in commit log. --- mm/mmap.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/mm/mmap.c b/mm/mmap.c index 4d4db76a07da..ff02c23fd375 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1276,26 +1276,25 @@ static struct anon_vma *reusable_anon_vma(struct vm_area_struct *old, struct vm_ */ struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *vma) { - struct anon_vma *anon_vma; + struct anon_vma *anon_vma = NULL; struct vm_area_struct *near; + /* Try next first. */ near = vma->vm_next; - if (!near) - goto try_prev; + if (near) { + anon_vma = reusable_anon_vma(near, vma, near); + if (anon_vma) + return anon_vma; + } - anon_vma = reusable_anon_vma(near, vma, near); - if (anon_vma) - return anon_vma; -try_prev: + /* Try prev next. */ near = vma->vm_prev; - if (!near) - goto none; + if (near) + anon_vma = reusable_anon_vma(near, near, vma); - anon_vma = reusable_anon_vma(near, near, vma); - if (anon_vma) - return anon_vma; -none: /* + * We might reach here with anon_vma == NULL if we can't find + * any reusable anon_vma. * There's no absolute need to look only at touching neighbours: * we could search further afield for "compatible" anon_vmas. * But it would probably just be a waste of time searching, @@ -1303,7 +1302,7 @@ struct anon_vma *find_mergeable_anon_vma(struct vm_area_struct *vma) * We're trying to allow mprotect remerging later on, * not trying to minimize memory used for anon_vmas. */ - return NULL; + return anon_vma; } /*