Re: [PATCH net-next v22 06/14] mm: page_frag: reuse existing space for 'size' and 'pfmemalloc'
From: Alexander Duyck <hidden>
Date: 2024-10-18 16:44:18
Also in:
linux-mm, lkml
From: Alexander Duyck <hidden>
Date: 2024-10-18 16:44:18
Also in:
linux-mm, lkml
On Fri, Oct 18, 2024 at 4:00 AM Yunsheng Lin [off-list ref] wrote:
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: Alexander Duyck <redacted> Signed-off-by: Yunsheng Lin <redacted> --- include/linux/mm_types_task.h | 19 +++++---- include/linux/page_frag_cache.h | 24 ++++++++++- mm/page_frag_cache.c | 70 ++++++++++++++++++++++----------- 3 files changed, 81 insertions(+), 32 deletions(-)
LGTM Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>