page_owner

简介

Documentation/mm/page_owner.rst

  1. build Linux Kernel

CONFIG_PAGE_OWNER

page owner is disabled by default.

  1. enable

add page_owner=on to boot cmdline.

  1. do the job that you want to debug.

  2. the tracking about who allocated each page.

$ cat /sys/kernel/debug/page_owner
  1. (options) build user-space helper

$ cd tools/mm
$ make page_owner_sort

$ cat /sys/kernel/debug/page_owner > page_owner_full.txt
$ ./page_owner_sort page_owner_full.txt sorted_page_owner.txt

参数解析

[OPTIONS]:

  • -a 根据分配页的时间进行排序

  • -m 根据分配页的总大小进行排序

  • -n 根据进程名字进行排序

  • -p 根据PID的大小进行排序

  • -P 根据TGID的大小进行排序

  • -s 根据分配栈进行排序

  • -t 默认根据分配页的次数进行排序

  • --cull <rules> 指定打印的成员(pid, tgid, comm, stacktrace, allocator) , 如:--cull pid,name,只打印进程 pid 以及名字

例子

以下是 page_owner_sort 默认的解析结果,可以看到每个分配的页信息, 包括次数、页数、进程信息、栈信息等。

  • 3 times : 分配的次数等于 3

  • 6 pages : 分配的页数等于 6

  • allocated by SLAB: 由 SLAB 分配器分配

  • order 1 : 分配的页 order 等于 1

  • mask 0x52810 : 分配的页掩码 gfp_mask

  • pid 78, tgid 78 (systemd-journal): 进程 pid 等于 78、tgid 等于 78、进程名字为 systemd-journal

以下是 page_owner_sort -m --cull pid,name 的解析结果,根据分配页的总大小进行 排序,并且只打印进程 pid 以及名字。

  • 3366 times: 分配的次数等于 3366

  • 3369 pages: 分配的页数等于 3369

  • PID 170 : 进程 pid 等于 170

  • task_comm_name cat: 进程名字为 cat

Last updated

Was this helpful?