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>,
"Mcgrof 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 v4 1/7] mm/memcg: use order instead of nr in split_page_memcg()
Date: Tue, 13 Feb 2024 16:55:14 -0500 [thread overview]
Message-ID: <20240213215520.1048625-2-zi.yan@sent.com> (raw)
In-Reply-To: <20240213215520.1048625-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>
---
include/linux/memcontrol.h | 4 ++--
mm/huge_memory.c | 3 ++-
mm/memcontrol.c | 3 ++-
mm/page_alloc.c | 4 ++--
4 files changed, 8 insertions(+), 6 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 016e20bd813e..0cd5fba0923c 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -2877,9 +2877,10 @@ static void __split_huge_page(struct page *page, struct list_head *list,
unsigned long offset = 0;
unsigned int nr = thp_nr_pages(head);
int i, nr_dropped = 0;
+ int order = folio_order(folio);
/* 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 93ad8640b741..404e529644c0 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 7ae4b74c9e5c..7c927b84e16c 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);
@@ -4838,7 +4838,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-13 21:55 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-13 21:55 [PATCH v4 0/7] Split a folio to any lower order folios Zi Yan
2024-02-13 21:55 ` Zi Yan [this message]
2024-02-14 9:12 ` [PATCH v4 1/7] mm/memcg: use order instead of nr in split_page_memcg() David Hildenbrand
2024-02-14 15:19 ` Zi Yan
2024-02-13 21:55 ` [PATCH v4 2/7] mm/page_owner: use order instead of nr in split_page_owner() Zi Yan
2024-02-14 9:14 ` David Hildenbrand
2024-02-14 15:21 ` Zi Yan
2024-02-13 21:55 ` [PATCH v4 3/7] mm: memcg: make memcg huge page split support any order split Zi Yan
2024-02-14 9:19 ` David Hildenbrand
2024-02-13 21:55 ` [PATCH v4 4/7] mm: page_owner: add support for splitting to any order in split page_owner Zi Yan
2024-02-14 9:34 ` David Hildenbrand
2024-02-14 15:29 ` Zi Yan
2024-02-13 21:55 ` [PATCH v4 5/7] mm: thp: split huge page to any lower order pages (except order-1) Zi Yan
2024-02-13 22:05 ` Luis Chamberlain
2024-02-13 22:14 ` David Hildenbrand
2024-02-13 22:15 ` Zi Yan
2024-02-13 22:19 ` Zi Yan
2024-02-14 2:56 ` Zi Yan
2024-02-14 10:38 ` Ryan Roberts
2024-02-14 16:11 ` Zi Yan
2024-02-14 16:22 ` Ryan Roberts
2024-02-14 16:28 ` Zi Yan
2024-02-14 16:41 ` Ryan Roberts
2024-02-13 21:55 ` [PATCH v4 6/7] mm: truncate: split huge page cache page to a non-zero order if possible Zi Yan
2024-02-14 10:43 ` Ryan Roberts
2024-02-14 16:19 ` Zi Yan
2024-02-14 16:25 ` Ryan Roberts
2024-02-13 21:55 ` [PATCH v4 7/7] mm: huge_memory: enable debugfs to split huge pages to any order Zi Yan
2024-02-13 22:21 ` [PATCH v4 0/7] Split a folio to any lower order folios David Hildenbrand
2024-02-13 22:31 ` Zi Yan
2024-02-14 10:50 ` Ryan Roberts
2024-02-14 10:55 ` David Hildenbrand
2024-02-14 16:35 ` Zi Yan
2024-02-14 17:18 ` Zi Yan
2024-02-14 17:38 ` Pankaj Raghav (Samsung)
2024-02-16 10:06 ` Pankaj Raghav (Samsung)
2024-02-16 15:51 ` 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=20240213215520.1048625-2-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