]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
page_counter: reduce struct page_counter size
authorShakeel Butt <shakeel.butt@linux.dev>
Fri, 28 Feb 2025 07:58:08 +0000 (23:58 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 4 Mar 2025 05:50:51 +0000 (21:50 -0800)
The struct page_counter has explicit padding for better cache alignment.
The commit c6f53ed8f213a ("mm, memcg: cg2 memory{.swap,}.peak write
handlers") added a field to the struct page_counter and accidently
increased its size.  Let's move the failcnt field which is v1-only field
to the same cacheline of usage to reduce the size of struct page_counter.

Link: https://lkml.kernel.org/r/20250228075808.207484-4-shakeel.butt@linux.dev
Signed-off-by: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin (Cruise) <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
include/linux/page_counter.h

index e4bd8fd427bedf3f7e68c409cbfc2f0d7c01a4e3..d649b6bbbc871b8cdc48d13f425628987ee386cf 100644 (file)
@@ -9,10 +9,12 @@
 
 struct page_counter {
        /*
-        * Make sure 'usage' does not share cacheline with any other field. The
-        * memcg->memory.usage is a hot member of struct mem_cgroup.
+        * Make sure 'usage' does not share cacheline with any other field in
+        * v2. The memcg->memory.usage is a hot member of struct mem_cgroup.
         */
        atomic_long_t usage;
+       unsigned long failcnt; /* v1-only field */
+
        CACHELINE_PADDING(_pad1_);
 
        /* effective memory.min and memory.min usage tracking */
@@ -28,7 +30,6 @@ struct page_counter {
        unsigned long watermark;
        /* Latest cg2 reset watermark */
        unsigned long local_watermark;
-       unsigned long failcnt; /* v1-only field */
 
        /* Keep all the read most fields in a separete cacheline. */
        CACHELINE_PADDING(_pad2_);