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 X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CAB6C433DB for ; Thu, 4 Feb 2021 11:07:32 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E7A5E64DBA for ; Thu, 4 Feb 2021 11:07:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7A5E64DBA 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 4F6AD6B0005; Thu, 4 Feb 2021 06:07:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A6476B006C; Thu, 4 Feb 2021 06:07:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39E386B006E; Thu, 4 Feb 2021 06:07:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0176.hostedemail.com [216.40.44.176]) by kanga.kvack.org (Postfix) with ESMTP id 1B86C6B0005 for ; Thu, 4 Feb 2021 06:07:31 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id C40F83632 for ; Thu, 4 Feb 2021 11:07:30 +0000 (UTC) X-FDA: 77780309460.05.rod30_291473f275db Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id A825918030C89 for ; Thu, 4 Feb 2021 11:07:30 +0000 (UTC) X-HE-Tag: rod30_291473f275db X-Filterd-Recvd-Size: 1823 Received: from szxga06-in.huawei.com (szxga06-in.huawei.com [45.249.212.32]) by imf15.hostedemail.com (Postfix) with ESMTP for ; Thu, 4 Feb 2021 11:07:29 +0000 (UTC) Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4DWbMf10cXzjHTb; Thu, 4 Feb 2021 19:06:22 +0800 (CST) Received: from huawei.com (10.175.104.175) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.498.0; Thu, 4 Feb 2021 19:07:16 +0800 From: Miaohe Lin To: CC: , , Subject: [PATCH] mm/mlock: stop counting mlocked pages when none vma is found Date: Thu, 4 Feb 2021 06:07:05 -0500 Message-ID: <20210204110705.17586-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.104.175] X-CFilter-Loop: Reflected Content-Transfer-Encoding: quoted-printable 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: There will be no vma satisfies addr < vm_end when find_vma() returns NULL= . Thus it's meaningless to traverse the vma list below because we can't fin= d any vma to count mlocked pages. Stop counting mlocked pages in this case = to save some vma list traversal cycles. Signed-off-by: Miaohe Lin --- mm/mlock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/mlock.c b/mm/mlock.c index 73960bb3464d..f8f8cc32d03d 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -622,7 +622,7 @@ static unsigned long count_mm_mlocked_page_nr(struct = mm_struct *mm, =20 vma =3D find_vma(mm, start); if (vma =3D=3D NULL) - vma =3D mm->mmap; + return 0; =20 for (; vma ; vma =3D vma->vm_next) { if (start >=3D vma->vm_end) --=20 2.19.1