Re:Re: [PATCH] mm/percpu-internal.h: optimise pcpu_chunk_struct to save memory

dd
2026-03-27T07:08:33Z

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

Hi:
You may refer to the pahole test results before and after the modification. The offsets of other members remain unchanged. Originally, nr_empty_pop_pageswas placed alone at the beginning of the third cache line.
After the modification, it has been moved to the end of the second cache line.

Thanks.
At 2026-03-27 13:16:41, "Andrew Morton" <akpm@linux-foundation.org> wrote:
>On Thu, 5 Mar 2026 15:30:43 +0800 zenghongling <zenghongling@kylinos.cn> wrote:
>
>> Subject: [PATCH] mm/percpu-internal.h: optimise pcpu_chunk_struct to save memory
>
>There is no pcpu_chunk_struct, I'll change this to "struct pcpu_chunk".
>
>> Date: Thu, 5 Mar 2026 15:30:43 +0800
>> Sender: owner-linux-mm@kvack.org
>> X-Mailer: git-send-email 2.25.1
>>
>> The pcpu_chunk_struct has a hole of 4 bytes and pushes the struct to three
>> cachelines. Relocating the three booleans upwards allows for the struct
>> to only use two cachelines.
>
>before:
>
>(gdb) p sizeof(struct pcpu_chunk)
>$2 = 256
>
>after:
>
>(gdb) p sizeof(struct pcpu_chunk)
>$1 = 192
>
>That's remarkable. It was an allmodconfig build which tends to add
>bloat, but the only source-level alteration was this patch.
>
>
>Another consideration here is that moving members around can have a
>performance impact - it can cause more (or less) cacheline
>invalidations. I worry that because someone has carefully commented
>all the member offsets, this might have been a consideration.
>
>Also I think your patch may have made those comments incorrect?
>
>
>Dennis, Tejun, Christoph: I think we want this space saving. Can
>you please advise?
>
>Thanks.

[-- Attachment #2: Type: text/html, Size: 2153 bytes --]