]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm: page_frag: reuse existing space for 'size' and 'pfmemalloc'
authorYunsheng Lin <linyunsheng@huawei.com>
Mon, 28 Oct 2024 11:53:41 +0000 (19:53 +0800)
committerJakub Kicinski <kuba@kernel.org>
Mon, 11 Nov 2024 18:56:27 +0000 (10:56 -0800)
commit0c3ce2f50261cd2f654d931eeb933c370a3a7d7a
tree725171e0fde46cb1426a36efd7355e9426132bb7
parent49e302be73f1b8de45765f3f66878f3b6c659b01
mm: page_frag: reuse existing space for 'size' and 'pfmemalloc'

Currently there is one 'struct page_frag' for every 'struct
sock' and 'struct task_struct', we are about to replace the
'struct page_frag' with 'struct page_frag_cache' for them.
Before begin the replacing, we need to ensure the size of
'struct page_frag_cache' is not bigger than the size of
'struct page_frag', as there may be tens of thousands of
'struct sock' and 'struct task_struct' instances in the
system.

By or'ing the page order & pfmemalloc with lower bits of
'va' instead of using 'u16' or 'u32' for page size and 'u8'
for pfmemalloc, we are able to avoid 3 or 5 bytes space waste.
And page address & pfmemalloc & order is unchanged for the
same page in the same 'page_frag_cache' instance, it makes
sense to fit them together.

After this patch, the size of 'struct page_frag_cache' should be
the same as the size of 'struct page_frag'.

CC: Andrew Morton <akpm@linux-foundation.org>
CC: Linux-MM <linux-mm@kvack.org>
Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>
Link: https://patch.msgid.link/20241028115343.3405838-7-linyunsheng@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/mm_types_task.h
include/linux/page_frag_cache.h
mm/page_frag_cache.c