From patchwork Mon Mar 14 15:17:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miaohe Lin X-Patchwork-Id: 12780325 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 23A34C433EF for ; Mon, 14 Mar 2022 15:18:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 97B788D0001; Mon, 14 Mar 2022 11:18:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 92B646B0073; Mon, 14 Mar 2022 11:18:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F2E68D0001; Mon, 14 Mar 2022 11:18:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 6E7DD6B0072 for ; Mon, 14 Mar 2022 11:18:24 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2182A8249980 for ; Mon, 14 Mar 2022 15:18:24 +0000 (UTC) X-FDA: 79243348128.19.00F2CD6 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf01.hostedemail.com (Postfix) with ESMTP id 64FC340032 for ; Mon, 14 Mar 2022 15:18:23 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4KHKrh5kNkzfZ2q; Mon, 14 Mar 2022 23:16:52 +0800 (CST) Received: from huawei.com (10.175.124.27) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Mon, 14 Mar 2022 23:18:19 +0800 From: Miaohe Lin To: , CC: , , Subject: [PATCH] mm/mlock: Use vma_lookup() instead of find_vma() Date: Mon, 14 Mar 2022 23:17:28 +0800 Message-ID: <20220314151728.20800-1-linmiaohe@huawei.com> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 X-Originating-IP: [10.175.124.27] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 64FC340032 X-Stat-Signature: 1fgwirtuf7i68j5tmgkx49h3d443kkg3 Authentication-Results: imf01.hostedemail.com; dkim=none; spf=pass (imf01.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: X-HE-Tag: 1647271103-727552 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: Using vma_lookup() verifies the start is contained in the found vma. This results in easier to read the code. Signed-off-by: Miaohe Lin --- mm/mlock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/mlock.c b/mm/mlock.c index efd2dd2943de..fefa9644d0f9 100644 --- a/mm/mlock.c +++ b/mm/mlock.c @@ -453,8 +453,8 @@ static int apply_vma_lock_flags(unsigned long start, size_t len, return -EINVAL; if (end == start) return 0; - vma = find_vma(current->mm, start); - if (!vma || vma->vm_start > start) + vma = vma_lookup(current->mm, start); + if (!vma) return -ENOMEM; prev = vma->vm_prev;