From nobody Tue Feb 10 23:52:51 2026 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 82DB6C761A6 for ; Tue, 4 Apr 2023 09:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234226AbjDDJqQ (ORCPT ); Tue, 4 Apr 2023 05:46:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234009AbjDDJqM (ORCPT ); Tue, 4 Apr 2023 05:46:12 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC83E30DC for ; Tue, 4 Apr 2023 02:45:50 -0700 (PDT) Received: from kwepemm600020.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PrNCk3pgCzKntV; Tue, 4 Apr 2023 17:45:06 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Tue, 4 Apr 2023 17:45:41 +0800 From: Peng Zhang To: , , CC: , , ZhangPeng Subject: [PATCH] mm/madvise: Use vma_lookup() instead of find_vma() Date: Tue, 4 Apr 2023 17:45:15 +0800 Message-ID: <20230404094515.1883552-1-zhangpeng362@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: ZhangPeng Using vma_lookup() verifies the address is contained in the found vma. This results in easier to read the code. Signed-off-by: ZhangPeng Reviewed-by: Liam R. Howlett --- mm/madvise.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/mm/madvise.c b/mm/madvise.c index 340125d08c03..405a2c4a0a18 100644 --- a/mm/madvise.c +++ b/mm/madvise.c @@ -852,21 +852,9 @@ static long madvise_dontneed_free(struct vm_area_struc= t *vma, *prev =3D NULL; /* mmap_lock has been dropped, prev is stale */ =20 mmap_read_lock(mm); - vma =3D find_vma(mm, start); + vma =3D vma_lookup(mm, start); if (!vma) return -ENOMEM; - if (start < vma->vm_start) { - /* - * This "vma" under revalidation is the one - * with the lowest vma->vm_start where start - * is also < vma->vm_end. If start < - * vma->vm_start it means an hole materialized - * in the user address space within the - * virtual range passed to MADV_DONTNEED - * or MADV_FREE. - */ - return -ENOMEM; - } /* * Potential end adjustment for hugetlb vma is OK as * the check below keeps end within vma. --=20 2.25.1