From patchwork Sat Nov 4 03:55:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13445387 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 ABCC7C4332F for ; Sat, 4 Nov 2023 03:56:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5F028D00D2; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E35438D00D5; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD4F18D00D2; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A1BC08D00D5 for ; Fri, 3 Nov 2023 23:55:52 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8522B1A0DD8 for ; Sat, 4 Nov 2023 03:55:52 +0000 (UTC) X-FDA: 81418908144.17.C9C4EE1 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf26.hostedemail.com (Postfix) with ESMTP id 777E6140013 for ; Sat, 4 Nov 2023 03:55:49 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699070150; 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:in-reply-to:references:references; bh=/pjTV/UH3Htl4eHQK4ntBuuWBvSNKg8stTZ8yGGw66M=; b=5LcCGGnvsZJV84RWstBq8WAXXyywjY3j67KJkp/eUJ3VTxpwjtWPyFL2vj6Jc2yjZoqBdQ hlcVfgCFDT3lTxnZZaRqfr6TVsNHvVJw1IGrdlKhT+6UcL0y3GXi0BnHdFfO76ntXJMyu9 KS0AElCso0OcXQiFEdktFdEROSXYwYM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699070150; a=rsa-sha256; cv=none; b=N7lYGnAzcVJRV9g3uN+Up430EiTxNKUhhDOXMrdU0hRqZFndSQKSDpDQAC1Cli7ZHYSVFO coZOECq6UPcFN+2zF2dOhUBS/qMRnALcuZeFK4QwlWlcNuq903C+/Oa8ad4nsFgZ12cBjs SX9KszuzaCCM5OI9+QiqkAsxHSIW8zs= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SMkDn0qXmzMmSn; Sat, 4 Nov 2023 11:51:21 +0800 (CST) Received: from localhost.localdomain (10.175.112.125) by dggpemm100001.china.huawei.com (7.185.36.93) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Sat, 4 Nov 2023 11:55:44 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH v2 09/10] mm: convert mm_counter() to take a folio Date: Sat, 4 Nov 2023 11:55:21 +0800 Message-ID: <20231104035522.2418660-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> References: <20231104035522.2418660-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 777E6140013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: e1xwitehman9zrdf1zwdmdpi6hjsddai X-HE-Tag: 1699070149-293455 X-HE-Meta: U2FsdGVkX1+igMe2EJjveZQ5PFPaoqpECIvyK0vpzkE7V0Yt8jZjLyA2p2Iq48fFOtBDauYuIo0toM8AoJ+x8AmHZRpEE36KZz79SXQykQ2CXe8IDctRxH1NR+SSQWQOYP7eT1Q856Qb0JAwZFEOaYfXpfzhvnMdDcw730LSJ9JMeeVHNUkQ4XQ6edXM1FG18TbMrrnc1QvIGY00VJUOVc8B1A18PzV6PnlalS8F32kgw2Je043wVDg1zH4+BRwaOBIjGOEZ88AxrjeAVQj2rkgsXvOsOCbOCt+eL8DNuSeWSyz6CeTBcC/kt/oK6If3nw0PAbAKkSoBU2yWYaeJQ+3HZ209F7/6A2c/e8PzehHYxtsRoDVunyzCxvUHGkxoQ6zPCQOb7qxP8C81Hr45q/s6gSTFC0zc+2V4gqEG7Wva7WIHYP9/uZfDHDZ1L4x3D25CPuvRopPRFLotT7f65KEpWTOjt9cJPtzMWttZSi7YIzm6uE7amniQKFg/bTgiPPpUAziiIjLMwN05vU+k4yiujFa269Co9m3Y1Q3GsurAsDDOxnT+xVtnziej1rR8MZoDqJXSqk3tTj4M+lZRPnhZpbTuoU/47OPzDVuXIeK2xnLnIo45XgmCoxDI2uW9ilP2BstwmqspkttSBefS/rzBd9BGS4oD2ona9/kNUFw6PGDN9rYL0LKNP/FxJUt278sOcT9PPY3tHw58MOVHV+CaJx2w8AdIilKApE0jokwruNvGZ+0j6BYSZspbgYob6tBSoVhGev9ILIEfGAZoh31QzQ5aoNBFckKxIDCkBkpWr+ie4qtX9Qb4nCJorTYRYUvwEYMi8zNDr3oAh5y2I2KMejBk/CBlnPB/gX4bVCpCOHxvdGqyhSU86S2oE7r4eMZf6tOW4/nULX2onw8EXjSzwZjPctrC1rpEwo4JFo125APtzyCWHK8ZDOVyHYjOyE8OE4flOwMiH40s/Gl sbPeMHAT UDeVrVFyLuCkLoT0/AJtVf0CFdz1Di5eFKrim7/cObaOl/tNLCFrxweU56N58hJM6/9vP9n7G0+JlmH1lvFjgRdXstpyOo6ibgr2HveCMrkQ1PVfR0lSSX1HRz73mFqw1FogGn47va4Gmn3WrEpnCBx2TmAiOgdU7P224XN53X4GiSu5IRReeKOF6eRyOLNpLXOsU/lZNxD3y6ti4wVduBlWvfc/hdb1RBCAiOGR+nAyZ5zo= 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: Since all mm_counter() callers with a folio, let's convert mm_counter() to take a folio. Signed-off-by: Kefeng Wang --- 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 2f946b493fff..54b184648db6 100644 --- a/arch/s390/mm/pgtable.c +++ b/arch/s390/mm/pgtable.c @@ -732,7 +732,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_to_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 418d26608ece..fea78900bf84 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2591,11 +2591,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 a2cf240b1975..ad30d4ad2223 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -803,7 +803,7 @@ copy_nonpresent_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, } else if (is_migration_entry(entry)) { folio = pfn_swap_entry_to_folio(entry); - rss[mm_counter(&folio->page)]++; + rss[mm_counter(folio)]++; if (!is_readable_migration_entry(entry) && is_cow_mapping(vm_flags)) { @@ -834,7 +834,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(&folio->page)]++; + rss[mm_counter(folio)]++; /* Cannot fail as these pages cannot get pinned. */ BUG_ON(page_try_dup_anon_rmap(&folio->page, false, src_vma)); @@ -1464,7 +1464,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) { page_remove_rmap(page, vma, false); if (unlikely(page_mapcount(page) < 0)) @@ -1492,7 +1492,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(&folio->page)]--; + rss[mm_counter(folio)]--; if (is_device_private_entry(entry)) page_remove_rmap(&folio->page, vma, false); folio_put(folio); @@ -1507,7 +1507,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, folio = pfn_swap_entry_to_folio(entry); if (!should_zap_page(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 7a27a2b41802..7a563490ce08 100644 --- a/mm/rmap.c +++ b/mm/rmap.c @@ -1678,7 +1678,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); } @@ -1693,7 +1693,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; @@ -2075,7 +2075,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); } @@ -2090,7 +2090,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 96d9eae5c7cc..9a6759fa9b06 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);