From patchwork Tue Apr 4 09:45:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Zhang X-Patchwork-Id: 13199408 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 865C3C6FD1D for ; Tue, 4 Apr 2023 09:45:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA33A6B0075; Tue, 4 Apr 2023 05:45:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A538D6B0078; Tue, 4 Apr 2023 05:45:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 941BB6B007B; Tue, 4 Apr 2023 05:45:49 -0400 (EDT) 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 8548B6B0075 for ; Tue, 4 Apr 2023 05:45:49 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 54D0B1C67FF for ; Tue, 4 Apr 2023 09:45:49 +0000 (UTC) X-FDA: 80643226818.23.AA7E818 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf27.hostedemail.com (Postfix) with ESMTP id 0571C4000C for ; Tue, 4 Apr 2023 09:45:46 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680601547; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references; bh=21r9BUiD6bnTfWKdCcjkNvI5dZCiJhV9YiPQO/nQrwk=; b=ptrFFpsrBvw6/RMYfwOr/i5RPPk0C/8Z+GZeHWZm3vAcUAZb9vHB5ZTrUP0x2UHuPGUn9A SBwMjKN1oVmlSL/bdkItP5sdLZ2iqDb+K1n95EaDKFTWSpffPOk1pasOgUD6ihBdL8AdGX pmeh4z73xPGnp0iEZP6Hz1sGKFmovgA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf27.hostedemail.com: domain of zhangpeng362@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=zhangpeng362@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680601547; a=rsa-sha256; cv=none; b=Q/jbiBx7cJ0LL9My4NO57Zmfk0AowB2QaxGzECygdQmgROAv6EHG5wCcSCs6L21THP4C72 T0yhI0q2cA3UaTwf6jvCCNekPTU2wDl5viseeZYI12Et/lQ+tUmIGxUNXzOeXRvlarJDsw xvsjf3NCVTLbczrM5iIUcToPu/bouW0= 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 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 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0571C4000C X-Stat-Signature: 3xfatod7ir958dxtueptmd6ch9cxfj6e X-HE-Tag: 1680601546-201209 X-HE-Meta: U2FsdGVkX1/kKKqSArhFAl1vQDsdcA+mL9SlBAqctYcI8tqatX5CRbz/cTpDXHgPzhgBzRrbjGgbsZl8uVGwCE7PczbMWR5IWXFJenRry2+1XRlSbFVB64l/V0j07GpKcw/juEkA8fM9SmdP3eFtpDPNOkjJXFj9UYAeKLWTcp9TTIo7bTkPAkQ6Cp1BTjLOMJbSzewQAflKKid4LCaxQsxC9k/xaPDNMduJXhe3iesd/tVkgorzb++ExuaPZDzBRRwjZZt8U9lhAIEcKmJLgo1JY+JkbTawwex3hTKxnr2pBD55e6N/QPYzbTvrDhNNaN/4PA0O5PBn64JHc+zQP0cnDsWmz5oadFH0rrlI+8K5cErgurMjvt0GXo4XzD2l4SMVWqnpRKZ0htzpQN4HOvPIURH2evWWfriyMGSjWrvViPgKabV5xle5kXmcXWN31WBP6igc8Z4LK2dUPaMPq6Y3u+6p/SZaivMp4c0VDoikL0OIV5X2GYJ16gTYtc51kflw7d18+K8UHwjWrtX5jWvXtE9lrnLopEai/7pBTp4hLNoF26Qt7rkVr3roKaSZ/gVSW1ismHhOkzG6G/+JBY6MFKoYnQDzkNIp4DAUP5ynv18kgh8wzPnZgBc2VZuZOyejHxkCqD9q8T8+sDWnCDJwcdVFMNle6Q5+/R7Xj1q5iTov5dZy21A6Nzs8fKIhN6cbB1fQ1Nr8bwveUzhQx9feSIP5kF3AqfDxjyz88STO6jD2GFN3xP7naNf+n9t9IfQcBZQUgf/IksZA5v6u4EZ+Bkt+XgXsKxeH7xWiabo2WkJRsJyVwjtS2IaSZN77Gh5A3VOA2AZ+lktKfMe4YFoWL99VB3Hic1Gc4XO59Z+zMYxVwjNmCTlVSXIjFVfjST4JJl9jX45/8fSEjxrSVuk3/wzVivXqBZxk9uyjVLDFrW5hiYa793hCO+didAgXZWEQRWgCiy+atx9Vm+4 KsPu5OYV xtMRCLISRwTWEMq2oj60vHhPzoQHR3hg2S9axG2IhKbBiDOfNvK/5vAQz4TdCR2Pb/D/+R1u8JJh8D+SgkRQ4gEa52NC3wyu93xibL/pcZ9C2Zaf9yd93jOUpOcPLS7HdMV3cIVh1E+F7TdEipZRHA36+Sba5oMGHuS45GpPk/lJySuF6JZK1HI+NbKzYvlHHmO7/FP/hsuXavv0= 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: 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_struct *vma, *prev = NULL; /* mmap_lock has been dropped, prev is stale */ mmap_read_lock(mm); - vma = find_vma(mm, start); + vma = 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.