Skip to content

buddy-dump: handle CONFIG_TRANSPARENT_HUGEPAGE #143

@xairy

Description

@xairy

When I run buddy-dump -o 4 -z Normal -n while debugging a kernel that has CONFIG_TRANSPARENT_HUGEPAGE enabled, I see the following output:

gef> buddy-dump -o 4 -z Normal -n
[+] Wait for memory scan
[+] Parse OK, making output...
---------------------------------------------------------------------------------------------------------------- node[0] @ 0xffffffc00a21a780 ----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------- zone[1] @ 0xffffffc00a21adc0 (Normal) -----------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------- per_cpu_pageset ----------------------------------------------------------------------------------------------------------------------
cpu: 0                                                                                                                                                                                                                                                       
cpu: 1
cpu: 2
cpu: 3
cpu: 4
  pcp_index: 12, order: 4 (0x010000 bytes), mtype: 0 (=Unmovable)
    page:0xfffffffe00600400  size:0x010000  virt:0xffffff8018010000-0xffffff8018020000  phys:0x0000000098010000-0x0000000098020000 (pcp, cpu=4)
    page:0xfffffffe005ffa00  size:0x010000  virt:0xffffff8017fe8000-0xffffff8017ff8000  phys:0x0000000097fe8000-0x0000000097ff8000 (pcp, cpu=4)
    page:0xfffffffe00249600  size:0x010000  virt:0xffffff8009258000-0xffffff8009268000  phys:0x0000000089258000-0x0000000089268000 (pcp, cpu=4)
...

What looks wrong here are PCP entries for order 4: PCP should only cover orders from 0 to 3.

I suspect this is just an issue with the output caused by gef forcing MIGRATE_PCPTYPES = 3 in dump_pcp_entry. When CONFIG_TRANSPARENT_HUGEPAGE is enabled, MIGRATE_PCPTYPES in the kernel is actually 4, and thus, gef miscalculates the page order based on PCP list index.

A simple fix of changing MIGRATE_PCPTYPES to be 4 solves the output issue. This might be a reasonable hot-fix.

However, possibly, the right fix would be to display Transparent HugePage PCP entries differently than normal PCP entries: I suspect at least their order should be calculated differently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions