Skip to content

Commit f7b0797

Browse files
shakeelbakpm00
authored andcommitted
page_counter: reduce struct page_counter size
The struct page_counter has explicit padding for better cache alignment. The commit c6f53ed ("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>
1 parent 0e2759a commit f7b0797

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/linux/page_counter.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@
99

1010
struct page_counter {
1111
/*
12-
* Make sure 'usage' does not share cacheline with any other field. The
13-
* memcg->memory.usage is a hot member of struct mem_cgroup.
12+
* Make sure 'usage' does not share cacheline with any other field in
13+
* v2. The memcg->memory.usage is a hot member of struct mem_cgroup.
1414
*/
1515
atomic_long_t usage;
16+
unsigned long failcnt; /* v1-only field */
17+
1618
CACHELINE_PADDING(_pad1_);
1719

1820
/* effective memory.min and memory.min usage tracking */
@@ -28,7 +30,6 @@ struct page_counter {
2830
unsigned long watermark;
2931
/* Latest cg2 reset watermark */
3032
unsigned long local_watermark;
31-
unsigned long failcnt; /* v1-only field */
3233

3334
/* Keep all the read most fields in a separete cacheline. */
3435
CACHELINE_PADDING(_pad2_);

0 commit comments

Comments
 (0)