Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libdrgn: add /usr/lib/debug/boot in the vmlinux_paths #1

Closed
wants to merge 1 commit into from

Conversation

sdimitro
Copy link
Contributor

@sdimitro sdimitro commented May 17, 2019

Ubuntu-based distros tend to put vmlinux with debug info
under /usr/lib/debug/boot/vmlinux-<version>.

Side-notes:
Took the liberty of re-ordering the paths to alphabetical order.

Ubuntu-based distros tend to put vmlinux with debug info
under /usr/lib/debug/boot/vmlinux-<version>.
@@ -487,9 +487,10 @@ static struct drgn_error *find_elf_symbol(Elf *elf, Elf_Scn *symtab_scn,
}

static const char * const vmlinux_paths[] = {
"/usr/lib/debug/lib/modules/%s/vmlinux",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think my reasoning with the order was that the files under /usr/lib/debug always have debug information, but maybe in /boot or /lib/modules they don't, so it'd be best to check /usr/lib/debug first. Could you keep the order and maybe add a comment like "Check /usr/lib/debug first, since those will always have debug information."

osandov added a commit that referenced this pull request May 28, 2019
libdrgn: add /usr/lib/debug/boot in the vmlinux_paths
@osandov
Copy link
Owner

osandov commented May 28, 2019

I have a conflicting change in the works, so I went ahead and merged this with the added comment. Thanks!

@osandov osandov closed this May 28, 2019
marxin added a commit to marxin/drgn that referenced this pull request Jan 27, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          osandov#1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64

Signed-off-by: Martin Liska <[email protected]>
marxin added a commit to marxin/drgn that referenced this pull request Jan 28, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          osandov#1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64

Signed-off-by: Martin Liska <[email protected]>
marxin added a commit to marxin/drgn that referenced this pull request Jan 30, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          osandov#1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <[email protected]>
marxin added a commit to marxin/drgn that referenced this pull request Jan 31, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          osandov#1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <[email protected]>
marxin added a commit to marxin/drgn that referenced this pull request Feb 8, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          osandov#1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <[email protected]>
marxin added a commit to marxin/drgn that referenced this pull request Feb 8, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          osandov#1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <[email protected]>
marxin added a commit to marxin/drgn that referenced this pull request Feb 10, 2023
When I run qemu on my AMD zen with 32 cores (and 2 GB memory) I
sometimes hit:

kswapd0: page allocation failure: order:7, mode:0x40c40(GFP_NOFS|__GFP_COMP), nodemask=(null)
CPU: 22 PID: 183 Comm: kswapd0 Not tainted 5.16.20-vmtest18.1default osandov#1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.16.0-0-gd239552-rebuilt.opensuse.org 04/01/2014
Call Trace:
 <TASK>
 dump_stack_lvl+0x34/0x44
 warn_alloc+0xf3/0x171
 __alloc_pages_slowpath.constprop.0+0x7e3/0x813
 __alloc_pages+0x100/0x179
 new_slab+0xac/0x23d
 ___slab_alloc+0x436/0x527
 ? p9_fcall_init+0x27/0x66
 ? virtqueue_add+0x7d6/0x8fe
 ? virtqueue_add+0x845/0x8fe
 ? update_cfs_rq_load_avg+0x13d/0x14b
..

With the new test argument '-smp 4' it works fine for all flavors.

Signed-off-by: Martin Liska <[email protected]>
osandov pushed a commit that referenced this pull request Feb 24, 2023
This script mimics crash>sys and provides the following output:

CPUS             16
DATE             Fri Jan 27 20:26:24 2023
UPTIME           1 day, 7:29:37
LOAD AVERAGE     0.00, 0.00, 0.00
TASKS            317
NODENAME         tw
RELEASE          6.1.7-1-default
VERSION          #1 SMP PREEMPT_DYNAMIC Wed Jan 18 11:12:34 UTC 2023 (872045c)
MACHINE          x86_64
MEMORY           12.67 GiB

Signed-off-by: Martin Liska <[email protected]>
imran-kn added a commit to imran-kn/drgn-work that referenced this pull request Mar 18, 2024
These don't have tets cases so can't go under helpers.
I have put these under contrib so that they are available
for use.

  python3 -m drgn -s vmlinux -c vmcore contrib/locks.py --help

  usage: locks.py [-h] lock_type info_type [locks ...]

  positional arguments:
    lock_type   type of lock i.e mutex. semaphore, rwsemaphore etc.
    info_type   "owner" or "waiter" or "all"
    locks       list of lock addresses

  options:
    -h, --help  show this help message and exit

For example following command will give us call stack for owner
waiters of specified mutex(es):

  python3 -m drgn -s vmlinux -c vmcore contrib/locks.py mutex all ffffffffc0143400
  ..................
  Dumping call stack for waiter of mutex: ffffffffc0143400

  call stack for pid: 215
  #0  context_switch (kernel/sched/core.c:5238:2)
  osandov#1  __schedule (kernel/sched/core.c:6551:8)
  osandov#2  schedule (kernel/sched/core.c:6627:3)
  osandov#3  schedule_preempt_disabled (kernel/sched/core.c:6686:2)
  osandov#4  __mutex_lock_common (kernel/locking/mutex.c:679:3)
  osandov#5  __mutex_lock (kernel/locking/mutex.c:747:9)
  osandov#6  0xffffffffc01411f6
  ..................

  call stack for pid: 216
  #0  context_switch (kernel/sched/core.c:5238:2)
  osandov#1  __schedule (kernel/sched/core.c:6551:8)
  osandov#2  schedule (kernel/sched/core.c:6627:3)
  osandov#3  schedule_preempt_disabled (kernel/sched/core.c:6686:2)
  osandov#4  __mutex_lock_common (kernel/locking/mutex.c:679:3)
  osandov#5  __mutex_lock (kernel/locking/mutex.c:747:9)
  osandov#6  0xffffffffc014112b
  ..................

  Dumping call stack for owner of mutex: ffffffffc0143400

  call stack for pid: 214
  #0  delay_tsc (arch/x86/lib/delay.c:79:3)
  osandov#1  0xffffffffc0141308
  ..................

  Signed-off-by: Imran Khan <[email protected]>
imran-kn added a commit to imran-kn/drgn-work that referenced this pull request Mar 18, 2024
python3 -m drgn -s vmlinux -c vmcore contrib/locks.py --help

usage: locks.py [-h] lock_type info_type [locks ...]

positional arguments:
lock_type   type of lock i.e mutex. semaphore, rwsemaphore etc.
info_type   "owner" or "waiter" or "all"
locks       list of lock addresses

options:
-h, --help  show this help message and exit

For example following command will give us call stack for owner
waiters of specified mutex(es):

python3 -m drgn -s vmlinux -c vmcore contrib/locks.py semaphore waiter ffffffffc0097340
Dumping call stack for waiter(s) of semaphore: ffffffffc0097340

call stack for pid: 1178
 #0  context_switch (kernel/sched/core.c:2811:2)
 osandov#1  __schedule (kernel/sched/core.c:3387:8)
 osandov#2  schedule (kernel/sched/core.c:3431:3)
 osandov#3  schedule_timeout (kernel/time/timer.c:1724:3)
 osandov#4  __down_common (kernel/locking/semaphore.c:221:13)
 osandov#5  __down (kernel/locking/semaphore.c:238:2)
 osandov#6  down (kernel/locking/semaphore.c:62:3)
 osandov#7  0xffffffffc0095045

..................

 call stack for pid: 1180
 #0  context_switch (kernel/sched/core.c:2811:2)
 osandov#1  __schedule (kernel/sched/core.c:3387:8)
 osandov#2  schedule (kernel/sched/core.c:3431:3)
 osandov#3  schedule_timeout (kernel/time/timer.c:1724:3)
 osandov#4  __down_common (kernel/locking/semaphore.c:221:13)
 osandov#5  __down (kernel/locking/semaphore.c:238:2)
 osandov#6  down (kernel/locking/semaphore.c:62:3)
 osandov#7  0xffffffffc0095045
 .............

Signed-off-by: Imran Khan <[email protected]>
imran-kn added a commit to imran-kn/drgn-work that referenced this pull request Mar 18, 2024
Add some ready-made helpers for rwsem and make the script
modular so that options can be added/removed for one lock
type, independently from other lock types.

Some example of using the script have been given below:

python3 -m drgn -s vmlinux -c vmcore-1 contrib/locks.py -h
usage: drgn script to dump lock information [-h] {mutex,semaphore,rwsem} ...

options:
  -h, --help            show this help message and exit

subcommands:
  {mutex,semaphore,rwsem}
    mutex               get mutex info.
    semaphore           get semaphore info.
    rwsem               get read-write semaphore info.

python3 -m drgn -s vmlinux -c vmcore-1 contrib/locks.py semaphore -h
usage: drgn script to dump lock information semaphore [-h] [--info | --waiter-list | --waiter-callstack] [locks ...]

positional arguments:
  locks               list of lock addresses

options:
  -h, --help          show this help message and exit
  --info              dump given semaphore's info like waiter(s) etc.
  --waiter-list       provide a list, of waiters of given semaphore(s)
  --waiter-callstack  provide callstack of all waiters of given semaphore(s)

python3 -m drgn -s vmlinux -c vmcore contrib/locks.py semaphore --waiter-list ffffffffc0097340
  The waiters of semaphore: ffffffffc0097340 are as follows:
    (struct task_struct *)0xffff992afc618000 pid: 1178 state: D
    (struct task_struct *)0xffff992afc7ae200 pid: 1181 state: D
    (struct task_struct *)0xffff992afc61ee40 pid: 1179 state: D
    (struct task_struct *)0xffff992afc619880 pid: 1180 state: D

python3 -m drgn -s vmlinux -c vmcore-1 contrib/locks.py semaphore --waiter-list ffffffffc0262340
  The waiters of semaphore: ffffffffc0262340 are as follows:
    (struct task_struct *)0xffff96c3fc6ec980 pid: 1178 state: S
    (struct task_struct *)0xffff96c3fc6eee40 pid: 1177 state: S
    (struct task_struct *)0xffff96c3fc5a55c0 pid: 1175 state: S
    (struct task_struct *)0xffff96c3fc6ee200 pid: 1176 state: S

python3 -m drgn -s vmlinux -c vmcore-1 contrib/locks.py semaphore --waiter-callstack ffffffffc0262340
Dumping call stack for waiter(s) of semaphore: ffffffffc0262340

call stack for pid: 1178
 #0  context_switch (kernel/sched/core.c:2811:2)
 osandov#1  __schedule (kernel/sched/core.c:3387:8)
 osandov#2  schedule (kernel/sched/core.c:3431:3)
 osandov#3  schedule_timeout (kernel/time/timer.c:1724:3)
 osandov#4  __down_common (kernel/locking/semaphore.c:221:13)
 osandov#5  __down_interruptible (kernel/locking/semaphore.c:243:9)
 osandov#6  down_interruptible (kernel/locking/semaphore.c:85:12)
 osandov#7  0xffffffffc0260045
.....................

call stack for pid: 1176
 #0  context_switch (kernel/sched/core.c:2811:2)
 osandov#1  __schedule (kernel/sched/core.c:3387:8)
 osandov#2  schedule (kernel/sched/core.c:3431:3)
 osandov#3  schedule_timeout (kernel/time/timer.c:1724:3)
 osandov#4  __down_common (kernel/locking/semaphore.c:221:13)
 osandov#5  __down_interruptible (kernel/locking/semaphore.c:243:9)
 osandov#6  down_interruptible (kernel/locking/semaphore.c:85:12)
 osandov#7  0xffffffffc0260045
call stack for pid: 1176
.....................

python3 -m drgn -s vmlinux -c vmcore-1 contrib/locks.py mutex -h
usage: drgn script to dump lock information mutex [-h] [--info | --waiter-list | --waiter-callstack | --owner-callstack] [locks ...]

positional arguments:
  locks               list of lock addresses

options:
  -h, --help          show this help message and exit
  --info              dump given mutex's info like owner, waiter(s) etc.
  --waiter-list       provide a list, of waiters of given mutex(es)
  --waiter-callstack  provide callstack of all waiters of given mutex(es)
  --owner-callstack   provide callstack of owner of given mutex(es)

python3 -m drgn -s vmlinux -c vmcore contrib/locks.py mutex --info ffffffffc0143400
  mutex: ffffffffc0143400 is owned by (struct task_struct *)0xffffa1fe42393900 pid: 214 state: R
  The waiters of mutex: ffffffffc0143400 are as follows:
    (struct task_struct *)0xffffa1fe42395580 pid: 215 state: D
    (struct task_struct *)0xffffa1fe42a58000 pid: 216 state: D
    (struct task_struct *)0xffffa1fe42389c80 pid: 217 state: D

python3 -m drgn -s vmlinux -c vmcore contrib/locks.py mutex --waiter-list ffffffffc0143400
  The waiters of mutex: ffffffffc0143400 are as follows:
    (struct task_struct *)0xffffa1fe42395580 pid: 215 state: D
    (struct task_struct *)0xffffa1fe42a58000 pid: 216 state: D
    (struct task_struct *)0xffffa1fe42389c80 pid: 217 state: D

python3 -m drgn -s vmlinux -c vmcore contrib/locks.py mutex --waiter-callstack ffffffffc0143400
Dumping call stack for waiter of mutex: ffffffffc0143400

call stack for pid: 215
 #0  context_switch (kernel/sched/core.c:5238:2)
 osandov#1  __schedule (kernel/sched/core.c:6551:8)
 osandov#2  schedule (kernel/sched/core.c:6627:3)
 osandov#3  schedule_preempt_disabled (kernel/sched/core.c:6686:2)
 osandov#4  __mutex_lock_common (kernel/locking/mutex.c:679:3)
 osandov#5  __mutex_lock (kernel/locking/mutex.c:747:9)
 osandov#6  0xffffffffc01411f6
........................

python3 -m drgn -s vmlinux -c vmcore-multiple-readers contrib/locks.py rwsem -h
usage: drgn script to dump lock information rwsem [-h] [--info | --waiter-list | --waiter-callstack | --owner-callstack] [locks ...]

positional arguments:
  locks               list of lock addresses

options:
  -h, --help          show this help message and exit
  --info              dump given rwsem's info like owner, waiter(s) etc.
  --waiter-list       provide a list, of waiters of given rwsem(s)
  --waiter-callstack  provide callstack of all waiters of given rwsem(s)
  --owner-callstack   provide callstack of owner of given rwsem(s)

python3 -m drgn -s vmlinux -c vmcore-reader-writer-reader-reader contrib/locks.py rwsem --info ffffffffc036d3c0
  rwsem: ffffffffc036d3c0 is owned by one or more readers.
  The waiters of rwsem are as follows:
    (struct task_struct *)0xffff9e593d4e3100: (pid)1175: type: down_write state: D
    (struct task_struct *)0xffff9e593d4e1880: (pid)1176: type: down_read state: D
    (struct task_struct *)0xffff9e593d4e6200: (pid)1177: type: down_read state: D

python3 -m drgn -s vmlinux -c vmcore-reader-writer-reader-reader contrib/locks.py rwsem --waiter-callstack ffffffffc036d3c0
Dumping call stack for waiter of rwsem: ffffffffc036d3c0

call stack for pid: 1175
 #0  context_switch (kernel/sched/core.c:2814:2)
 osandov#1  __schedule (kernel/sched/core.c:3389:8)
 osandov#2  schedule (kernel/sched/core.c:3433:3)
 osandov#3  __rwsem_down_write_failed_common (kernel/locking/rwsem-xadd.c:588:4)
 osandov#4  call_rwsem_down_write_failed+0x13/0x1f (arch/x86/lib/rwsem.S:105)
 osandov#5  __down_write (./arch/x86/include/asm/rwsem.h:126:2)
 osandov#6  down_write (kernel/locking/rwsem.c:56:2)
 osandov#7  0xffffffffc036b2b6
................................

python3 -m drgn -s vmlinux -c vmcore-writer-reader-reader-reader contrib/locks.py rwsem --info ffffffffc02033c0
  rwsem: ffffffffc02033c0 owned by writer (struct task_struct *)0xffff9162fdb58c40  (pid)1173  (state)R
  The waiters of rwsem are as follows:
    (struct task_struct *)0xffff9162fdb5ee40: (pid)1174: type: down_read state: D
    (struct task_struct *)0xffff9162fd8355c0: (pid)1175: type: down_read state: D
    (struct task_struct *)0xffff9162fd836200: (pid)1176: type: down_read state: D

For newer kernels number of read owners can be obtained:

python3 -m drgn -s vmlinux -c vmcore-multiple-readers contrib/locks.py rwsem --info ffffffffc00c9340
  rwsem: ffffffffc00c9340 is owned by 2 reader(s).
  There are no waiters for rwsem: ffffffffc00c9340.

Signed-off-by: Imran Khan <[email protected]>
imran-kn added a commit to imran-kn/drgn-work that referenced this pull request Mar 18, 2024
For example:

python3 -m drgn -s vmlinux -c vmcore-writer-reader-reader-reader contrib/locks.py rwsem --spinner-callstack ffffffffc03083c0
rwsem: ffffffffc03083c0 has 1 spinners and their call-stack is as follows:

call stack for pid: 239
 #0  __read_once_size (./include/linux/compiler.h:268:2)
 osandov#1  arch_atomic64_read (./arch/x86/include/asm/atomic64_64.h:22:9)
 osandov#2  atomic64_read (./include/asm-generic/atomic-instrumented.h:837:9)
 osandov#3  atomic_long_read (./include/asm-generic/atomic-long.h:28:9)
 osandov#4  rwsem_owner_flags (kernel/locking/rwsem.c:298:24)
 osandov#5  rwsem_spin_on_owner (kernel/locking/rwsem.c:737:9)
 osandov#6  rwsem_optimistic_spin (kernel/locking/rwsem.c:812:17)
 osandov#7  rwsem_down_read_slowpath (kernel/locking/rwsem.c:1018:6)
 osandov#8  __down_read_killable (kernel/locking/rwsem.c:1366:14)
 osandov#9  down_read_killable (kernel/locking/rwsem.c:1532:6)
 osandov#10 0xffffffffc030622c
.................

Signed-off-by: Imran Khan <[email protected]>
imran-kn added a commit to imran-kn/drgn-work that referenced this pull request Mar 18, 2024
For example:
python3 -m drgn -s vmlinux -c vmcore-1 contrib/locks.py mutex --spinner-callstack ffffffffc02af340
mutex: ffffffffc02af340 has 4 spinners and their call-stack is as follows:

call stack for pid: 250
 #0  __read_once_size (./include/linux/compiler.h:268:2)
 osandov#1  osq_lock (kernel/locking/osq_lock.c:137:10)
 osandov#2  mutex_optimistic_spin (kernel/locking/mutex.c:667:8)
 osandov#3  __mutex_lock_common (kernel/locking/mutex.c:971:6)
 osandov#4  __mutex_lock (kernel/locking/mutex.c:1109:9)
 osandov#5  0xffffffffc02ad045
 ......................

call stack for pid: 251
 #0  __read_once_size (./include/linux/compiler.h:268:2)
 osandov#1  osq_lock (kernel/locking/osq_lock.c:137:10)
 osandov#2  mutex_optimistic_spin (kernel/locking/mutex.c:667:8)
 osandov#3  __mutex_lock_common (kernel/locking/mutex.c:971:6)
 osandov#4  __mutex_lock (kernel/locking/mutex.c:1109:9)
 osandov#5  0xffffffffc02ad045
 .....................

call stack for pid: 248
 #0  __read_once_size (./include/linux/compiler.h:268:2)
 osandov#1  osq_lock (kernel/locking/osq_lock.c:137:10)
 osandov#2  mutex_optimistic_spin (kernel/locking/mutex.c:667:8)
 osandov#3  __mutex_lock_common (kernel/locking/mutex.c:971:6)
 osandov#4  __mutex_lock (kernel/locking/mutex.c:1109:9)
 osandov#5  0xffffffffc02ad045
.....................

call stack for pid: 249
 #0  __read_once_size (./include/linux/compiler.h:268:2)
 osandov#1  arch_atomic64_read (./arch/x86/include/asm/atomic64_64.h:22:9)
 osandov#2  atomic64_read (./include/asm-generic/atomic-instrumented.h:837:9)
 osandov#3  atomic_long_read (./include/asm-generic/atomic-long.h:28:9)
 osandov#4  __mutex_owner (kernel/locking/mutex.c:75:32)
 osandov#5  mutex_spin_on_owner (kernel/locking/mutex.c:566:9)
 osandov#6  mutex_optimistic_spin (kernel/locking/mutex.c:683:8)
 osandov#7  __mutex_lock_common (kernel/locking/mutex.c:971:6)
 osandov#8  __mutex_lock (kernel/locking/mutex.c:1109:9)
 osandov#9  0xffffffffc02ad045
....................

Signed-off-by: Imran Khan <[email protected]>
kylee0215 added a commit to kylee0215/drgn that referenced this pull request Sep 4, 2024
Sample output:

Page allocated via order 0, gfp_mask: 0x140cca, pid: 74, tgid: 74 (b'kworker/u32:2'), ts 1189257596 ns, free_ts 0 ns
PFN: 262203, Flags: 0x3fffe000004003c
#0  set_page_owner (./include/linux/page_owner.h:32:3)
osandov#1  post_alloc_hook (mm/page_alloc.c:1502:2)
osandov#2  prep_new_page (mm/page_alloc.c:1510:2)
osandov#3  get_page_from_freelist (mm/page_alloc.c:3489:4)
osandov#4  __alloc_pages_noprof (mm/page_alloc.c:4747:9)
osandov#5  alloc_pages_mpol_noprof (mm/mempolicy.c:2263:9)
osandov#6  folio_alloc_mpol_noprof (mm/mempolicy.c:2281:9)
osandov#7  shmem_alloc_folio (mm/shmem.c:1726:10)
osandov#8  shmem_alloc_and_add_folio (mm/shmem.c:1786:11)
osandov#9  shmem_get_folio_gfp (mm/shmem.c:2192:10)
osandov#10 shmem_get_folio (mm/shmem.c:2297:9)
osandov#11 shmem_write_begin (mm/shmem.c:2902:8)
osandov#12 generic_perform_write (mm/filemap.c:4019:12)
osandov#13 shmem_file_write_iter (mm/shmem.c:3078:8)
osandov#14 __kernel_write_iter (fs/read_write.c:523:8)
osandov#15 __kernel_write (fs/read_write.c:543:9)
osandov#16 kernel_write (fs/read_write.c:564:9)
osandov#17 kernel_write (fs/read_write.c:554:9)
osandov#18 xwrite (init/initramfs.c:33:16)
osandov#19 do_copy (init/initramfs.c:405:7)
osandov#20 write_buffer (init/initramfs.c:452:10)
osandov#21 unpack_to_rootfs (init/initramfs.c:505:14)
...

Signed-off-by: Kuan-Ying Lee <[email protected]>
kylee0215 added a commit to kylee0215/drgn that referenced this pull request Sep 4, 2024
python3 -m drgn -s ./vmlinux -c ./vmcore contrib/page_owner.py --pfn 262144

Sample output:

Page last allocated via order 0, gfp_mask: 0x140cca, pid: 74, tgid: 74 (kworker/u32:2), ts 1189257596 ns, free_ts 0 ns
PFN: 262203, Flags: 0x3fffe000004003c
#0  set_page_owner (./include/linux/page_owner.h:32:3)
osandov#1  post_alloc_hook (mm/page_alloc.c:1502:2)
osandov#2  prep_new_page (mm/page_alloc.c:1510:2)
osandov#3  get_page_from_freelist (mm/page_alloc.c:3489:4)
osandov#4  __alloc_pages_noprof (mm/page_alloc.c:4747:9)
osandov#5  alloc_pages_mpol_noprof (mm/mempolicy.c:2263:9)
osandov#6  folio_alloc_mpol_noprof (mm/mempolicy.c:2281:9)
osandov#7  shmem_alloc_folio (mm/shmem.c:1726:10)
osandov#8  shmem_alloc_and_add_folio (mm/shmem.c:1786:11)
osandov#9  shmem_get_folio_gfp (mm/shmem.c:2192:10)
osandov#10 shmem_get_folio (mm/shmem.c:2297:9)
osandov#11 shmem_write_begin (mm/shmem.c:2902:8)
osandov#12 generic_perform_write (mm/filemap.c:4019:12)
osandov#13 shmem_file_write_iter (mm/shmem.c:3078:8)
osandov#14 __kernel_write_iter (fs/read_write.c:523:8)
osandov#15 __kernel_write (fs/read_write.c:543:9)
osandov#16 kernel_write (fs/read_write.c:564:9)
osandov#17 kernel_write (fs/read_write.c:554:9)
osandov#18 xwrite (init/initramfs.c:33:16)
osandov#19 do_copy (init/initramfs.c:405:7)
osandov#20 write_buffer (init/initramfs.c:452:10)
osandov#21 unpack_to_rootfs (init/initramfs.c:505:14)
...

Signed-off-by: Kuan-Ying Lee <[email protected]>
kylee0215 added a commit to kylee0215/drgn that referenced this pull request Sep 4, 2024
python3 -m drgn -s ./vmlinux -c ./vmcore contrib/page_owner.py --pfn 262144

Sample output:

page_owner tracks the page as allocated
Page last allocated via order 0, gfp_mask: 0x140cca, pid: 74, tgid: 74 (kworker/u32:2), ts 1187644920 ns, free_ts 0 ns
PFN: 262144, Flags: 0x3fffe000004003c
#0  set_page_owner (./include/linux/page_owner.h:32:3)
osandov#1  post_alloc_hook (mm/page_alloc.c:1502:2)
osandov#2  prep_new_page (mm/page_alloc.c:1510:2)
osandov#3  get_page_from_freelist (mm/page_alloc.c:3489:4)
osandov#4  __alloc_pages_noprof (mm/page_alloc.c:4747:9)
osandov#5  alloc_pages_mpol_noprof (mm/mempolicy.c:2263:9)
osandov#6  folio_alloc_mpol_noprof (mm/mempolicy.c:2281:9)
osandov#7  shmem_alloc_folio (mm/shmem.c:1726:10)
osandov#8  shmem_alloc_and_add_folio (mm/shmem.c:1786:11)
osandov#9  shmem_get_folio_gfp (mm/shmem.c:2192:10)
osandov#10 shmem_get_folio (mm/shmem.c:2297:9)
osandov#11 shmem_write_begin (mm/shmem.c:2902:8)
osandov#12 generic_perform_write (mm/filemap.c:4019:12)
osandov#13 shmem_file_write_iter (mm/shmem.c:3078:8)
osandov#14 __kernel_write_iter (fs/read_write.c:523:8)
osandov#15 __kernel_write (fs/read_write.c:543:9)
osandov#16 kernel_write (fs/read_write.c:564:9)
osandov#17 kernel_write (fs/read_write.c:554:9)
osandov#18 xwrite (init/initramfs.c:33:16)
osandov#19 do_copy (init/initramfs.c:405:7)
osandov#20 write_buffer (init/initramfs.c:452:10)
osandov#21 unpack_to_rootfs (init/initramfs.c:505:14)
page_owner free stack trace missing
...

Signed-off-by: Kuan-Ying Lee <[email protected]>
kylee0215 added a commit to kylee0215/drgn that referenced this pull request Sep 4, 2024
python3 -m drgn -s ./vmlinux -c ./vmcore contrib/page_owner.py --pfn 262144

Sample output:

page_owner tracks the page as allocated
Page last allocated via order 0, gfp_mask: 0x140cca, pid: 74, tgid: 74 (kworker/u32:2), ts 1187644920 ns, free_ts 0 ns
PFN: 262144, Flags: 0x3fffe000004003c
#0  set_page_owner (./include/linux/page_owner.h:32:3)
osandov#1  post_alloc_hook (mm/page_alloc.c:1502:2)
osandov#2  prep_new_page (mm/page_alloc.c:1510:2)
osandov#3  get_page_from_freelist (mm/page_alloc.c:3489:4)
osandov#4  __alloc_pages_noprof (mm/page_alloc.c:4747:9)
osandov#5  alloc_pages_mpol_noprof (mm/mempolicy.c:2263:9)
osandov#6  folio_alloc_mpol_noprof (mm/mempolicy.c:2281:9)
osandov#7  shmem_alloc_folio (mm/shmem.c:1726:10)
osandov#8  shmem_alloc_and_add_folio (mm/shmem.c:1786:11)
osandov#9  shmem_get_folio_gfp (mm/shmem.c:2192:10)
osandov#10 shmem_get_folio (mm/shmem.c:2297:9)
osandov#11 shmem_write_begin (mm/shmem.c:2902:8)
osandov#12 generic_perform_write (mm/filemap.c:4019:12)
osandov#13 shmem_file_write_iter (mm/shmem.c:3078:8)
osandov#14 __kernel_write_iter (fs/read_write.c:523:8)
osandov#15 __kernel_write (fs/read_write.c:543:9)
osandov#16 kernel_write (fs/read_write.c:564:9)
osandov#17 kernel_write (fs/read_write.c:554:9)
osandov#18 xwrite (init/initramfs.c:33:16)
osandov#19 do_copy (init/initramfs.c:405:7)
osandov#20 write_buffer (init/initramfs.c:452:10)
osandov#21 unpack_to_rootfs (init/initramfs.c:505:14)
page_owner free stack trace missing
...

Signed-off-by: Kuan-Ying Lee <[email protected]>
daniel-thompson added a commit to daniel-thompson/drgn that referenced this pull request Oct 14, 2024
Both usage and limitations are described in docs/advanced_usage.rst.

Testing is been modest but does follow pretty much all the new code
paths:

1. the reported register values were compared between gdb and drgn
2. frame pointer based (fallback) stack tracing
3. x0 (argc) and x1 (argv) were checked and the pointers chased
   to verify that argv[0] contains the right value

The autotests are based on osandov#1 and osandov#2 above (there are enough memory
reads during a stack trace to exercise the memory read paths).

Signed-off-by: Daniel Thompson <[email protected]>
daniel-thompson added a commit to daniel-thompson/drgn that referenced this pull request Oct 14, 2024
Both usage and limitations are described in docs/advanced_usage.rst.

Testing is been modest but does follow pretty much all the new code
paths:

1. the reported register values were compared between gdb and drgn
2. frame pointer based (fallback) stack tracing
3. x0 (argc) and x1 (argv) were checked and the pointers chased
   to verify that argv[0] contains the right value

The autotests are based on osandov#1 and osandov#2 above (there are enough memory
reads during a stack trace to exercise the memory read paths).

Signed-off-by: Daniel Thompson <[email protected]>
kylee0215 added a commit to kylee0215/drgn that referenced this pull request Oct 29, 2024
python3 -m drgn -s ./vmlinux -c ./vmcore contrib/page_owner.py --pfn 262144

Sample output:

page_owner tracks the page as allocated
Page last allocated via order 0, gfp_mask: 0x140cca, pid: 74, tgid: 74 (kworker/u32:2), ts 1187644920 ns, free_ts 0 ns
PFN: 262144, Flags: 0x3fffe000004003c
#0  set_page_owner (./include/linux/page_owner.h:32:3)
osandov#1  post_alloc_hook (mm/page_alloc.c:1502:2)
osandov#2  prep_new_page (mm/page_alloc.c:1510:2)
osandov#3  get_page_from_freelist (mm/page_alloc.c:3489:4)
osandov#4  __alloc_pages_noprof (mm/page_alloc.c:4747:9)
osandov#5  alloc_pages_mpol_noprof (mm/mempolicy.c:2263:9)
osandov#6  folio_alloc_mpol_noprof (mm/mempolicy.c:2281:9)
osandov#7  shmem_alloc_folio (mm/shmem.c:1726:10)
osandov#8  shmem_alloc_and_add_folio (mm/shmem.c:1786:11)
osandov#9  shmem_get_folio_gfp (mm/shmem.c:2192:10)
osandov#10 shmem_get_folio (mm/shmem.c:2297:9)
osandov#11 shmem_write_begin (mm/shmem.c:2902:8)
osandov#12 generic_perform_write (mm/filemap.c:4019:12)
osandov#13 shmem_file_write_iter (mm/shmem.c:3078:8)
osandov#14 __kernel_write_iter (fs/read_write.c:523:8)
osandov#15 __kernel_write (fs/read_write.c:543:9)
osandov#16 kernel_write (fs/read_write.c:564:9)
osandov#17 kernel_write (fs/read_write.c:554:9)
osandov#18 xwrite (init/initramfs.c:33:16)
osandov#19 do_copy (init/initramfs.c:405:7)
osandov#20 write_buffer (init/initramfs.c:452:10)
osandov#21 unpack_to_rootfs (init/initramfs.c:505:14)
page_owner free stack trace missing
...

Signed-off-by: Kuan-Ying Lee <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants