From patchwork Tue Oct 10 06:45:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 13414850 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 796C9CD68F6 for ; Tue, 10 Oct 2023 06:47:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 54FD36B01FA; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D8776B01F9; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 219706B01F6; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) 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 041A16B01F6 for ; Tue, 10 Oct 2023 02:47:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id C9EACB484B for ; Tue, 10 Oct 2023 06:47:13 +0000 (UTC) X-FDA: 81328619946.12.5BC8B3E Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by imf25.hostedemail.com (Postfix) with ESMTP id 4B95FA000A for ; Tue, 10 Oct 2023 06:47:10 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1696920432; 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=TnqqPukhplCsMkc/rctsfscvk/yq8sOOK7EULXK6MuA=; b=3M4IKpTPL9ZF1pgEonSsM/EvrVB/7NpqoQ3aujYwttWy/fIkoobNDnWcXCO2BPwcpYx+nL TvrFdKSrp97Ljkj8L2FZ1GmGhIsCUMM+I95yEUqzfodr4ePJ9lI5SZpyRx1Aa3b3Pb1Lhh pfiTOe36MViQ+NZiPnIyBnAllqNZZxI= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=none; dmarc=pass (policy=quarantine) header.from=huawei.com; spf=pass (imf25.hostedemail.com: domain of wangkefeng.wang@huawei.com designates 45.249.212.188 as permitted sender) smtp.mailfrom=wangkefeng.wang@huawei.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1696920432; a=rsa-sha256; cv=none; b=IgQGUXAKaYjJmwiOtCqnVL+uX8p86mOD/74IayQtlOlCv+DrvvFjQjfK3zghQ4NbUsA1cJ SOHqFcPfS8rvdhp0KGbcvG4eyE4LrYFYPEhgwf127bOu8zU/Y0DJqV91mtjneKkrLkRSui XZsDSlodQPrfnCP1ijG2INYvmAkk9y4= Received: from dggpemm100001.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4S4RDc5vqYzNnqm; Tue, 10 Oct 2023 14:43:12 +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; Tue, 10 Oct 2023 14:47:08 +0800 From: Kefeng Wang To: Andrew Morton CC: , , , , , Zi Yan , Kefeng Wang Subject: [PATCH -next 7/7] mm: convert page_cpupid_xchg_last() to folio_cpupid_xchg_last() Date: Tue, 10 Oct 2023 14:45:44 +0800 Message-ID: <20231010064544.4162286-8-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> References: <20231010064544.4162286-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.112.125] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm100001.china.huawei.com (7.185.36.93) X-CFilter-Loop: Reflected X-Rspamd-Queue-Id: 4B95FA000A X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: xngxnq1saoyr6q315yaaswycyf1er846 X-HE-Tag: 1696920430-332580 X-HE-Meta: U2FsdGVkX18YgqAt1OjWoJt/OIJtcsS+Hqzr2jNMvqGyLK+k7v/3DS8lJDC5ofMuLPHC5Zpa/0TiURNV9n3/iuq9GQIHtAbi35LTZxVC1OUUyIKHdOrFVt9T3ElifwReopMY1vptcqH4t8T3mpSeSpG1PQSQ22UarOXDhpGwbWxZxs7EMv+adMMVZF0hLhIIUIE0KMY140N14LDUBQ4I7X/6fG9x9RkFEekJFAKuw57kxSSJaQZ6dMjfmgz86kHXK0/iGHBWjuiZcLnOZq36iwseqzQT48M+4QYmYxyfrJczlHhz7JJlrMWXmRMWuOIGH7vWGNQrk+rcz2ncNKFyGqTDxH9uJwxNcKnhsfUoxTNBNjL2iLyCvuB481j/7pf0jIOSM0HInClThRy1VIJiUenf1MuQ7hRoZniPh2MDBA+JBqU2MijlnKrAQ01BB4iTfxH8XKBfQcBxJBa/Kx7FuIRIp+iUm9QrgXGb8rU6NdNH2QKiV5Tvx8p8DlxSrIuqZGJgUFSDxeJuiUpItIygQw+azK2Sn4DrxSHr6reqeFKj0gLwDKyzsUM5C34G8YQjEoAfL3nwFV3UeZFgkiowSN8h+QTxgS+DjZ3XgmHThcOuwNBd1drWbyG2fPaYHV0xkOuPHqw/ellF4yqNomdvJ8UA8nhPC/sGz9EvSahLIjlzYe1kAYsuxw/MZmIvA+bZISPvlvstXDXIjm5WavlfDrkrcSzAFK4H5VMQAwNc0o4+D5ps9MxkaU4QckZ1hftGUr4zWT3PRro1xjN1PdCuocRCQNxXfaZ37yNo7ive3nkEragEwpVkEBZFt50w3atMoaCc3trC9ON/g/9otFEJTzHw3hJttl+BMwCM2RT4cwovAUvgcQUy09WJV+MA7wASFnnmF+tj02JTDAKioEEWKWC2kc1CYnyqzpJPkzXxQl8pXcwHVAVbppxvfX25oEHVLNt29atI+GjmIRHdKuS pXlIQn/S OykWfCFPUylbhsXeHE/Kq9VQaTZY/AAqPKkBa1onQRukQ/lAlaNGwPobSRUkqelOqz6QbGAeh18zU1yEAwkysJc9MWWJGCiuZo/RNGKcPJ+y4i8ZKrdEzjDYyW0O+PRapxo/G6UW92GpaoeqHcT0F6CjOj9MwTIaIZZ+5t2EJKN3km40BD7RHxtpLU9BHnCTbwm9q 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: Make page_cpupid_xchg_last() to take a folio, and rename it to olio_cpupid_xchg_last() since all callers with a folio. Signed-off-by: Kefeng Wang --- include/linux/mm.h | 14 +++++++------- kernel/sched/fair.c | 2 +- mm/huge_memory.c | 2 +- mm/memory.c | 2 +- mm/migrate.c | 4 ++-- mm/mmzone.c | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 3d59455626fa..e761642e1c00 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -1683,9 +1683,9 @@ static inline bool __cpupid_match_pid(pid_t task_pid, int cpupid) #define cpupid_match_pid(task, cpupid) __cpupid_match_pid(task->pid, cpupid) #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS -static inline int page_cpupid_xchg_last(struct page *page, int cpupid) +static inline int folio_cpupid_xchg_last(struct folio *folio, int cpupid) { - return xchg(&page->_last_cpupid, cpupid & LAST_CPUPID_MASK); + return xchg(&folio->_last_cpupid, cpupid & LAST_CPUPID_MASK); } static inline int folio_cpupid_last(struct folio *folio) @@ -1702,7 +1702,7 @@ static inline int folio_cpupid_last(struct folio *folio) return (folio->flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK; } -extern int page_cpupid_xchg_last(struct page *page, int cpupid); +extern int folio_cpupid_xchg_last(struct folio *folio, int cpupid); static inline void page_cpupid_reset_last(struct page *page) { @@ -1714,8 +1714,8 @@ static inline int xchg_folio_access_time(struct folio *folio, int time) { int last_time; - last_time = page_cpupid_xchg_last(&folio->page, - time >> PAGE_ACCESS_TIME_BUCKETS); + last_time = folio_cpupid_xchg_last(folio, + time >> PAGE_ACCESS_TIME_BUCKETS); return last_time << PAGE_ACCESS_TIME_BUCKETS; } @@ -1729,9 +1729,9 @@ static inline void vma_set_access_pid_bit(struct vm_area_struct *vma) } } #else /* !CONFIG_NUMA_BALANCING */ -static inline int page_cpupid_xchg_last(struct page *page, int cpupid) +static inline int folio_cpupid_xchg_last(struct folio *folio, int cpupid) { - return page_to_nid(page); /* XXX */ + return folio_nid(folio); /* XXX */ } static inline int xchg_folio_access_time(struct folio *folio, int time) diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 50b9f63099fb..5d4c7cedc6d1 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -1818,7 +1818,7 @@ bool should_numa_migrate_memory(struct task_struct *p, struct folio *folio, } this_cpupid = cpu_pid_to_cpupid(dst_cpu, current->pid); - last_cpupid = page_cpupid_xchg_last(&folio->page, this_cpupid); + last_cpupid = folio_cpupid_xchg_last(folio, this_cpupid); if (!(sysctl_numa_balancing_mode & NUMA_BALANCING_MEMORY_TIERING) && !node_is_toptier(src_nid) && !cpupid_valid(last_cpupid)) diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 3b37367eaeff..2163b1d0dad5 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -2515,7 +2515,7 @@ static void __split_huge_page_tail(struct folio *folio, int tail, if (page_is_idle(head)) set_page_idle(page_tail); - page_cpupid_xchg_last(page_tail, folio_cpupid_last(folio)); + folio_cpupid_xchg_last(new_folio, folio_cpupid_last(folio)); /* * always add to the tail because some iterators expect new diff --git a/mm/memory.c b/mm/memory.c index 1a1a6a6ccd58..9f3b359b46db 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -3034,7 +3034,7 @@ static inline void wp_page_reuse(struct vm_fault *vmf, struct folio *folio) * information potentially belongs to a now completely * unrelated process. */ - page_cpupid_xchg_last(vmf->page, (1 << LAST_CPUPID_SHIFT) - 1); + folio_cpupid_xchg_last(folio, (1 << LAST_CPUPID_SHIFT) - 1); } flush_cache_page(vma, vmf->address, pte_pfn(vmf->orig_pte)); diff --git a/mm/migrate.c b/mm/migrate.c index c602bf6dec97..5642e9572d80 100644 --- a/mm/migrate.c +++ b/mm/migrate.c @@ -588,7 +588,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) * Copy NUMA information to the new page, to prevent over-eager * future migrations of this same page. */ - cpupid = page_cpupid_xchg_last(&folio->page, -1); + cpupid = folio_cpupid_xchg_last(folio, -1); /* * For memory tiering mode, when migrate between slow and fast * memory node, reset cpupid, because that is used to record @@ -601,7 +601,7 @@ void folio_migrate_flags(struct folio *newfolio, struct folio *folio) if (f_toptier != t_toptier) cpupid = -1; } - page_cpupid_xchg_last(&newfolio->page, cpupid); + folio_cpupid_xchg_last(newfolio, cpupid); folio_migrate_ksm(newfolio, folio); /* diff --git a/mm/mmzone.c b/mm/mmzone.c index 68e1511be12d..cd473f82b647 100644 --- a/mm/mmzone.c +++ b/mm/mmzone.c @@ -93,19 +93,19 @@ void lruvec_init(struct lruvec *lruvec) } #if defined(CONFIG_NUMA_BALANCING) && !defined(LAST_CPUPID_NOT_IN_PAGE_FLAGS) -int page_cpupid_xchg_last(struct page *page, int cpupid) +int folio_cpupid_xchg_last(struct folio *folio, int cpupid) { unsigned long old_flags, flags; int last_cpupid; - old_flags = READ_ONCE(page->flags); + old_flags = READ_ONCE(folio->flags); do { flags = old_flags; last_cpupid = (flags >> LAST_CPUPID_PGSHIFT) & LAST_CPUPID_MASK; flags &= ~(LAST_CPUPID_MASK << LAST_CPUPID_PGSHIFT); flags |= (cpupid & LAST_CPUPID_MASK) << LAST_CPUPID_PGSHIFT; - } while (unlikely(!try_cmpxchg(&page->flags, &old_flags, flags))); + } while (unlikely(!try_cmpxchg(&folio->flags, &old_flags, flags))); return last_cpupid; }