From patchwork Mon Nov 6 15:49:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13447160 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 57FB3C4332F for ; Mon, 6 Nov 2023 16:07:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E0A5B8E000A; Mon, 6 Nov 2023 11:07:55 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DB9BB8E0001; Mon, 6 Nov 2023 11:07:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5C9A8E000A; Mon, 6 Nov 2023 11:07:55 -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 B78B28E0001 for ; Mon, 6 Nov 2023 11:07:55 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 783A614081C for ; Mon, 6 Nov 2023 16:07:55 +0000 (UTC) X-FDA: 81428010510.08.1BF0C27 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by imf13.hostedemail.com (Postfix) with ESMTP id 2BFB82001C for ; Mon, 6 Nov 2023 16:07:50 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 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=1699286872; 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=113j91Z/CFywLfCKAhAiKZT7Zsk5X2/WxRslA1lSS0I=; b=1gWY/QwMPYSjlzwMVtuCxEo8pJm7OhBYaS3dkhhwutv1Iu7lqy3AkSc0X0Z0Q+0PRvuu1o x/GNhSv0j42cwjI2e4QIokQrXg3FlRDFFtlbiHhksz4i/wzzgQwsJfSKWqJrTZ+vUJOSeD GQAIqs8K/L3AbSw5VI+ieCpAUCcl564= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=none; spf=pass (imf13.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.255 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699286872; a=rsa-sha256; cv=none; b=puzttEYSwhqg8BZB991Rwn+1Lg2L3Z4SZ8zy8Uiq3u/P7Az7UpbRCiJIYsvWGgLp8vltdV JQRsGPppYLyMTeni9X7hLAa2yd+H2Wa95D+fNaibpnvVOTHn3WFEmLMtH/9YW+V8By5dYw 71mMUTEFandwdg6kQDJ+m/Wjm3KGDTA= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.54]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4SPG1X25YHz1P7x5; Mon, 6 Nov 2023 23:46:56 +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; Mon, 6 Nov 2023 23:50:02 +0800 From: Kefeng Wang To: Andrew Morton CC: , , Matthew Wilcox , David Hildenbrand , , Kefeng Wang Subject: [PATCH 09/10] mm: convert mm_counter() to take a folio Date: Mon, 6 Nov 2023 23:49:49 +0800 Message-ID: <20231106154950.3399469-10-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> References: <20231106154950.3399469-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 2BFB82001C X-Rspam-User: X-Stat-Signature: b71mbopuh7sawiwf6mgd17d74ts4ff85 X-Rspamd-Server: rspam01 X-HE-Tag: 1699286870-613555 X-HE-Meta: U2FsdGVkX186wiBuoNJEbuEqlF9gGjeYHYzTqrakf2mIK4Bxvwypcp5KtR1KKUdnNAB1Dr1RnZFbETF6OjZq30Pxx39IvR2r0L7EtZXbU3JSyvoKdeFhHWds32iLZwqRKZLmOAK9A2IlNGNjChnhlECfydn0JqpmifoctrWwLilxOHD6CF0DiodIU4UI4T80o/J1Cfs8gFXEgoRaSUY707vkY1vhFF/KcRfUtjNdcbNUWdyIJQHSew2cFKMH211YbSjoj3H2vcxY7Mg+hMlRTfrSYLKQ78wkeNSl9vCijGb+YXdu6wge8tJtakFu+dlywsYoHhNI2qd+QMBZuXW9prkYqOV5Gmwib8qSdibI5qtnNm1NZEaVgGXNIfXyie7ZhbIxkT6Yo15IOC4oakJr8v8QH152YgjYLBDm7h7/E61Y7omB5yRSzw/QszGGL4WrJWfSN6/Zd/S6XUeFDF+XlKDpJV4q7crOsXcKbJ5vvs5LBMmzjo+CJ0lHdPuRRFLLfRQV919fmxMjvynwwME05doSDY32buL4rrMeaDOCoPyqTLMdKE0wT3CA0nIhe3kmQUDQSF3XkWkU5kSkaPaiQnvfb6pG/EQeVwk1tczQDk37HS5bJ8oIKDLZwlKIfyV/n2roUc0IblJMvcHC5l2PwwtHcYz6FTi/pljoxwzMvnBNCUUdvVlHOPMfq3J9ZltwDKzmyu1JeQ1fUdcq3CcwMIM8lWxZRaNDzWhSy2vMHwpl4w8JcPrzZp47F0A0KS3ES4ul6xPgwmtIhKyPKDreKY7pCDiHpKPuArG2zyuxZGOpgeOEa50GZ2VB57DRCI4Q8+LvBbbIGDWEmhOo5GMiY4QvASSu8UWzEC8TleXVJjpiNab6vm9ecYrVV3q+YiRlcdKvPT9o2Fp4YFAhHwShie6MHKr5ysc4gTWG5AMmYY0U5pTMmTvbnR9Hkc1PL4CZe77tPj1pI8brL7MyrFn p3rn0FEm jFXGxUPGmxOHfYwxeHYrK6QmGn6HItIgZVb7E+SHop6mvj2Pb5Q5cx3J/1frXTdrEyeezML4IV1BZSBvzTnIQx0DDgOCA0yQUnYkGlbUDnYtHrVTJ/TC4zut9r2+DtzquJAUKOQCG64g91iPZNszNXNmqPLrrLNN/NOcR8KismMA2Y51hM8o3BVsAgY0MREpCEsc9 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 dd3760988e02..3ffef84dd7bb 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)) { @@ -835,7 +835,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. */ BUG_ON(page_try_dup_anon_rmap(page, false, src_vma)); @@ -1466,7 +1466,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)) @@ -1496,7 +1496,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)) page_remove_rmap(page, vma, false); folio_put(folio); @@ -1511,7 +1511,7 @@ static unsigned long zap_pte_range(struct mmu_gather *tlb, folio = pfn_swap_entry_to_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 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);