Fix for "kmem -s|-S" on Linux 5.17+ with CONFIG_SLAB

Since the following kernel commits split slab info from struct page
into struct slab, crash cannot get several slab related offsets from
struct page.

  d122019bf061 ("mm: Split slab into its own type")
  401fb12c68c2 ("mm: Differentiate struct slab fields by sl*b implementations")
  07f910f9b729 ("mm: Remove slab from struct page")

Without the patch, "kmem -s|-S" options cannot work correctly on kernels
configured with CONFIG_SLAB with the following error:

  crash> kmem -s
  kmem: invalid structure member offset: page_active
        FILE: memory.c  LINE: 12225  FUNCTION: verify_slab_overload_page()

Resolves: https://github.com/crash-utility/crash/issues/115
Signed-off-by: xiaer1921 <xiaer1921@gmail.com>
Signed-off-by: Kazuhito Hagio <k-hagio-ab@nec.com>
This commit is contained in:
xiaer1921 2022-04-07 15:05:17 +08:00 committed by Lianbo Jiang
parent 8d49ad6662
commit b89f9ccf51
1 changed files with 9 additions and 0 deletions

View File

@ -541,6 +541,15 @@ vm_init(void)
ANON_MEMBER_OFFSET_INIT(page_s_mem, "page", "s_mem");
ANON_MEMBER_OFFSET_INIT(page_freelist, "page", "freelist");
ANON_MEMBER_OFFSET_INIT(page_active, "page", "active");
/*
* Moved to struct slab in Linux 5.17
*/
if (INVALID_MEMBER(page_s_mem))
MEMBER_OFFSET_INIT(page_s_mem, "slab", "s_mem");
if (INVALID_MEMBER(page_freelist))
MEMBER_OFFSET_INIT(page_freelist, "slab", "freelist");
if (INVALID_MEMBER(page_active))
MEMBER_OFFSET_INIT(page_active, "slab", "active");
}
if (!VALID_STRUCT(kmem_slab_s) && VALID_STRUCT(slab_s)) {