From patchwork Thu Jan 11 15:24:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517538 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 898CEC47077 for ; Thu, 11 Jan 2024 15:24:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA6BB6B0093; Thu, 11 Jan 2024 10:24:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3E0F6B0095; Thu, 11 Jan 2024 10:24:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A80F66B0096; Thu, 11 Jan 2024 10:24:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 991EF6B0093 for ; Thu, 11 Jan 2024 10:24:45 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 593C2A227D for ; Thu, 11 Jan 2024 15:24:45 +0000 (UTC) X-FDA: 81667402530.02.4F43731 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf04.hostedemail.com (Postfix) with ESMTP id 8880840020 for ; Thu, 11 Jan 2024 15:24:43 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QVcPzKV1; dmarc=none; spf=none (imf04.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=1704986683; a=rsa-sha256; cv=none; b=5iyFABH+Ly+pvzqCdYf0YdfFdl/rkDukoHXndT5/QrpTHUGTETdWl7Nu5Bd8ZuE9eJUVrD 2w6d1NvE8yjrVf05LWtHiOUh6Iuqla791Gdq6uP+JrvWsTeIbSIG2lJ11JtU3FTHBZCSML RaNLGxIW/H/S/QRyiez6uWBfwtgM7ho= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=QVcPzKV1; dmarc=none; spf=none (imf04.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=1704986683; 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=SWPLe2lBFcOeS/R+eqUJaGE4qvmGFpI0sgm68JzAp2s=; b=6yKtyN/DW0FXb2k3U3vXaonC2umkoT8OAB5UnzVBK/DW0Jdio5UeKa2iowimBXeBd4vZQb GE1CNrd8p4PS04Idj/CoDvU41gsbmVeMGg+qFRdWu0Ebwc2cDx93Du7KZF6Bn4r04oV5O3 Y4hDjijP5WT9kO4VXnpSxPoChDCBqnU= 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=SWPLe2lBFcOeS/R+eqUJaGE4qvmGFpI0sgm68JzAp2s=; b=QVcPzKV1YNnMfheJtChzwtL02f e1cC0RZvvMWJyb9EQAMOvxUDzRUQBNK5BJXla2PE1U1NLRw8rVNKwo77SOCCgrC1BJsUXABWJa4OB A0AvlidZpJNlFAHwwE0y83hZJQGO0OnYb8j1PpD3+BikP4MXlFPesDYOWP8IY7cTGJSdIdgEpjJ0m NAAPl2VFN/Dmamm2L6+UBRyzl9m6QJrpHjXKd2PezMG4OX+FDSZ2iesbd6gtdR3+A3cs5paiamyj6 9/nbsEftVAL2/O9HLGsXgU1IV2Y04oWOasB4jZcz/44drZ52o+zh6IyXUu0eAGIauRzNkDdKy8+Vr r6v/heSw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9sg-Aj; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Kefeng Wang , david@redhat.com, linux-s390@vger.kernel.org Subject: [PATCH v3 01/10] mm: Add pfn_swap_entry_folio() Date: Thu, 11 Jan 2024 15:24:20 +0000 Message-Id: <20240111152429.3374566-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 8880840020 X-Stat-Signature: dhpi76xrszrk3amskku6ar5fh6cfufa8 X-HE-Tag: 1704986683-592531 X-HE-Meta: U2FsdGVkX1/REVbhHpcErPxbkXPwgInXN5PiwmTKxwtKWkOn8UFFvFfn0M5O46bRn0r9AI72yj+i3YFyltyCHaIj22gmCs2fhyWm312uHa0vyxJ8H8ZrjFdvdKUuXeV1Fhj2qbHlxTcKhYJLhRtjomPrUyGraoVQcvNco2JC8wlHPVQUEJEY5USMU9Z68V1gkiWwoQ5Cqmt5cXbpkftO7u+c9rFduKwFJU45MaQDk+QWpjquwDySFG8e/kL16/Q2LekqSul09EzLGDY8Am4wGbnDkNZAzPfD+EW7zor+yqVZ5oaJWiL0O6UBj/KSvo0KggMWseYq0ik/eRAcGmI2EACHve9w9bgzKXgFsOLYHHcOpl64zUq9ny2eo7TKH7j+ts8XWDWpOnDXTnuzwFmhrQlLpt7NpCCVjy3JDB+xJ8i36RTmuIP52LHE6/BA+toaLqoKhhhPF7LnFb2v+BG7ahi/zaMZqZzakHjEZQTfosMepiqjY6zDsfoUYQRH0T/m+k8GOAYogFp3C1NR1gL+J3DyXIjJ2hDEx1Whx0z+0koYmHQdKhViXJrcOaqJifW9h2nWoa/kcYo4JjdZjz1P8eyLQJmK2gw+Qo7D0AVUBA3A/RRUx1ya1OvEt3y4enAdf9kVq7RB1gOdE1VD3AdTJTvKG+218MgCMCJiu1+L0oSe9ekaKAf6dHNikfECVRvOGvThTwx77YRmFvBs6Z6PMOItto7lXVyfdqLuCElqJlYL3+zI4HtykUj9ovZGBJDQfxfM3Y08q4ivrc9ZeC4paQZNbN6kwHl0En3Mpi4Dg6in+xF8YCpzKM8rhLZG0KpRuIIEryyj2o3fMAnE+Xh0++o86DHkIM+TOe9U025AFQS4fIDanR0GczY1rKWd8vcN0CWIEm34l0XYrr53dN/2O/TMNGUTBAv60TshjDffs6oF0rIpgAX//qHegBUjasD/YO9hCyr1lN1JmhpqZ5C DkBuDxgo 1MDnqOqGGPCkw14UPYDbaZpCfO7Z/vd3tI1LJQI8L0JjMnOr3mBb4KaIcmeszH2+S7A4GIqEQQgOU/1CdubcjNSH441Fi7d6Ro1cQTYXTVNNS3Sxog88CdZVYfPpF5jhZA/Bse8GtZYA8oNYppO5TljzPscd8Ov+PKKtvEOZoMFv0ieCONp0MTqhvwSOK8mmFFe8UiqZOtwYb37XT5Nreelw1MFG83KZYtxWb 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: Thanks to the compound_head() hidden inside PageLocked(), this saves a call to compound_head() over calling page_folio(pfn_swap_entry_to_page()) Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/swapops.h | 13 +++++++++++++ mm/filemap.c | 2 +- mm/huge_memory.c | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/linux/swapops.h b/include/linux/swapops.h index bff1e8d97de0..48b700ba1d18 100644 --- a/include/linux/swapops.h +++ b/include/linux/swapops.h @@ -468,6 +468,19 @@ static inline struct page *pfn_swap_entry_to_page(swp_entry_t entry) return p; } +static inline struct folio *pfn_swap_entry_folio(swp_entry_t entry) +{ + struct folio *folio = pfn_folio(swp_offset_pfn(entry)); + + /* + * Any use of migration entries may only occur while the + * corresponding folio is locked + */ + BUG_ON(is_migration_entry(entry) && !folio_test_locked(folio)); + + return folio; +} + /* * A pfn swap entry is a special type of swap entry that always has a pfn stored * in the swap offset. They are used to represent unaddressable device memory diff --git a/mm/filemap.c b/mm/filemap.c index 750e779c23db..c704085f29b6 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1354,7 +1354,7 @@ void migration_entry_wait_on_locked(swp_entry_t entry, spinlock_t *ptl) unsigned long pflags; bool in_thrashing; wait_queue_head_t *q; - struct folio *folio = page_folio(pfn_swap_entry_to_page(entry)); + struct folio *folio = pfn_swap_entry_folio(entry); q = folio_waitqueue(folio); if (!folio_test_uptodate(folio) && folio_test_workingset(folio)) { diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 94ef5c02b459..5b2da360ae0c 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2035,7 +2035,7 @@ int change_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, #ifdef CONFIG_ARCH_ENABLE_THP_MIGRATION if (is_swap_pmd(*pmd)) { swp_entry_t entry = pmd_to_swp_entry(*pmd); - struct folio *folio = page_folio(pfn_swap_entry_to_page(entry)); + struct folio *folio = pfn_swap_entry_folio(entry); pmd_t newpmd; VM_BUG_ON(!is_pmd_migration_entry(*pmd)); From patchwork Thu Jan 11 15:24: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: 13517543 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 645D7C47258 for ; Thu, 11 Jan 2024 15:25:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F3CB16B009A; Thu, 11 Jan 2024 10:25:01 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EECC86B009B; Thu, 11 Jan 2024 10:25:01 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DDCF46B009C; Thu, 11 Jan 2024 10:25:01 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id CAC926B009A for ; Thu, 11 Jan 2024 10:25:01 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 96950120B7B for ; Thu, 11 Jan 2024 15:25:01 +0000 (UTC) X-FDA: 81667403202.28.800642B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id E7FB61A0003 for ; Thu, 11 Jan 2024 15:24:59 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pPLym1Dn; dmarc=none; spf=none (imf19.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=1704986700; a=rsa-sha256; cv=none; b=ZHER5SuL2TD3kFR3Br33uSMxRpQmQueeYk9OmwpCkPQSLI+jNobKN2WsHhFY5xwhQx8g97 yW3O8t07eUDA5+fOzZaSksXb8V4EHNJHrOlQX2YKaUwx0EB9St5eIsT9IZTW+3v1VrK50P IFDnxWYwgk6NOnoqeWtcZegkOtdPCGo= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pPLym1Dn; dmarc=none; spf=none (imf19.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=1704986700; 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=NG4y6T5mz41ygruMS3SPucdfvQG3VJprEVuTqUHC614=; b=Qg3yuh4CVOg6C57UpzGIlJ7ft1q1O9tzAEwkqTI1zWbwaYsOSNYtu1I1lB6tg6kiueIQuQ K3hMlihVBh6GKvzscYCVgvEW8U4EpvPXnpJFUh555CFf/psf9chz8s/5h5BRG0WT1vifCc wKK8HUtmNTPlpmjWHQmfX62IrT/l0/c= 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=NG4y6T5mz41ygruMS3SPucdfvQG3VJprEVuTqUHC614=; b=pPLym1DnNyymWjJALWJjq2mHEM u4qfQouuoLahhYk4rmRuCH3aBEuXKY2qzRFtdZBV9nqNlbL3w1bznnWqZ2cjz1V7pKPdNXC+KwSrc RjG3Kao3b7GmlG8ugDoLZwF4ONppDbbEjAZP9VBAuaXWEyyVsVK6pSA2BfV47VryGC/vDhO4aGQZD wgNAQo7kiXKQksSHJHZ40YZzGE56PMXLqBndckgnu3EJAx2GdlENwLHxHllsNpSf8f12YnBVU1mzG LGOBQ+NummSIPdHsBYyh/VtX9c2z4DtMxWzEzgIg9j2VDsBrnPRHhl+lyMZofy39Pd38bP+x5JraV oN3zt/gQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9si-DR; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Kefeng Wang , david@redhat.com, linux-s390@vger.kernel.org Subject: [PATCH v3 02/10] proc: Use pfn_swap_entry_folio where obvious Date: Thu, 11 Jan 2024 15:24:21 +0000 Message-Id: <20240111152429.3374566-3-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: E7FB61A0003 X-Stat-Signature: kkx691c13m3exfy3dd9b6xuefbb61bbu X-HE-Tag: 1704986699-260471 X-HE-Meta: U2FsdGVkX1+02JcmvLvVHM3720GursLKZDe8gZB3kB2PJIqwZW2YoGbiwcNohf6v60hcfczQ1VJD4PlccUlxTiLNVlaq0p9hwcgEsCovIsRfOE0T0qPzfXl0cr2s7lgKM50TNNwzLjoL/uFHt7dloTkBahtO46jLn8LlcaZS9DVA7Sb5sneLmui1ZxGHuH788L6U8OOHByV5PHcM3AIPnm6hc8YatJT4IbXROjyhU1YxSFdwC4w4IQmcVwqgIeCxEOHsto7M363mVZxWRvAKWYuNmgqG8zNzl73Cbz0WGhs8iRojnx45WMmfvaRaonPeRmsJZdjVQggtMgVgr4WL95Ty4kUjzKeFYMkyWATXFSmwW+rM/aKX6OxUsgheehnqWL4jNMtLrcPX2Y0cWdd8ChSMrWMXNdCC/F/HY4IvieIqdSNCr54a31hNQb0Mtiggb66PeXS/Mdew4d/BRJfR5/XKtsHyZDvqNoUKk0W+B8rRSbzMDEAriZPJs/3JgTmtRdf+k/oR/0q+biFVb8RcxfUMaY76fJSK+7jd81Vc3zbvogDbcX3vpZAWBK5IZsq6eLb5KWESf/OhlaN+PMIxwmAEeqr7p7KmAuPi12sxguPWpWsebPb7ahP9xxBO7zkASYEC7iSBAZdFZkIZEyJ3hg+zwVY5FnV0jUzUtY6P+sZVr2C8HSFztdHEcQ9GRlD9nPfnl2WlpYINiSD/T3TsAyqP+Rdx0IiF4t80aneto5ArbtCb+0F5qJCUdrXhIVrxF71uoF4x4KMm3yZ/aj9khbIiYWnD3aPaz4oaIdNqcA0vXRzkJG/Ki/+ondTDLEzbffII5FOJoDLIwTVBaPH+fvg2e0sH77Y2Yoij6q6okidCIKBlCLUWAiTAmV8BfWz9tl/42YsNmoUJxIeNgJAkg4ofbhukCO/IiGZCPLCqEmD2fAupkHFprvaf1Fn5uPJSsGSaI9LeKhiV9oD5oPm hthSJ4hA 5Fd+SqNRC99i6196eO7jdkLZrVgneUhyYZKp7dMmI13cf8MtZfosfb8AEF52PFDr6ytbTbXTZHsrOMmngtELtKQUeG9z+pIdXHZIgwHTkh7Ut9W3lq5ET+9WHOS+ZjW3k8xv4i+ZsWVslGwqP9viBzBFpQBkdBxwXt5aEWuYRiAq8CZX/aDafhNT1I41P1hF88UaaFS3Cn4/1hqFccVhNtM3XgApQAtkhddG7 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: These callers only pass the result to PageAnon(), so we can save the extra call to compound_head() by using pfn_swap_entry_folio(). Signed-off-by: Matthew Wilcox (Oracle) --- fs/proc/task_mmu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 62b16f42d5d2..6e75bfd6c3f8 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1807,7 +1807,7 @@ static unsigned long pagemap_page_category(struct pagemap_scan_private *p, if (p->masks_of_interest & PAGE_IS_FILE) { swp = pte_to_swp_entry(pte); if (is_pfn_swap_entry(swp) && - !PageAnon(pfn_swap_entry_to_page(swp))) + !folio_test_anon(pfn_swap_entry_folio(swp))) categories |= PAGE_IS_FILE; } if (pte_swp_soft_dirty(pte)) @@ -1873,7 +1873,7 @@ static unsigned long pagemap_thp_category(struct pagemap_scan_private *p, if (p->masks_of_interest & PAGE_IS_FILE) { swp = pmd_to_swp_entry(pmd); if (is_pfn_swap_entry(swp) && - !PageAnon(pfn_swap_entry_to_page(swp))) + !folio_test_anon(pfn_swap_entry_folio(swp))) categories |= PAGE_IS_FILE; } } From patchwork Thu Jan 11 15:24:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517544 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 68A36C47258 for ; Thu, 11 Jan 2024 15:25:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BDEE6B009B; Thu, 11 Jan 2024 10:25:06 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06E156B009C; Thu, 11 Jan 2024 10:25:06 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9E576B009D; Thu, 11 Jan 2024 10:25:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id D83676B009B for ; Thu, 11 Jan 2024 10:25:05 -0500 (EST) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id AD818120B7B for ; Thu, 11 Jan 2024 15:25:05 +0000 (UTC) X-FDA: 81667403370.20.A973265 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id E0B7A18001B for ; Thu, 11 Jan 2024 15:25:03 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=R0nsiLkS; dmarc=none; spf=none (imf06.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=1704986704; 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=BfP/fGwBklnFZaYvawDWMaMKV/+8upyp4Stw7tV+DLE=; b=hGCh6oi1ZZIGoSJNpcvK9do9YHA0naimYSq8+zXs6oC6Q7ENu8hZQFNeTv3AtAKwKXGSPR 6f8xLrk+fX4QjXHi5bE6yFDMxmPc09EF75BxGfSUf1irk1OApd92fMz7lJAQfP9zAukPOp qwPQKg6+8GrYggGHYXg6oCOzm1uW0T0= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=R0nsiLkS; dmarc=none; spf=none (imf06.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=1704986704; a=rsa-sha256; cv=none; b=GJJQh2xTZ4wpP5NjPKcdRu2m0MI8GM5NDdyEKRPmBpiD6mPCUMY5sD6SDqdy01AJsfYZZj XKlWF0KEUHbYPKP7FT1j6TwipWPBw0Ek3/BNQOSl/ZNfC8yn0CIljENLpBWmgDyz/oUx/b f1G7qlsq8iQzY4fTvPAV3q+2qN7M9fQ= 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=BfP/fGwBklnFZaYvawDWMaMKV/+8upyp4Stw7tV+DLE=; b=R0nsiLkSkD/AHtpue3+mNyRKTe E7sf7B2vnUbfKLKR3BihhqaUE29FmRIivR60JM4+O2M7YKN4FE0o9W4to9d0k2VYv1iWe0QV9zOTE mIIy6vy5ujGuW8RGVk/WS0lAHnJVwluedehEzchUYhoT7Dbpl/I8fC/9MOaGFI12tGKynmU8Q7dGL cRaxSEq7Fpa5LTjmob0aYXGAZmmTKdIX9tSMFwFQqwMFpR3lt6f+0rupEYOiz+s5cU9kEnr/XjlKY Fd6ZjDwTBk8CxmhoU6DV89R2O8KvFIF2RN7xz7xb6LWeCrSanosJuVWZed4/BjUJfSwNTuHd1njUU OFcwIE0g==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9sk-G8; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org, Kefeng Wang , david@redhat.com, linux-s390@vger.kernel.org Subject: [PATCH v3 03/10] mprotect: Use pfn_swap_entry_folio Date: Thu, 11 Jan 2024 15:24:22 +0000 Message-Id: <20240111152429.3374566-4-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E0B7A18001B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: g3uqdjh7bbn3h166emzjggp47nfngp44 X-HE-Tag: 1704986703-316804 X-HE-Meta: U2FsdGVkX1/U1cnJ+8trNJKEE+Tpvypzg5FDO2d+wyoD2D4XVCQbQqJCY93kuxTzTXJKhXq8KqrijOTvF2CR7AnKgwcAJSXc0eskINk6eLPyklbXu3MYVdN463rUwTk0NTqAgQoaZgqmcuDwCnaPfFUmF7FGsCHhNBEGYAfYyN5Q4xvUZ0YRzsqHUR32yOLF2QOvwO4uvcBIN3CXE5VPvSQLl656KdVCtfjvWdwq7yiZ2Uz5Cz8XD6OvlKHg6JfVugJq9beSAnLi9wQbZ3O7sEY7sV7/qw+jHEzv4LvBJYsYTGUOZqkAEnPNYkyrHTXApBnuBzwPMC2wCNKQZ0fdrCsVkyxfPa/DgFjqzqSTCaRVpyxNyWAdvhn5I8ww6c51TwCOCJJdCLBOVwgpHISaVH0PGZ74o/0IzEXQTSosS+Y1lhINjvPOZPq+vspQSZA6fWtbPLQCNMvdYr8Sad11WHSF7nJvP1UAvCUGdwt5fZYCQHNhP6piBWNIeGTOqKswoOh9lzccdM33WWIhBPt2RWwXRWoOxYoZnFHRYctmJ3RsaifyUldTsqIp/kfNRRkMSxvZnGB0VI1V8eW0lRVSefbTLbp4QHlsIOeYDwlpk01/fGUX+t+Y5CSJDEZRqdcpqX0agYdeemzhsADR3ygu9DZzNhEVh2n+lHou3Bu5dHjhL08BUDdb8/g2dUR3zwRxkmUPbYuHQ8umjqijju8kg2P9t76Sv4Ha3GMnUVI96KeprNExcL0dKBDlpPko8d4Y5NPnF4Lf7v6lcUyU5QczkiYF/ukjTS6jnGrP3QWUL2bMdj5/LKQOa8k/8woUL5STxPu6INcGngOW/cjYZ51ElmEEIZ0gIir/BhT9q6PRhHavzupeyTkxM3HBNBMyeuIhwBqyBbzuZnmPfe5FCR1XKHi6Hy7uekte6TG6xnkaflkvA18suQcb2dPHObHLwXyiEDAKK4rMdAiUGo3Y8f3 KKHYeuOi 6NWhTr2nmIGp6dsbdvCf6gro1iqbL55fFM/qS3BlFSkmvq8EK3/0V6Fzh9OpijVH3FeSNxSvlkr079vsNXZZ95C8q2PhcBUrvO7fB9/HLak5GTvXTEL5Xl/wVfn7yfKJNhwbQGFvoS5AnslJ5Kr0i6/KyVPWpICvUM/R4xskWmfPM9dtzfZJqN195Tf4pfS0n4zVtjeneCaP5CpEYQ4VU+UEoHucxojyotqd/ 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: We only want to know whether the folio is anonymous, so use pfn_swap_entry_folio() and save a call to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/mprotect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/mprotect.c b/mm/mprotect.c index 81991102f785..f8a4544b4601 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c @@ -198,13 +198,13 @@ static long change_pte_range(struct mmu_gather *tlb, pte_t newpte; if (is_writable_migration_entry(entry)) { - struct page *page = pfn_swap_entry_to_page(entry); + struct folio *folio = pfn_swap_entry_folio(entry); /* * A protection check is difficult so * just be safe and disable write */ - if (PageAnon(page)) + if (folio_test_anon(folio)) entry = make_readable_exclusive_migration_entry( swp_offset(entry)); else From patchwork Thu Jan 11 15:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517541 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 B01B2C47077 for ; Thu, 11 Jan 2024 15:24:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 022CC6B0098; Thu, 11 Jan 2024 10:24:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F164D6B0099; Thu, 11 Jan 2024 10:24:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D66926B009A; Thu, 11 Jan 2024 10:24:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C5FC06B0098 for ; Thu, 11 Jan 2024 10:24:53 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A064CA0CAA for ; Thu, 11 Jan 2024 15:24:53 +0000 (UTC) X-FDA: 81667402866.13.A4C1886 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf05.hostedemail.com (Postfix) with ESMTP id E7AA7100012 for ; Thu, 11 Jan 2024 15:24:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Xdb6YNnx; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704986692; 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=grYj7oDXTJx8wAhL05lTDgU26iqsxg0SBN9GKoUT5AE=; b=Hp/vrEWXSjwB5LSj6/HPg/rpPBlSRRzRcqdTcy74hNg9XEKbibZxEwReNKO4gTjDf5QvCk 9AGnny/MYTqJqoNEG8LX8t0YS/eV5PR59U9r4NQuOJZXyx29sJS+Nxnp4GWc9FqYS7fNxJ IvqGN7CvsZx9pvJKZuc9NC3yUJxi2AU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704986692; a=rsa-sha256; cv=none; b=WttTwl6DRx+R6/8MSNyAzcDAUDAFNGvCB2FGcoU050qYhviSNkLlDU9wTyBXi3GwzXE9xa OrjdbQkFDzOijeXOZO9a/dUE+9NLxnzlB1siDAZ1EUxWxlmpT6FqStbMokd+CMvnQ/W1k/ jAUUqGnTBGMzSq9R1UDCcoSVeVEIeks= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Xdb6YNnx; spf=none (imf05.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=grYj7oDXTJx8wAhL05lTDgU26iqsxg0SBN9GKoUT5AE=; b=Xdb6YNnxxBXSES0V1LNS1egGU2 clY+LLffhJGIXNu16qGhurri+B7H6+ljnMyT/GZA2dsuGUKFK6a7u+6lHWLOMnYPZyk2UyIy91Cel Rcl+JxphhKwHqOf2kVErU/0Zh/gLVJ+7V86Lqp3ep8aLvMY0kC2A9E3sKmLO0TBfnDctNSK+rD0kD YeApnLsNyt9pGyY9MmiIgxzFd8oTF1NC+XH9y9hHqCnB3cw3RwI2JKM1Wwl6LYY7RQO/zUbSpGRhX z2pWVhO4ETI/wG0PUTjbxmCJKKf3vUJggjWbCjrd+XDxHJ0y3uZagXZJavOntEfrQPSzhGroPYlNY ukjSqK9Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9sm-Ir; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 04/10] s390: use pfn_swap_entry_folio() in ptep_zap_swap_entry() Date: Thu, 11 Jan 2024 15:24:23 +0000 Message-Id: <20240111152429.3374566-5-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: 4jeqprmifeye7adh5cg89ft3oocdso46 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: E7AA7100012 X-Rspam-User: X-HE-Tag: 1704986691-163569 X-HE-Meta: U2FsdGVkX189f702bD5Pa0C/TSWGeswsxRBa6yEuTBw5d1pLRTyPTjl7Cu9aPTb78zMoON/Vy0ZWWTak7a3r5vc2N/XhGwlAw9T7hPDdNRcLOhWH5T3WcjTb9vbymdcHymVc3bDAUlKe745LmOAeCueHRiAM7/dfUqHMummHsUrUregObhPJVxTtKjfnhhZhBWCR/+z5XRyQexCcHM+lGY3ra52RgAX1yoKiZa30KtUws4ILvbnQ8DfZyCTzNbl4SAMQT4Oo6r6cVybenzt4vmViIExGHHOwM+MnMVowBdqd1kpR0mOCpkhOf3qXdksexcnGSfc76YuP7P/yI/xx/VyaFrfR6XEJpSy6DCL3yGKqo6+Nq9El49FM+AHQ7kwAWhOUkqSUmkEUF8CDIyZDiWdcnfaFVR9o8Oiu93u28lIeVHwZ/XE1a1d1tVJeUpQgsSUkRs96jQ8EANkdfMW2hM0GnIqqN8SPcAJ4QSdELKRSOJh9DFkNpGvP4yiihKWsaVLfjuDh2tic/Q58JfRp6PK3Tq0ZT0Ugsd3q/PhpmfRcK5s/ykNubdHnZSUE3/gmEmYJyGxCKLPVkHWaX99/YSPemJAgD9/UnWBi3lbx7VhoXCey3l7qBX8hCOW+8HW45oU9ZYydKbTMy9+VKMN4xqi4dMY6/zzZhRCV01FffNPU4iF8ZjvquoHHI+Zyu+b/486ngcO4UO8hJkHiqahPfjrDKFthKqZ6GZ0416C0fyajCEGTw5E3YXbTYZ5q71KMkmpBGSWlGhAGxc17KNmjzSM6A+lnNQP8Kj8/iMB4kxXpUz96h8q7sGwZj3B7D565JtNCYU73bJiU7872aogxn9F4Klr4wBqK9kr7lGNZrRg8aoqdiR9LdZqQCS/AYBj1sa7U9W7yPbgehJKQhxG9vyHOWnIrkK1/zcmRUx7fONrw8y7tfnmLZeOEpOzzQOmvzov+z18AJxCE/KaduYb Xqin4jA2 zTv+agJzYZnc5e09Zyz3ClTFuqEKA9k95hdP1PQeY5DA+8uCSeMPQlkOvLIx1lxU6XCfUmXsLSeJuQIN2Ps5hsC9psXvNMFrsnUH7m9WEIdNpHHiwHu3LR4I3jfXh0NHuUmbjGY01J9aNzaUSSLyyHtVHzxCZy/1AxLU4wDGpFfYhE9/p0PctIOATQ2YzdsYsx0IwteQfkumLrvUjK9e/YtWlxIhzDLFezZx9ZXYRB1CLkTOIKa0pCMuNCg== 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: From: Kefeng Wang Call pfn_swap_entry_folio() in ptep_zap_swap_entry() as preparation for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- arch/s390/mm/pgtable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 99422926efe1..7e5dd4b17664 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -721,9 +721,9 @@ static void ptep_zap_swap_entry(struct mm_struct *mm, swp_entry_t entry) if (!non_swap_entry(entry)) dec_mm_counter(mm, MM_SWAPENTS); else if (is_migration_entry(entry)) { - struct page *page = pfn_swap_entry_to_page(entry); + struct folio *folio = pfn_swap_entry_folio(entry); - dec_mm_counter(mm, mm_counter(page)); + dec_mm_counter(mm, mm_counter(&folio->page)); } free_swap_and_cache(entry); } From patchwork Thu Jan 11 15:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517545 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 E607AC47077 for ; Thu, 11 Jan 2024 15:25:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 837AE6B0087; Thu, 11 Jan 2024 10:25:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7C2F56B009C; Thu, 11 Jan 2024 10:25:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B9656B009D; Thu, 11 Jan 2024 10:25:08 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 55AEE6B0087 for ; Thu, 11 Jan 2024 10:25:08 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 39C03A0CAA for ; Thu, 11 Jan 2024 15:25:08 +0000 (UTC) X-FDA: 81667403496.27.375AAB3 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id 33AD8180026 for ; Thu, 11 Jan 2024 15:25:05 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=qYMJGgwr; dmarc=none; spf=none (imf06.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=1704986706; 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=DpHWtj8UeAQGvemXnNL2ch0TeITvLAzMMm0m+IyVsmc=; b=qcxa3SB/nDXH5bfJVfNF2/y2uUjdELx/42xqq6YE75Tjcb4HAPTsGswOkodlwRrjXP5Ica 34as19RwDjCHlKZKm50red6IZz/akZnYQG+xVrLQdKVQYu0Si2VbdVsWNg+EGHxK2s2Zwk AA6WBxXFYCgbxxIo5SMcg3UK8T1f40g= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=qYMJGgwr; dmarc=none; spf=none (imf06.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=1704986706; a=rsa-sha256; cv=none; b=eBeCHztqrMIfsQ5zRYjnD41GoJj7Km6IK2PkpEbRaZmI6ERvq8sWaBGlEX28sIaqZRjtdi RhUSrz8TDmAq31+0waHeiqTtjsANIrjjHNutOIhcCD65f+9IzhjXEj2d+Bd0C+YhDqowwO T3GkylAukdK448/68yhA+cvJPkW5lBo= 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=DpHWtj8UeAQGvemXnNL2ch0TeITvLAzMMm0m+IyVsmc=; b=qYMJGgwrJjEPeRzi/f90dt3Ozv 9PQtyqzziqRJpX+p40XvKLJkluq16ySvHxsi/iO67TMJPEubaqLslIc5g3D4vRdUHJG13tz5Cpdjf ghhn4AqibXxTlKUv6JnRmmflcyCGENaiJkF4NuD29SnejdzIXfZSIt9oE6dQblAAmMor022zW43vN S7F7ktILemN5A3vIi5n3xNRDerODTZUS2JFmM46GapYJmYSWFtGfNspu0bZ98GgvZJpggwQ3AVNkx wYLjOg9D2eiSjbtR+iqteYoh0PJyuqomx9uDeW8CvvHSc0ap4qa1T8TaI2En3zu+SE13VcoatM182 Da/ZJtHA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9so-L3; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 05/10] mm: use pfn_swap_entry_folio() in __split_huge_pmd_locked() Date: Thu, 11 Jan 2024 15:24:24 +0000 Message-Id: <20240111152429.3374566-6-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 33AD8180026 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 9xr8gnodtraw8zzoff7d9rc88gbze5dk X-HE-Tag: 1704986705-994524 X-HE-Meta: U2FsdGVkX1+U9ILmp6kD1jynNbHTrwm+15Li/WnEStorBgt56A/UoHVoSTr6a6m6Fp12j1lALAeWzMO00Rch6UM2V978bkzlE4/3EPs/umAj9MzlnX6mIz3rdNxRRk7+DQB80NGn0OvxtAowoNJ3WxZiFSnP57lGR92ONoOAgAQ6YP5d3jZeHnc0LMTJNs6o3BC5MbHygwchaxLBRKNe3id71Dq6amMqNMQzD6Dm1Y6eKzbiPH5i59FtXCYDi0huR99+p3ES+YEA+veVu85RUjQWvVKg9PiCBLnUlbphunYMVAMhQPpsug2POruW5cQ2yjbI0zWiJBoyGfE+yepJh1ck/9gTZ+AhwAFVEjmF9qALGhznHQIgvdKwWKwbFFhx/CDT+sBURe6WQ/qptnmnUK5GNO5J36WjWMZS5N7aNDnpRdsZvelji+LLLlRUtV+5NZCo0xkt07jesczwKMNQy+IWErlRd78FQJuQXN8PuIl/3gkoa0CPFryv+pGpe7W4ak3y1bh6hZfmKQ2N1fBgxHDdv6NLaUhk1uQdgWrnAvyhSJaiURCijtQY26MO50pcnp3oASkkLwWHEVdVtEdYoQdOnwbnbINAjVmxGwlr6RGAffGuoAryTZVf++2yVe4wrunyNlY1ebZAeRQSnyZ/nrt9Q44FmQpZjgEGybzYMSSzf7sBYL74/QttrsRxSpYbqhlIMkd900K6+wY3w5d/au1cDQP9g4zijv2aC8/bk98tNlSs20qSia8MSu623K1UaxEUoc9/nZushPK/1Pb3lmWM1HdSzSVKOYu/84uiVAYFZB/G1lrJgaONZTy9oRGrscIt75RvGGjLFzJWI7oD3jgHr9ydA+Yj6kvxE0S5qlCgyGkZTOyzTqq3aLodlM8NX5osiNA0capzYXCGoFSHiq6mg7mi3oRYZk1a+MRl0OLUHo9wdIjlexkafj+QBcO4fc7g/YHu4FIRYDPyMdY Qs/+IKHO n+FaJZ1QixDWJnCYhmDBfgmFz4hb3db7y7+6NaTUcPWxJtq6tncydP/AqJ6yJ7h6flg6qD1v1ZoyY4ZsYPk4i5b8VbLtY398vnXXEm4NLd3cawY3H3wwUEQt/heAnE00E0R30qgDoO7qRrqMF2ZC97DvRRgr0DA1WLyqoA/rfswEq8Hyboj6K0xrNUoLLUYkv+e7VZ/FoApD0vl4Y5pYmn7Df7crM2pyZw7b9m1e11WlzNGNG7B+BvNto+w== 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: From: Kefeng Wang Call pfn_swap_entry_folio() in __split_huge_pmd_locked() as preparation for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 5b2da360ae0c..4ad1416b60e3 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2432,7 +2432,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, swp_entry_t entry; entry = pmd_to_swp_entry(old_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_folio(entry); } else { page = pmd_page(old_pmd); folio = page_folio(page); @@ -2443,7 +2443,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, folio_remove_rmap_pmd(folio, page, vma); folio_put(folio); } - add_mm_counter(mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file(&folio->page), -HPAGE_PMD_NR); return; } From patchwork Thu Jan 11 15:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517540 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 7603DC47258 for ; Thu, 11 Jan 2024 15:24:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AAC8A6B0078; Thu, 11 Jan 2024 10:24:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A0B5D6B0096; Thu, 11 Jan 2024 10:24:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8F9126B0098; Thu, 11 Jan 2024 10:24:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 81E536B0078 for ; Thu, 11 Jan 2024 10:24:50 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2B1D21602D3 for ; Thu, 11 Jan 2024 15:24:50 +0000 (UTC) X-FDA: 81667402740.16.FD788FD Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf08.hostedemail.com (Postfix) with ESMTP id 7C8DD16001B for ; Thu, 11 Jan 2024 15:24:48 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Qm71Yl2Z; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704986688; 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=CYYNkRTkd5xFX+VO5m2RjKXg1OSKu23U+VpXCiMR+DM=; b=I3jyw8s6Ycu/Ef1bVOIlW0BqNOHe0yQfY9VjWqM1c14sZbsuSxE+LSa1bdKJYQCO5udVwI 1NIEAacXwR8XE3rm8KzEgK1986C5hZFUV6uo+5/ixcKGzIrX5zFLStCUg6p8PLnjBk2yQ6 G02Dma6tKFcyG5T17GZHi35DvV/jlzI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704986688; a=rsa-sha256; cv=none; b=3u9w7mthSASOHBIyay3xIpXEn4NPmTA/vf9eyH5lVBYkM5hBxE+VJ3YSRS99SQhhqhLqN1 GEMh1w9EZzn3NfB8r3V9SeM5Kjud75JBv0z396Vwlf8FNV5yXzJpts36sIXs26rtTdYwF0 S2anz41aJIsQFXPMBant2kdLIf67OJU= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=Qm71Yl2Z; spf=none (imf08.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none 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=CYYNkRTkd5xFX+VO5m2RjKXg1OSKu23U+VpXCiMR+DM=; b=Qm71Yl2ZL/hcUySturjDZKEqdM adPr7hRDRWEHj7lVE8ojtLUXWNtQuqjHlBJ2V1pGGZdU+ng9ARBTkBXMV76ySBdmtqCn0XYdmt68C xIQK3qM6KGSn+gDo/Ik1NUEorTGya3HIKcrc1uZJjCcsFft3nMBZDlatvvYDX0ztPJtphXgGpB41g JY/4olr8OI2etKVxeqdWRstBtP90bIh6YXJJOKy92bHFLBvB3bD5sF/7AIUAlf3szLm3TnhhAKas0 sae8WGxzk9LizWHosQfkXTG765y5ozq/NxWX8pza5AJiRcLj9uPi/4aOPA3zeTEDsq5xyfbfxsvw7 fVZbFYTA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9sq-Nj; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 06/10] mm: use pfn_swap_entry_to_folio() in zap_huge_pmd() Date: Thu, 11 Jan 2024 15:24:25 +0000 Message-Id: <20240111152429.3374566-7-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7C8DD16001B X-Rspam-User: X-Stat-Signature: worjbbq4sdhdpmms9emrkrfjzs4dr4ya X-Rspamd-Server: rspam03 X-HE-Tag: 1704986688-776135 X-HE-Meta: U2FsdGVkX1/l6gmMRRpvmMwcIrsMFfNF3zy0skfvF7Dj8DEWvBkwR0SlxIQSL/dNN2dsE96X28EBxXDrKYZFnbifcEavWeNSnCKCaPD72zzOi7dqq8Cv9gAgcGBgossvgG8dKeh/usJO3qpORQ/NcxpHpvCXelBgSk6CnQVCmUeiZBPHLb8cnQCa2BiA7hP6m0MvY3gFSgoA/xemJRKYE/w6GC4oV0cmce3fWqdKriiPpTLPyyeCPBCWn5qKmZi7n5v2+91VzPXmhQiJKnayouhJqhrZ8mHKGqwFH5xpBJFuO4D+nQf0St8Eye4BmZhHh1jBnE/4Zbv4qLyxBvvoRYm1XJqSdcGSVrudIWoWKWJ/oaNZY/36NMRuyXFfU7t2GUjm+keTwcwlCo3JUc8dHSqQABmUqViEBpkCFMCVVvAalkKvtVw9cagvRyg+9KBYuVUfWf1lx00ye/L4ucM/PviCQ5FnspzHxXvn6e0bgKU3E6eXw7P0VxlHPzxcUTgTpdc5RkL/XT1cE0Em6YF0+oLhkDmmvVX8upjVRaxqTG8QhGbDsskFV8WQP43aCFlClf9m/N/M3vm7gQez0w8JEO/FDBxuo5kvIKCjqLWQkMEmhLVvtaF4divUKdrb+YpfvFKoX4tP9ByUguhlJ5a3QXCi6qyMzIMJtclR9soE3yIpiQ9ADkhd7poZGtIfDGk4ywzrf/qgZA1nheWZ1OyScwQPApff5EIBgcYyEOpiEO7nmXGDGfcuCOiI/c53PQJR3+pWC6bSZtcmM41nL/VWGJBk22EVo0feBK87y+FluFNVSzVIu+SBEF7UQyquvteoIKV5h6xZGilI6fwVb1XiIgdtfbtvMijviBXi69U153pYew0t3bOXUL4gqCz97mpAC2fAiBV30HOCcGrbq5Vtn7rD15kxd+Oa6lqqz9rvgGRxab4fuyAz/65W+xPV4BJ6m6JfLBXVhEakOw6YkfR KkTSqToE hgHqoOZz+K+oybd67VJSzzcC6DO41cOUx1y6UyIkBxkmXZeLePt/9SzwL9zzJoRHPvFkDPP0eGMpSxWlwphh7TA4jecCxKgBYLLy+ZLKB3f7snIeYzsRjgHKxuFrF7buCG/Xe5oYnQLqYnlmOGb2UvzzPdVA6K80EKu7rhr0OXjOeWGKtUx1VQ8rhxFHFitSCf4RZ+Ie+0SBss9en7GPcqhg9BroWpa1icgsWlGGsHqK5gPZ+Izc07oPB7g== 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: From: Kefeng Wang Call pfn_swap_entry_to_folio() in zap_huge_pmd() as preparation for converting mm counter functions to take a folio. Saves a call to compound_head() embedded inside PageAnon(). Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- mm/huge_memory.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 4ad1416b60e3..4a17306c7dda 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1895,12 +1895,14 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, zap_deposited_table(tlb->mm, pmd); spin_unlock(ptl); } else { - struct page *page = NULL; + struct folio *folio = NULL; int flush_needed = 1; if (pmd_present(orig_pmd)) { - page = pmd_page(orig_pmd); - folio_remove_rmap_pmd(page_folio(page), page, vma); + struct page *page = pmd_page(orig_pmd); + + folio = page_folio(page); + folio_remove_rmap_pmd(folio, page, vma); VM_BUG_ON_PAGE(page_mapcount(page) < 0, page); VM_BUG_ON_PAGE(!PageHead(page), page); } else if (thp_migration_supported()) { @@ -1908,23 +1910,24 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, VM_BUG_ON(!is_pmd_migration_entry(orig_pmd)); entry = pmd_to_swp_entry(orig_pmd); - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_folio(entry); flush_needed = 0; } else WARN_ONCE(1, "Non present huge pmd without pmd migration enabled!"); - if (PageAnon(page)) { + if (folio_test_anon(folio)) { zap_deposited_table(tlb->mm, pmd); add_mm_counter(tlb->mm, MM_ANONPAGES, -HPAGE_PMD_NR); } else { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(page), -HPAGE_PMD_NR); + add_mm_counter(tlb->mm, mm_counter_file(&folio->page), + -HPAGE_PMD_NR); } spin_unlock(ptl); if (flush_needed) - tlb_remove_page_size(tlb, page, HPAGE_PMD_SIZE); + tlb_remove_page_size(tlb, &folio->page, HPAGE_PMD_SIZE); } return 1; } From patchwork Thu Jan 11 15:24:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517537 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 718BDC47422 for ; Thu, 11 Jan 2024 15:24:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E3676B0092; Thu, 11 Jan 2024 10:24:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 093966B0093; Thu, 11 Jan 2024 10:24:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9CC16B0095; Thu, 11 Jan 2024 10:24:42 -0500 (EST) 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 DAED06B0092 for ; Thu, 11 Jan 2024 10:24:42 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B0A7240BB8 for ; Thu, 11 Jan 2024 15:24:42 +0000 (UTC) X-FDA: 81667402404.03.BED0B36 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 2A57680005 for ; Thu, 11 Jan 2024 15:24:40 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SumA547o; dmarc=none; spf=none (imf02.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=1704986681; 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=ylZ6GfCWdkm95QXmE5YeGp/GcqdnO5+70q964u8MBL8=; b=OzjEKcXAn084Ei11p7Pk9OwmyvnwZ3N4V9UOcmmTX7bYS8tRnUr65aGfQZDdOMqq5af3/i 93+3S4J80kL+ROe8+QPd//LFJPH5XzELWj9p/AAzxOCZxhxuxFUh1NeD/tV/zxRlZAMFNt 0qPFVd06hYW370xFe2rVeIAE4UFleTk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=SumA547o; dmarc=none; spf=none (imf02.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=1704986681; a=rsa-sha256; cv=none; b=ehJt2xEXsx1lGjrKWmFvAXoh6xwOfmX4QgMbBUSxTv4wsROb1R95vTWrftyHkF4A9N2ZAJ 8N2l1Ik8IaoQdnMtbcurnk43Aydk/nMmfhnvqkVA7xjyMaQTC5a8vLGpuz0lrmYrILGn0R 6k7ehFe3vFtc+wktdniXIc7D9jBIBf0= 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=ylZ6GfCWdkm95QXmE5YeGp/GcqdnO5+70q964u8MBL8=; b=SumA547o68BIVFAVAWeLC0QQW2 NALZ4tmVt2xXo3/c1xlq57lcAwyPCP2kKPW/A9z0fPfpbFFabXPOxNJI9ueJakDzELd4d2kBSuBt0 k3jzIdFIv7HisV0LfiHPCeiZDSLaKI4SM46T1j2b5/nLq8I+4172YBORhTGv63LOlLSyP4oPJu2Ok TT8j5GYv8GpIFio2Gd1fpHiXxQBDNSkGvDDtVjoQvnklfKYa3RaixQ2eM8+Y00SeLpEd802nEAIIc vpMUgCt/xcJ0xJ6E/J43XNGBbNRYaUf5eT4FsNEu4ytz5xGjenITQpi9vLA0X69+aLGSuUrhqtoXj fnUBg2zw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9ss-Sr; Thu, 11 Jan 2024 15:24:31 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 07/10] mm: use pfn_swap_entry_folio() in copy_nonpresent_pte() Date: Thu, 11 Jan 2024 15:24:26 +0000 Message-Id: <20240111152429.3374566-8-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: w5an5sc74np1qnh5i9zqy8uhur5mhy3t X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A57680005 X-HE-Tag: 1704986680-426103 X-HE-Meta: U2FsdGVkX19iRexUmrY5awxtU6xyw6sl6txBjW5mRYHlX/5kYBY5qfvEF3i6NTwdQIuomc905iAwLX97NGqCKzcU1vYkEFLsNzhmIXDCDsy19MgZmdsSazFR/i1RdsZquVkM6wm5G9CMlFSCbiVWAP4qjcqCEkWzJcmOTM/eiwZE7qt6NDMvw3h3U5yo9D4JeQZRX7rw5JDCEMAvbSNhu31h1jmYztuSiVJLJbg9hEKmfA4NqoXzVO9cqLPRlbDnBAKmIsb+5OS+7Dh6qOjagzgX940jS8TI4ZO+Xkr4VAqhYLhkSXsTR9v2YfMAC/urnv96n0rOka6lo4h1xUe6Ye236whBN/8t/8Wj+qCzAJtwTIUJ8YNWFvgyPcthG2E7fXaGNkkbrXZ9hxHeNqBUL2t8VRFLYiu0XQqy4r/GkmeutByD6z+OSXHxi5e/pdSaEdB/ejJ+qgYV/KJfi04KlVOZDYxzt/g1s7LcwbsHppraDIqy4aaOJT4ILf3OGRt/m/ffs9Y8+iTnkFwnMJqklaIaNmYJwMGDCFCzjWMhlema7RxMUpja/ov7Bz3uy0UlINlhYcldXR42jUS8XWsdZQt6ViEwWgbueHzgGQxFD8RyoaBb6i6BNuM0acW4W2mOmVZN/JZC8DOaCG0Bu+eDOcqkPcjLRn5zRaXfBZP7lWLYtEwfUbniEg9+aJr+vGTtlg7oyeH2Yx1ylA+xTC1F97SHv0Sg9SpJCXY+I3pgchX9FJs3zQwhC6KPrcKS2cXU+XiqJqETfIOAVkcBiMrfS6pH9dNfgqvNU8bObNOVdfaQl0oNN9zu6nxdV0+Mx/VhWgUNOmywkSELR/iVwvDqrWK4/dup7k3okOZadrBM2gFmg7hLubNGq39gbBhq2kTpgrgrB9HXPHq0E8ckhNitu5FAxE+GBh0F 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: From: Kefeng Wang Call pfn_swap_entry_folio() as preparation for converting mm counter functions to take a folio. Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 7e1f4849463a..60aa08f2ccdc 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -806,9 +806,9 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } rss[MM_SWAPENTS]++; } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); + folio = pfn_swap_entry_folio(entry); - rss[mm_counter(page)]++; + rss[mm_counter(&folio->page)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { From patchwork Thu Jan 11 15:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517542 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 EA3FDC47422 for ; Thu, 11 Jan 2024 15:24:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA7EF6B0099; Thu, 11 Jan 2024 10:24:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A5A5D6B009A; Thu, 11 Jan 2024 10:24:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8AEE16B009B; Thu, 11 Jan 2024 10:24:57 -0500 (EST) 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 64CE16B0099 for ; Thu, 11 Jan 2024 10:24:57 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1C1AB1A03A9 for ; Thu, 11 Jan 2024 15:24:57 +0000 (UTC) X-FDA: 81667403034.13.5F144FC Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id 5272B4000F for ; Thu, 11 Jan 2024 15:24:54 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WLvKEMaR; dmarc=none; spf=none (imf12.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=1704986695; 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=cwPZenCs5tEi8Hk4LaFtzjhgBXHRX0Dio8DzNCbpitA=; b=CE422pk/60Hj5OCEt0DX20wLVs62rwQPaE5ujNkipen5qgHrGvYJiB4xxwg2viRxpYKa7Q EJTtxU391K43unMfNkx1MtpXqqB78sXoMSlS396OqeHV9t391j04R9QccdbumAipXI/XMC bQ/lrcXHqF4neFsfy6HNd6l0ity3sPE= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=WLvKEMaR; dmarc=none; spf=none (imf12.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=1704986695; a=rsa-sha256; cv=none; b=4J+zr4nVMEDR/v0kcCBsS7fk5YqCslk6oZeM6TQGqKC3oQw1aatDZ7aJcg5h2zON9MRxdH kB27kyM9trK3uJzgOG3wczr4WOjeElp2Zlz93t/djCZYhCR7ZRaZjtcxuia9aqLphVLRB7 ss8MvyOdp9oQ1tzZGmmB0OucwmLRbek= 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=cwPZenCs5tEi8Hk4LaFtzjhgBXHRX0Dio8DzNCbpitA=; b=WLvKEMaRcwYqspQuMwl4Svoq82 xeKIGrZQRRsfMMMHvf6/3AFadgthcHgwL97RUZJaRAdfi5LruvSjkRw9Zect0ZFXF8M4ztGYFwdwf vtyLZwZVZ29gp9+SXupcdt1Z5UrUpp74WiqkObEXeyQlLoAD7DB0kfZPjl33bUjkPQmge4izvgTfy b1mg/RvGWLB0Dfhh9wlbIbxg/lgXeQFw8aAC2pej+Aaq5dx4uEPM+i+14+X333cogocV8ydnBvCc4 M8SIPWknkQtsyBZoasDv0qZey7CoqJ6chamKz5y7sI5sdlBhPqCuDSCihr7ag1R0dwXAKaVPmC72j onE9uwFg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv1-00E9su-VZ; Thu, 11 Jan 2024 15:24:32 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 08/10] mm: Convert to should_zap_page() to should_zap_folio() Date: Thu, 11 Jan 2024 15:24:27 +0000 Message-Id: <20240111152429.3374566-9-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5272B4000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 4iafubhhxji4p47i56m4ef7uhfb3zfh8 X-HE-Tag: 1704986694-266453 X-HE-Meta: U2FsdGVkX1/5UF0CGr++FbLP/drE+B/jsebS1mgEB6RKHh9j9lNdooIeTXxvmjGJSmSaIZG4Gkq9vZIFLiXoX8H5+QrG9em5Vi8/2wpAQ2j/xQS2Jl9TVs5Og6bNGDeCB7w4SEOth5kupe5YifwJ0if1tiF+7kGnit/nRhJrYwRNqY5LEYZdHHPF+TXarLddnEI2C1QWy/cfBm3Gz6Ghf+HTT7Gu5qHge73oQ2pYoz3ICXJ/xpXw6IGYKbTz5KtkNZ9w2cd5qsONr8U78K9nYWW8Q2COsJEi0LEEfqHfFUAmpFlY1t3WwQzfXLwf0xZp4BtJ+u7/UNk1SNn1Lh7TC5jpKS46exM0QJl7ZPILPrLUGQ2nx2TSaQ2NIhlKbfslDW+oKIvZY9hMaGjMk5SlaDZ49uKLkuk3313+BZK1jc8S3GUuKHC/cGi6n4wKlQwxmjbz96zybA0QzopfnVwJdTJ2svmOXIA6ZcHt9YKX2iBvZ0OS/TSruqGNelvkKhapE9Ia4UF14lanN+l35Y3IOrQpPUVESUnyWkztza3+YoKx8jCRQiAMM7IyTmAV8YhTwVtKxJ0g9hkygOjauI4KDM0PrILxgfLQqSZHBGqL0miNJtpviynHKC7DT31vEatN8gVtnQ2UKA3YbLh5K6k0gWXwTT/PHs9Br94yQraGMLrHdgEMESxUKK8FN/bcN9Mvwj6As9qsE/kTRKgHX+HUvQGI9u9ohJA4xOZ71/KHiobe2vdXTa9eoT06X842GDKFm4HUaCJeejHO3IIifyqNw6ZcCg8U4WQM+T19Yv0Id4w9Q1MjhIvanoz1ao1aTNk45YS58Mk3vPtAPUaeSm6v2cBoccL/XHtH9QdIklmdL+FexNbjC7ob4JlLRH+ggYgzGSj9IisclvD3tmsP9sKBHHEZRfptiRd2T4NhBNABt89Q4TC6f1v6PfWT9NmWz51jOGk0hXsUaxjbWpOh+mP kxvCNeV9 brEMIU4uAfk/4447Ybw3xOquAcmUPLN6CByxNQrRUYn4yFRuAtsPoLdsPu3L8DAqVGYEt605nedtP1vgdy+uhD7HoO9tta5XOAbETLzWs7Wz+6pAjTCzMHPfHCk/VCzUhyAE00+hGYoC8zh4iz9IpTeRt7O2MxmPoAF/tANaIUaCMn0h7n41/m3qPyfsH8GS3dGL7r+HyLCQ74+4w8I9DJyHvu/WAneTvbDH1crvSpLpH5prf3urx89qVSQ== 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: From: Kefeng Wang Make should_zap_page() take a folio and rename it to should_zap_folio() as preparation for converting mm counter functions to take a folio. Saves a call to compound_head() hidden inside PageAnon(). Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- mm/memory.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/mm/memory.c b/mm/memory.c index 60aa08f2ccdc..b73322ab9fd6 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1369,19 +1369,20 @@ static inline bool should_zap_cows(struct zap_details *details) return details->even_cows; } -/* Decides whether we should zap this page with the page pointer specified */ -static inline bool should_zap_page(struct zap_details *details, struct page *page) +/* Decides whether we should zap this folio with the folio pointer specified */ +static inline bool should_zap_folio(struct zap_details *details, + struct folio *folio) { - /* If we can make a decision without *page.. */ + /* If we can make a decision without *folio.. */ if (should_zap_cows(details)) return true; - /* E.g. the caller passes NULL for the case of a zero page */ - if (!page) + /* E.g. the caller passes NULL for the case of a zero folio */ + if (!folio) return true; - /* Otherwise we should only zap non-anon pages */ - return !PageAnon(page); + /* Otherwise we should only zap non-anon folios */ + return !folio_test_anon(folio); } static inline bool zap_drop_file_uffd_wp(struct zap_details *details) @@ -1447,7 +1448,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, unsigned int delay_rmap; page = vm_normal_page(vma, addr, ptent); - if (unlikely(!should_zap_page(details, page))) + if (page) + folio = page_folio(page); + + if (unlikely(!should_zap_folio(details, folio))) continue; ptent = ptep_get_and_clear_full(mm, addr, pte, tlb->fullmm); @@ -1460,7 +1464,6 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, continue; } - folio = page_folio(page); delay_rmap = 0; if (!folio_test_anon(folio)) { if (pte_dirty(ptent)) { @@ -1492,7 +1495,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, is_device_exclusive_entry(entry)) { page = pfn_swap_entry_to_page(entry); folio = page_folio(page); - if (unlikely(!should_zap_page(details, page))) + if (unlikely(!should_zap_folio(details, folio))) continue; /* * Both device private/exclusive mappings should only @@ -1513,10 +1516,10 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (unlikely(!free_swap_and_cache(entry))) print_bad_pte(vma, addr, ptent, NULL); } else if (is_migration_entry(entry)) { - page = pfn_swap_entry_to_page(entry); - if (!should_zap_page(details, page)) + folio = pfn_swap_entry_folio(entry); + if (!should_zap_folio(details, folio)) continue; - rss[mm_counter(page)]--; + rss[mm_counter(&folio->page)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only From patchwork Thu Jan 11 15:24:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517536 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 9555FC47258 for ; Thu, 11 Jan 2024 15:24:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D2AB6B008A; Thu, 11 Jan 2024 10:24:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8824B6B0092; Thu, 11 Jan 2024 10:24:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 688376B0095; Thu, 11 Jan 2024 10:24:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 4E6AB6B0092 for ; Thu, 11 Jan 2024 10:24:42 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 25CF3A2188 for ; Thu, 11 Jan 2024 15:24:42 +0000 (UTC) X-FDA: 81667402404.07.E12F751 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id EB63E180007 for ; Thu, 11 Jan 2024 15:24:39 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=JGH+1Vk7; dmarc=none; spf=none (imf06.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=1704986680; 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=ICF9LS0a/Yck6c1d8aWnlAw0yJ+x3RGOq1LGLEZtkVo=; b=n7DQJ6he2rEbdC79+KBjuupat0oify/HgMqGlc9vV/s+tXM+ont/Cxgr0J8Emd+eEc7cSL nHU1q/nW0K2oW3dAdMPtkrlG/pD+iC7JBMjYqJOKGpHBJTnSK4dG83xDcDJ7VZXzjuDHfI UTHAu7yITy6o96vIiu+yP/0gRKVfmNo= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=JGH+1Vk7; dmarc=none; spf=none (imf06.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=1704986680; a=rsa-sha256; cv=none; b=5tEI53I0UuaE7GFHUPM2pLqM9Xi9CVKGi1uGVu7xwSkd1OyeGn2MXQA+l5L3RAdDM/lD5x d5SsoqVuKi5Nwl61AP6zFRCDMZQFhS0cebbX3TtDk9CFC7R6MGZxhAHk8IbuuEUnEYJhOo sNSVdZoE+cycvzgqLCNREssBT1aSDgw= 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=ICF9LS0a/Yck6c1d8aWnlAw0yJ+x3RGOq1LGLEZtkVo=; b=JGH+1Vk7AGOiSVpl5+BV2HzGX0 9c1y8jIRfULhE2wJAq3YB/z0IPwlB7Xj5P9N76TNsquMxDfWMk3SFPMUduDwEOcyVlPhbG1Qcg5d5 u/nI66o2/QajMLkwCPQVj7YSJMuxzJsM5xzdK5vFEG1ClahD2F2E2pnfgGFAZZFl4Q1bOKvcDSn3R wZWxNhkkkOZCWzS/de/AQ1C9UEjkAvgflelkgFXQcdVKbXq8RlFsmOJZ/alqdHIOVslNA2hNXx7az Rd4ow0Ot8KB6YV2318qqPoXHi1CvtujhQxs4PjvSIfxdK0p3ZJ18D1nS5UOIi17Q3mXR2s5VquvTs bNeC0CVA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv2-00E9sw-21; Thu, 11 Jan 2024 15:24:32 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 09/10] mm: convert mm_counter() to take a folio Date: Thu, 11 Jan 2024 15:24:28 +0000 Message-Id: <20240111152429.3374566-10-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: wji8apfythkndqbkfc6h4dp7xqm6zcci X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: EB63E180007 X-HE-Tag: 1704986679-662177 X-HE-Meta: U2FsdGVkX1961tjC55Oj8JCNJ8/DHTMHjGBatK9505bhMudAaUrTMEkVbl11Pu0VHhxpIk1YxQ01UtKDU6zyGR+nYbCliyQzMNma+Py0J8u3/x4x51D5+Y8e5Fn6CE6i/tHlMi6HuW3jiVlgL0Yw1x5HFClK16kE/vRfheQ3NrZeafJxNeHAcnvgd3ZN+soeXqxTvQ/oGRwOeq3B2sBTRXqKEEToFfxQvssAJkdgMUkJ7R3D5DQKPy4dFRBDpUIXsYvj8hmcI9ZsyEHyzm9X/MbF4WqdYp+aI9rJmNxWvBapke9C48bUUJhDf9EchyKGqon6odu8+JfiIe7YOTl2Mmo1Ubx5LvAWJzYWkeae5FSi4VifAVpynbSu7tl28+CG/cCGHQ6Ul6pTuJ4v9RDOEE7Qynhn6EEPMtTAeD4VTY3OOo4SpF1SJSS4Qv0Z3lJ7u82e+PYZJJoHFzOoUgtCs4BJ940wYWj7/u0/302qA9OxDxsJmYipl7ME/3pLtS5CBeZZJtOosrtIRh0y5bQiNdgBX55rW3u2N2YkIfAoI+tcT/NZ/JeFkUo8Rt5+wxp2kiJqV6BA98L0oxbQJAUjDZiSjfADyWvkliYg9Qe7avGABE4lYLd6q55Ecj4kcD0NlIKsYxrpkQYiKIknfFShNhaWDiONNxrZ7BDnIOCW/JngMBMfKs0SPDjdiwUiiGG3p9hfivfz0T/K43oO1cfedJA4LyIc39yCOAyIz/wQhvJ/90RJRzJ4KkZE+07KL4zhCqgMCI4U0jcdkqr3WYl3r9wsMdqxFch87e7CMCSW91LOsfqMuogLjVJ5nEPfVI0tTy4plZ3BgPiV+bSXVcGRW1bfFuO/n/vSc50Tyym7RGVodABWi9ix0F3IaWCt0YWkTKu3fdZpJISyUhqvngWG9B1+QhTEclt8/ZIHNTHvfLGPBF6dV7klhMVT44DUVLnJSBuBPz50Yw91Xbw79vc W9YYGLyC 0oLWkZVW4XC3rBa552XGzz4lqSyYMr+HYNxvrM3vJs/p2qaLCJ/uePzlNWw9oF450AlnAccG7rLS7xIahc7/n1mUpJ7+qm0+bEQlTFT/jZcd6lMdXyyFTNWJFArScY9JrU8R4fXszRGvIH7lBQ+hWybJM5MbutukO7D1DoIFsnLok5mBZKvBJcmFOD7X9o4YwYTPpHsVmBGQVT8iO6or4brV3+z7IPtKnww7yVB/ymUN0DN3WL6ZSRYjGmw== 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: From: Kefeng Wang Now all callers of mm_counter() have a folio, convert mm_counter() to take a folio. Saves a call to compound_head() hidden inside PageAnon(). Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- arch/s390/mm/pgtable.c | 2 +- include/linux/mm.h | 6 +++--- mm/memory.c | 10 +++++----- mm/rmap.c | 8 ++++---- mm/userfaultfd.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c index 7e5dd4b17664..b71432b15d66 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -723,7 +723,7 @@ static void ptep_zap_swap_entry(struct mm_struct *mm, swp_entry_t entry) else if (is_migration_entry(entry)) { struct folio *folio = pfn_swap_entry_folio(entry); - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); } free_swap_and_cache(entry); } diff --git a/include/linux/mm.h b/include/linux/mm.h index f5a97dec5169..22e597b36b38 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2603,11 +2603,11 @@ static inline int mm_counter_file(struct page *page) return MM_FILEPAGES; } -static inline int mm_counter(struct page *page) +static inline int mm_counter(struct folio *folio) { - if (PageAnon(page)) + if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(page); + return mm_counter_file(&folio->page); } static inline unsigned long get_mm_rss(struct mm_struct *mm) diff --git a/mm/memory.c b/mm/memory.c index b73322ab9fd6..53ef7ae96440 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -808,7 +808,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } else if (is_migration_entry(entry)) { folio = pfn_swap_entry_folio(entry); - rss[mm_counter(&folio->page)]++; + rss[mm_counter(folio)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { @@ -840,7 +840,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, * keep things as they are. */ folio_get(folio); - rss[mm_counter(page)]++; + rss[mm_counter(folio)]++; /* Cannot fail as these pages cannot get pinned. */ folio_try_dup_anon_rmap_pte(folio, page, src_vma); @@ -1476,7 +1476,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, if (pte_young(ptent) && likely(vma_has_recency(vma))) folio_mark_accessed(folio); } - rss[mm_counter(page)]--; + rss[mm_counter(folio)]--; if (!delay_rmap) { folio_remove_rmap_pte(folio, page, vma); if (unlikely(page_mapcount(page) < 0)) @@ -1504,7 +1504,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, * see zap_install_uffd_wp_if_needed(). */ WARN_ON_ONCE(!vma_is_anonymous(vma)); - rss[mm_counter(page)]--; + rss[mm_counter(folio)]--; if (is_device_private_entry(entry)) folio_remove_rmap_pte(folio, page, vma); folio_put(folio); @@ -1519,7 +1519,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, folio = pfn_swap_entry_folio(entry); if (!should_zap_folio(details, folio)) continue; - rss[mm_counter(&folio->page)]--; + rss[mm_counter(folio)]--; } else if (pte_marker_entry_uffd_wp(entry)) { /* * For anon: always drop the marker; for file: only diff --git a/mm/rmap.c b/mm/rmap.c index f5d43edad529..4648cf1d8178 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1780,7 +1780,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, set_huge_pte_at(mm, address, pvmw.pte, pteval, hsz); } else { - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -1795,7 +1795,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * migration) will not expect userfaults on already * copied pages. */ - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); } else if (folio_test_anon(folio)) { swp_entry_t entry = page_swap_entry(subpage); pte_t swp_pte; @@ -2181,7 +2181,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, set_huge_pte_at(mm, address, pvmw.pte, pteval, hsz); } else { - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); set_pte_at(mm, address, pvmw.pte, pteval); } @@ -2196,7 +2196,7 @@ static bool try_to_migrate_one(struct folio *folio, struct vm_area_struct *vma, * migration) will not expect userfaults on already * copied pages. */ - dec_mm_counter(mm, mm_counter(&folio->page)); + dec_mm_counter(mm, mm_counter(folio)); } else { swp_entry_t entry; pte_t swp_pte; diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c index 216ab4c8621f..662ab304cca3 100644 --- a/mm/userfaultfd.c +++ b/mm/userfaultfd.c @@ -124,7 +124,7 @@ int mfill_atomic_install_pte(pmd_t *dst_pmd, * Must happen after rmap, as mm_counter() checks mapping (via * PageAnon()), which is set by __page_set_anon_rmap(). */ - inc_mm_counter(dst_mm, mm_counter(page)); + inc_mm_counter(dst_mm, mm_counter(folio)); set_pte_at(dst_mm, dst_addr, dst_pte, _dst_pte); From patchwork Thu Jan 11 15:24:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13517535 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 09B01C47077 for ; Thu, 11 Jan 2024 15:24:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4B4C36B0087; Thu, 11 Jan 2024 10:24:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4644C6B008A; Thu, 11 Jan 2024 10:24:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 304BD6B0092; Thu, 11 Jan 2024 10:24:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1D2D56B0087 for ; Thu, 11 Jan 2024 10:24:42 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id C5E67140B67 for ; Thu, 11 Jan 2024 15:24:41 +0000 (UTC) X-FDA: 81667402362.07.0A5BAE7 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id AFEB120018 for ; Thu, 11 Jan 2024 15:24:37 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=D+SXDLIm; dmarc=none; spf=none (imf03.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=1704986679; 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=/JVekdlGZM0tpkfZjc1ZJe7iyChUAelazfelkg1Lz/4=; b=SR09ScVQIfJle4Gr4ZwFkZPV3hXLd25IsW8nReGeFBi/Sb4/y0CWamQPiqcBJyYV/iXxt9 vGNpJe8WcmsaaVhV0fBu0LmFbT58AmEJuu+RkAGPD3YWVJIPA1o25T8+T4lPGnOzQ4jLC3 qWbWnjnIWr1XA8Q/j6DKRo/CgYqBZyc= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=D+SXDLIm; dmarc=none; spf=none (imf03.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=1704986679; a=rsa-sha256; cv=none; b=z+Bh/4mnndHbKGcc4nA3574J2QuOJb2cyESZs8EWwksIdo9iS+e558D9ftOww9o0OTIx+Z Ub6hTk/fBrYbs8ziQ9fEEbmu1kX3OrJXZhfPEsxS7zjoPIN7CjjOOxiXsWlsOThTl03lx1 piWTjsNK34j7Kl4l1bfiU731/29cAQI= 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=/JVekdlGZM0tpkfZjc1ZJe7iyChUAelazfelkg1Lz/4=; b=D+SXDLImf7oLbCf33/4juKuCdQ /Rg+YVL1d9CbksbSStIW+tgYUeJaaSaR1Cz3+AsiHZF7J+aAPLVZdbCk1VozQw7ZVE4CojgcxnKPp Snd86to3yWKqDYI37Y595yE7Dysu7ivskJSWPoFPzffcwNOREYYi+DCa2M0029X9HoVb+WHRiAtDo 0P2D12Pu5RUHU36D8emC6uGhbgCtDynzlxivWBXMvQS/3z2WgBewi0R4SjsrNxEMcslOS8Y5EsnWp 6P/Mummf9EMFIEeXa4NROBsAVfdTkRkWSS9rlNxmCbqoX6RJ+VgEgy9GHaK/9nfINTFaNMcKM50pm OvwFJWrA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1rNwv2-00E9sy-4k; Thu, 11 Jan 2024 15:24:32 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: Kefeng Wang , linux-mm@kvack.org, david@redhat.com, linux-s390@vger.kernel.org, Matthew Wilcox Subject: [PATCH v3 10/10] mm: convert mm_counter_file() to take a folio Date: Thu, 11 Jan 2024 15:24:29 +0000 Message-Id: <20240111152429.3374566-11-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20240111152429.3374566-1-willy@infradead.org> References: <20240111152429.3374566-1-willy@infradead.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: AFEB120018 X-Stat-Signature: nrri9geybhtr97etdg1s5u44ypqqyu68 X-HE-Tag: 1704986677-348665 X-HE-Meta: U2FsdGVkX1967rGd+zxJ53dCm4rW/F7RFQCZoBi14WKy15Hz6S5z7+681aQE8+YH6HwuUBcQG1Bu0gjn5AqheJ6yJMg8WhilGyU1e6MX9RgYHaFBBnA1o7YOTN8Y6Tgve+b0XMYzSq8S80nvW0VXUqGwmGjwjhgL1OINPz2aNJAfznblyWVXS8b9lTf90sK8ux/QNOc04FmqTnZYLbnEt8n29SWgLQAopBsKXU9OnorpnH/9iUH747hvBji6G0IKHkaTbgHqscjdJKXHqF01zltFxvq3HeO1+L2VT8LRRfG0ho3HQHFfljpeDh2uvqQ8XmhyIKa2PwEn5UzIIUB2lIGq6sxS756t8PSVF8YriE2GZp8mp/SW4EIZkFcdNENJtAf3FGVQCgGh55xf3nx2TZsfNbbq0J5AycQcuUam1msaLd5EutqUd9zXWdqZQf9+YhTac2J1OaISimPuVU5sM7oYiJRwizw+b9/c7QtuRGMk6/lPZgtSyL22CziO0XOAEWc9lOJdRwWVZrUc3nXTDvp5rfbztskreTFN5QNSSlPxzStCT7lMV3mKaV8TY1w+OJTHFOAh8D0xh2c/mqDm9beMENgAJ77pYaEvOQu0F0Um/X7M4RDwZ3fzc/ekqxRmbC1+r+V5WWgVjj/UlJSrI5UGCXLOP716KNwtPsN7/A46unVz0I4yEZBd3kIevcsYgO3LZmocEWanEWl9EaZ0t19lxXxNosvDr91o4IqlQIUD8UThWpv7v/ORYcfcHRmLDw6O7SOa4ey1grtGEb3VO603qPFx7DMXf/I3O0zoz4Q3ti/5/9ZZPbR5rNDYeTl39dojFaQsW8NN7ViP1KYMVWaXfzJF8jXyUz8m1HgPk16y7pj0NORuKUcJBvyCkmlfa65T8PTr39aM3C0Li4JZGMDLhlsMQiMZ 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: From: Kefeng Wang Now all callers of mm_counter_file() have a folio, convert mm_counter_file() to take a folio. Saves a call to compound_head() hidden inside PageSwapBacked(). Signed-off-by: Kefeng Wang Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/mm.h | 8 ++++---- kernel/events/uprobes.c | 2 +- mm/huge_memory.c | 4 ++-- mm/khugepaged.c | 4 ++-- mm/memory.c | 10 +++++----- mm/rmap.c | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 22e597b36b38..ac6b71cbdffb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2595,10 +2595,10 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member) mm_trace_rss_stat(mm, member); } -/* Optimized variant when page is already known not to be PageAnon */ -static inline int mm_counter_file(struct page *page) +/* Optimized variant when folio is already known not to be anon */ +static inline int mm_counter_file(struct folio *folio) { - if (PageSwapBacked(page)) + if (folio_test_swapbacked(folio)) return MM_SHMEMPAGES; return MM_FILEPAGES; } @@ -2607,7 +2607,7 @@ static inline int mm_counter(struct folio *folio) { if (folio_test_anon(folio)) return MM_ANONPAGES; - return mm_counter_file(&folio->page); + return mm_counter_file(folio); } static inline unsigned long get_mm_rss(struct mm_struct *mm) diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 485bb0389b48..948c2e064ca3 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c @@ -188,7 +188,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr, dec_mm_counter(mm, MM_ANONPAGES); if (!folio_test_anon(old_folio)) { - dec_mm_counter(mm, mm_counter_file(old_page)); + dec_mm_counter(mm, mm_counter_file(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 4a17306c7dda..f40feb31b507 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1921,7 +1921,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, } else { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - add_mm_counter(tlb->mm, mm_counter_file(&folio->page), + add_mm_counter(tlb->mm, mm_counter_file(folio), -HPAGE_PMD_NR); } @@ -2446,7 +2446,7 @@ static void __split_huge_pmd_locked(struct vm_area_struct *vma, pmd_t *pmd, folio_remove_rmap_pmd(folio, page, vma); folio_put(folio); } - add_mm_counter(mm, mm_counter_file(&folio->page), -HPAGE_PMD_NR); + add_mm_counter(mm, mm_counter_file(folio), -HPAGE_PMD_NR); return; } diff --git a/mm/khugepaged.c b/mm/khugepaged.c index 2b219acb528e..fe43fbc44525 100644 --- a/mm/khugepaged.c +++ b/mm/khugepaged.c @@ -1634,7 +1634,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, /* step 3: set proper refcount and mm_counters. */ if (nr_ptes) { folio_ref_sub(folio, nr_ptes); - add_mm_counter(mm, mm_counter_file(&folio->page), -nr_ptes); + add_mm_counter(mm, mm_counter_file(folio), -nr_ptes); } /* step 4: remove empty page table */ @@ -1665,7 +1665,7 @@ int collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr, if (nr_ptes) { flush_tlb_mm(mm); folio_ref_sub(folio, nr_ptes); - add_mm_counter(mm, mm_counter_file(&folio->page), -nr_ptes); + add_mm_counter(mm, mm_counter_file(folio), -nr_ptes); } if (start_pte) pte_unmap_unlock(start_pte, ptl); diff --git a/mm/memory.c b/mm/memory.c index 53ef7ae96440..b8bc09696cc9 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -966,7 +966,7 @@ copy_present_pte(struct vm_area_struct *dst_vma, struct vm_area_struct *src_vma, } else if (page) { folio_get(folio); folio_dup_file_rmap_pte(folio, page); - rss[mm_counter_file(page)]++; + rss[mm_counter_file(folio)]++; } /* @@ -1873,7 +1873,7 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte, return -EBUSY; /* Ok, finally just insert the thing.. */ folio_get(folio); - inc_mm_counter(vma->vm_mm, mm_counter_file(page)); + inc_mm_counter(vma->vm_mm, mm_counter_file(folio)); folio_add_file_rmap_pte(folio, page, vma); set_pte_at(vma->vm_mm, addr, pte, mk_pte(page, prot)); return 0; @@ -3178,7 +3178,7 @@ static vm_fault_t wp_page_copy(struct vm_fault *vmf) if (likely(vmf->pte && pte_same(ptep_get(vmf->pte), vmf->orig_pte))) { if (old_folio) { if (!folio_test_anon(old_folio)) { - dec_mm_counter(mm, mm_counter_file(&old_folio->page)); + dec_mm_counter(mm, mm_counter_file(old_folio)); inc_mm_counter(mm, MM_ANONPAGES); } } else { @@ -4463,7 +4463,7 @@ vm_fault_t do_set_pmd(struct vm_fault *vmf, struct page *page) if (write) entry = maybe_pmd_mkwrite(pmd_mkdirty(entry), vma); - add_mm_counter(vma->vm_mm, mm_counter_file(page), HPAGE_PMD_NR); + add_mm_counter(vma->vm_mm, mm_counter_file(folio), HPAGE_PMD_NR); folio_add_file_rmap_pmd(folio, page, vma); /* @@ -4526,7 +4526,7 @@ void set_pte_range(struct vm_fault *vmf, struct folio *folio, folio_add_new_anon_rmap(folio, vma, addr); folio_add_lru_vma(folio, vma); } else { - add_mm_counter(vma->vm_mm, mm_counter_file(page), nr); + add_mm_counter(vma->vm_mm, mm_counter_file(folio), nr); folio_add_file_rmap_ptes(folio, page, nr, vma); } set_ptes(vma->vm_mm, addr, vmf->pte, entry, nr); diff --git a/mm/rmap.c b/mm/rmap.c index 4648cf1d8178..1cf2bffa48ed 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1903,7 +1903,7 @@ static bool try_to_unmap_one(struct folio *folio, struct vm_area_struct *vma, * * See Documentation/mm/mmu_notifier.rst */ - dec_mm_counter(mm, mm_counter_file(&folio->page)); + dec_mm_counter(mm, mm_counter_file(folio)); } discard: if (unlikely(folio_test_hugetlb(folio)))