From patchwork Mon Apr 8 19:42:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13621552 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 D75CCC67861 for ; Mon, 8 Apr 2024 19:43:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2259B6B0096; Mon, 8 Apr 2024 15:43:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1D5FE6B0098; Mon, 8 Apr 2024 15:43:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF6046B0099; Mon, 8 Apr 2024 15:42:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id D17006B0096 for ; Mon, 8 Apr 2024 15:42:59 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 9E861120166 for ; Mon, 8 Apr 2024 19:42:59 +0000 (UTC) X-FDA: 81987387678.10.BD6D0DB Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP id F3B7140003 for ; Mon, 8 Apr 2024 19:42:57 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EnWMwjrx; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712605378; a=rsa-sha256; cv=none; b=C276D7HjTNnHOboR12iz3cp9RxymGgpLtXLb8c0DOCIw3BA/GA/vXmxUZj+MFM7ZWgTnoL seEUIXzbALFDfG+oT9NJH2pR/REA5AbdJnGvSBWc3IWIQadAVyvfgwvOYAJKSVziqOANnM QRO4OVGkGTotwPUdd9H2x2gtMBJHirM= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=EnWMwjrx; dmarc=none; spf=none (imf07.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712605378; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=9xwOmtj5mTjwvmp+KNCpctqJtEXESdvMm2FbLUwq0nA=; b=JGA/Nr9brCe/HlP0Q7+dShrKSZGXRuylkO2IctDJFQbOIRe75Amp9qKFksm3iCcE/kBPAl DQn2hHvjOwmK7rwxBP0nzAkRCVmXK7ZzFENyNc3HF1HFeVHwSRw585vkTixaOEgwm9dr1p rHhhj071RgUsDR02vgS8JzcygqDjk7c= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=9xwOmtj5mTjwvmp+KNCpctqJtEXESdvMm2FbLUwq0nA=; b=EnWMwjrxPTWEUO9T0K1wzTGkt4 3n+rAKuhsn4l5yMXJYS1rGSahA7rmcBAdnVYZKrdZHcA1tDKnPOvZ/s6LNScQe1wK9f5lv8XwdZye moP/T7e0PdPzyzKPbbSB/8RwOKNnQy54w0OpW1m4nph9wnGh83f2ItQc7ZQZArE7e+JgrJnVIWZRd IoBzDXV0MW2Wu6IVVuQ60yGjuNNE9gU95yqmxoO7UilLOtvRv4X7SpwHgGWhOfOvrvUkCyWYTbwX2 6TDExHv8fKem4fUlHT+zodtwBon7s6+z9v6Ned9S51go3b+3QbpryC07KjiVfmYIC8SJp4taZRh8Q t48+agXQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rtut0-00000000UqD-3k9I; Mon, 08 Apr 2024 19:42:34 +0000 From: "Matthew Wilcox (Oracle)" To: Miaohe Lin Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH v2 03/11] mm: Return the address from page_mapped_in_vma() Date: Mon, 8 Apr 2024 20:42:21 +0100 Message-ID: <20240408194232.118537-4-willy@infradead.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240408194232.118537-1-willy@infradead.org> References: <20240408194232.118537-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: F3B7140003 X-Stat-Signature: 4mp76614fcy9j3kbr94rmfi387boz64y X-HE-Tag: 1712605377-530510 X-HE-Meta: U2FsdGVkX18ETT8Ur1SyzGpW3Kl8UYsBgJhfgknylFaKFPqTITeQZvN8+qnOQ8FdZKvBsE38d96dshF+K4IJ/k9X+hjj1Z6hsT0FfXTfOyHFlve12uD5vlC4/C0qj5jOtTQKlZiVJOXA6fZg2y/joaLzQ0NT4Y+kXMFDG/rR89dw5z58zINJLNEq2oX7HE3jNDaY7D1WyTMu4TA3fnzIq+hVaiq2OSB5IC+CKst2M72/RSwyVWMH1XNL6g0Kx/ArRQIzfgdhrn5xUvAMxtyKKz8G4Kl6Ibr5rtFW422/8pSDuLZxarvY4Bi/I49txE6hS9EAo4/KsqHMfNeh3JWM3LzBx7ebJHZTv15YxbPGVt8P7qgmuuL2Z4kCCzwMRE/MERJIe0vQoTpJxr3wF6uQLrugJsmRciWcdwl9GNSohSIxG/aCcDWZM/2vCKV/u6h+CNe8eTiP6DS3vyJUYAWd//HLw+q+Lvgk0eecRzP3QbZPzcvcoo5fmjecB6N8IFA1o2Fu60LR4uEVmW2ZYTc040hz/oM+ZSfXiTB0sdd1mM1avjCFDpGI9BjPwSubMPWRMMCvt33tnsf2Y4RR5LvdlKzV4yRzYTXwQ+bhUF/WacWltwPqr+3mB34g6/LRaUH6F7dNsk0uUHIytLKuTjtmTPlSkoqaj8wIFPc51sXCmiO/DaziLrdUdzRMfwduTnjObCDc+i8k2ieolnxWsl7ySx7hDWN9O+Zj6aHfORfS0z7+bpxbJfvFv2J54qH1XSJdUBsc02uSXdzu6Sii5DFSMemGPLPfPG+vpsn8sAFyzGlI769huXniLwNvd8I4JF70dgAfTmeALhhLz7mJpOsC7VEsm+eSc1JTBOG85YUGUEcZtY2U65z+7CHtghA0TlURRLZ8SKHj0MIX6w8m3BwOiR26fcVSaaR2kKsB4DlhLxFkyJKC2xSuL4Hh8sHuo5VTusV8HWNr6SVyVFoB6GG P8mLmOhx 30Cq7eza0+mMtIz7bNZYMsPp5bj6+hk7msBIWUheGw0hrrVwb8XDySe2UzEaQY0gWdAqAQ0879NcoyrPCDxaWhvocXWANrbSWN4MX5yV1FjBU4CjfCqyE14Gc18u7hn8AAeOb4fm/F+ObKY5GiWNo9J/ffA7qLqI/vDwSP+i7Y0yHkzllGWlBkSmLNoX7xmuEOqHrstnSsUUkyZNWDjEvCYS4+zQNlE21XuIoHyebniNxoOPW9YULiyvJgQ== 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: List-Subscribe: List-Unsubscribe: The only user of this function calls page_address_in_vma() immediately after page_mapped_in_vma() calculates it and uses it to return true/false. Return the address instead, allowing memory-failure to skip the call to page_address_in_vma(). Acked-by: Miaohe Lin Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Jane Chu --- mm/page_vma_mapped.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c index 53b8868ede61..48bfc17934cd 100644 --- a/mm/page_vma_mapped.c +++ b/mm/page_vma_mapped.c @@ -319,9 +319,10 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw) * @page: the page to test * @vma: the VMA to test * - * Returns 1 if the page is mapped into the page tables of the VMA, 0 - * if the page is not mapped into the page tables of this VMA. Only - * valid for normal file or anonymous VMAs. + * Return: The address the page is mapped at if the page is in the range + * covered by the VMA and present in the page table. If the page is + * outside the VMA or not present, returns -EFAULT. + * Only valid for normal file or anonymous VMAs. */ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) { @@ -336,9 +337,10 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma) pvmw.address = vma_address(vma, pgoff, 1); if (pvmw.address == -EFAULT) - return 0; + goto out; if (!page_vma_mapped_walk(&pvmw)) - return 0; + return -EFAULT; page_vma_mapped_walk_done(&pvmw); - return 1; +out: + return pvmw.address; }