From: Zi Yan <zi.yan@sent.com>
To: "Pankaj Raghav (Samsung)" <kernel@pankajraghav.com>, linux-mm@kvack.org
Cc: "Zi Yan" <ziy@nvidia.com>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
"David Hildenbrand" <david@redhat.com>,
"Yang Shi" <shy828301@gmail.com>, "Yu Zhao" <yuzhao@google.com>,
"Kirill A . Shutemov" <kirill.shutemov@linux.intel.com>,
"Ryan Roberts" <ryan.roberts@arm.com>,
"Michal Koutný" <mkoutny@suse.com>,
"Roman Gushchin" <roman.gushchin@linux.dev>,
"Zach O'Keefe" <zokeefe@google.com>,
"Hugh Dickins" <hughd@google.com>,
"Luis Chamberlain" <mcgrof@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org,
linux-fsdevel@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: [PATCH v5 3/8] mm/memcg: use order instead of nr in split_page_memcg()
Date: Mon, 26 Feb 2024 15:55:29 -0500 [thread overview]
Message-ID: <20240226205534.1603748-4-zi.yan@sent.com> (raw)
In-Reply-To: <20240226205534.1603748-1-zi.yan@sent.com>
From: Zi Yan <ziy@nvidia.com>
We do not have non power of two pages, using nr is error prone if nr
is not power-of-two. Use page order instead.
Signed-off-by: Zi Yan <ziy@nvidia.com>
Acked-by: David Hildenbrand <david@redhat.com>
---
include/linux/memcontrol.h | 4 ++--
mm/huge_memory.c | 5 +++--
mm/memcontrol.c | 3 ++-
mm/page_alloc.c | 4 ++--
4 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h
index 4e4caeaea404..173bbb53c1ec 100644
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -1163,7 +1163,7 @@ static inline void memcg_memory_event_mm(struct mm_struct *mm,
rcu_read_unlock();
}
-void split_page_memcg(struct page *head, unsigned int nr);
+void split_page_memcg(struct page *head, int order);
unsigned long mem_cgroup_soft_limit_reclaim(pg_data_t *pgdat, int order,
gfp_t gfp_mask,
@@ -1621,7 +1621,7 @@ void count_memcg_event_mm(struct mm_struct *mm, enum vm_event_item idx)
{
}
-static inline void split_page_memcg(struct page *head, unsigned int nr)
+static inline void split_page_memcg(struct page *head, int order)
{
}
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 9840f312c08f..96ac7c62c375 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2889,11 +2889,12 @@ static void __split_huge_page(struct page *page, struct list_head *list,
struct lruvec *lruvec;
struct address_space *swap_cache = NULL;
unsigned long offset = 0;
- unsigned int nr = thp_nr_pages(head);
int i, nr_dropped = 0;
+ int order = folio_order(folio);
+ unsigned int nr = 1 << order;
/* complete memcg works before add pages to LRU */
- split_page_memcg(head, nr);
+ split_page_memcg(head, order);
if (folio_test_anon(folio) && folio_test_swapcache(folio)) {
offset = swp_offset(folio->swap);
diff --git a/mm/memcontrol.c b/mm/memcontrol.c
index 95c3fccb321b..1a09f0e77c44 100644
--- a/mm/memcontrol.c
+++ b/mm/memcontrol.c
@@ -3608,11 +3608,12 @@ void obj_cgroup_uncharge(struct obj_cgroup *objcg, size_t size)
/*
* Because page_memcg(head) is not set on tails, set it now.
*/
-void split_page_memcg(struct page *head, unsigned int nr)
+void split_page_memcg(struct page *head, int order)
{
struct folio *folio = page_folio(head);
struct mem_cgroup *memcg = folio_memcg(folio);
int i;
+ unsigned int nr = 1 << order;
if (mem_cgroup_disabled() || !memcg)
return;
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 96839b210abe..a7a96bc97e0b 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2653,7 +2653,7 @@ void split_page(struct page *page, unsigned int order)
for (i = 1; i < (1 << order); i++)
set_page_refcounted(page + i);
split_page_owner(page, 1 << order);
- split_page_memcg(page, 1 << order);
+ split_page_memcg(page, order);
}
EXPORT_SYMBOL_GPL(split_page);
@@ -4840,7 +4840,7 @@ static void *make_alloc_exact(unsigned long addr, unsigned int order,
struct page *last = page + nr;
split_page_owner(page, 1 << order);
- split_page_memcg(page, 1 << order);
+ split_page_memcg(page, order);
while (page < --last)
set_page_refcounted(last);
--
2.43.0
next prev parent reply other threads:[~2024-02-26 20:56 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-26 20:55 [PATCH v5 0/8] Split a folio to any lower order folios Zi Yan
2024-02-26 20:55 ` [PATCH v5 1/8] mm/huge_memory: only split PMD mapping when necessary in unmap_folio() Zi Yan
2024-02-28 10:30 ` David Hildenbrand
2024-02-26 20:55 ` [PATCH v5 2/8] mm: Support order-1 folios in the page cache Zi Yan
2024-02-26 20:55 ` Zi Yan [this message]
2024-02-26 20:55 ` [PATCH v5 4/8] mm/page_owner: use order instead of nr in split_page_owner() Zi Yan
2024-02-26 20:55 ` [PATCH v5 5/8] mm: memcg: make memcg huge page split support any order split Zi Yan
2024-02-26 20:55 ` [PATCH v5 6/8] mm: page_owner: add support for splitting to any order in split page_owner Zi Yan
2024-02-28 10:31 ` David Hildenbrand
2024-02-26 20:55 ` [PATCH v5 7/8] mm: thp: split huge page to any lower order pages Zi Yan
2024-02-28 8:23 ` Ryan Roberts
2024-02-28 15:42 ` Zi Yan
2024-02-28 15:44 ` Ryan Roberts
2024-02-28 15:52 ` Zi Yan
2024-03-07 14:58 ` Zi Yan
2024-02-26 20:55 ` [PATCH v5 8/8] mm: huge_memory: enable debugfs to split huge pages to any order Zi Yan
2024-03-01 9:51 ` Aishwarya TCV
2024-03-01 10:33 ` Ryan Roberts
2024-03-01 12:11 ` Mark Brown
2024-03-01 12:56 ` Zi Yan
2024-03-01 14:14 ` Mark Brown
2024-03-01 12:52 ` Zi Yan
2024-03-01 13:09 ` Ryan Roberts
2024-03-01 13:53 ` Zi Yan
2024-03-01 14:18 ` Ryan Roberts
2024-03-01 14:27 ` Mark Brown
2024-03-01 15:21 ` Zi Yan
2024-03-01 19:41 ` Zi Yan
2024-03-01 14:24 ` Mark Brown
2024-03-01 14:00 ` Zi Yan
2024-03-01 14:23 ` Ryan Roberts
2024-03-01 14:33 ` Zi Yan
2024-03-01 19:37 ` Zi Yan
2024-03-01 20:02 ` Zi Yan
2024-03-01 21:10 ` Zi Yan
2024-03-04 9:50 ` Aishwarya TCV
2024-03-04 14:58 ` Zi Yan
2024-03-04 15:44 ` Aishwarya TCV
2024-03-04 15:57 ` Zi Yan
2024-03-04 18:25 ` Aishwarya TCV
2024-03-04 18:26 ` Zi Yan
2024-03-04 18:31 ` Zi Yan
2024-03-07 15:06 ` Zi Yan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240226205534.1603748-4-zi.yan@sent.com \
--to=zi.yan@sent.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=kernel@pankajraghav.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mcgrof@kernel.org \
--cc=mkoutny@suse.com \
--cc=roman.gushchin@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=shy828301@gmail.com \
--cc=willy@infradead.org \
--cc=yuzhao@google.com \
--cc=ziy@nvidia.com \
--cc=zokeefe@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).