-
Notifications
You must be signed in to change notification settings - Fork 165
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: read kdumps (new dependecy: libkdumpfile) #7
Conversation
Seems like Travis is failing because the images do not have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few more minor comments. I think C is preferable for this so that it's supported from the C API. Thanks for the contribution!
libdrgn/program.c
Outdated
@@ -534,6 +583,11 @@ drgn_program_set_core_dump(struct drgn_program *prog, const char *path) | |||
if (prog->core_fd == -1) | |||
return drgn_error_create_os(errno, path, "open"); | |||
|
|||
if (has_kdump_signature(prog->core_fd, &err)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a side note, normal ELF vmcores don't include vmalloc or per CPU addresses in the program headers, so drgn currently can't read from them. It seems like libkdumpfile can, so perhaps as a followup change, we should also use libkdumpfile for normal ELF vmcores.
Asked a couple of questions above, and applied the rest of the feedback in a separate commit. As this is still a WIP, I'll leave each round of feedback as a separate commit and squash them into one commit before merging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, sorry for the delay. A few comments about reorganizing the conditional compilation.
- kdump_reader.c only compiled when respective flag is enabled - drgn_program_set_kdump() the only thing exposed through kdump_header.h - has_kdump_signature() moved to program.c - dump OSRELEASE_LEN macro - kdump_read() impossible short read without error - no need to clear buffer before using kdump_read() - has_kdump_signature() return NULL for cores smaller than KDUMP_SIG_LEN
I pushed a tweak to the configure script so that we automatically use libkdumpfile if it's available. A few final things:
|
I rebased this on top of the platform change in the devel branch. Can you please test it out? If everything works well, I'll merge it. |
Just tested the PR and the output is the same as the description (I tried a few other globals and types from modules that I loaded with I remember you mentioning on our DMs yesterday, that you went ahead and did the freeing of the kdump context yourself? I didn't see that in the changes that I pulled (neither the renaming |
Ah, I pushed the changes to the |
Gave the |
Merged, thanks! |
Sync "6.0/stage" with "master" via GitHub Actions
Simply doing "drgn" segmentation-faults on my machine: (gdb) bt #0 apply_elf_rela_x86_64 (relocating=relocating@entry=0x7fc843650c90, r_offset=0, r_type=2, r_addend=0, sym_value=<optimized out>) at ../../libdrgn/arch_x86_64.c:498 #1 0x00007fc88cbd523b in relocate_elf_section (platform=0x7fc843650c80, shdrnum=59, sh_addrs=0x7fc808000b20, symtab_scn=<optimized out>, reloc_scn=0x17614c8, scn=<optimized out>) at ../../libdrgn/debug_info.c:761 osandov#2 relocate_elf_file (elf=<optimized out>) at ../../libdrgn/debug_info.c:865 osandov#3 drgn_debug_info_find_sections (module=<optimized out>) at ../../libdrgn/debug_info.c:883 osandov#4 drgn_debug_info_read_module (load=load@entry=0x7ffea9d70870, dindex_state=0x7ffea9d70810, head=0x163c6b0) at ../../libdrgn/debug_info.c:970 osandov#5 0x00007fc88cbd5474 in drgn_debug_info_update_index._omp_fn.1 () at ../../libdrgn/debug_info.c:1037 osandov#6 0x00007fc88cb19769 in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1 osandov#7 0x00007fc88cb21f00 in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1 osandov#8 0x00007fc88cb1f7aa in ?? () from /usr/lib/x86_64-linux-gnu/libgomp.so.1 osandov#9 0x00007fc88dfb7fa3 in start_thread (arg=<optimized out>) at pthread_create.c:486 osandov#10 0x00007fc88dafe4cf in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95 Always returning NULL in libdrgn/debug_info.c:relocate_elf_file() fixes the issue. I don't know, maybe it's a bug in drgn's implementation of ELF relocation, but add this hack for now. Signed-off-by: Peilin Ye <[email protected]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
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]>
Intro
Note that this is a WIP to get feedback on the design/organization of the code.
After writing this in C, I realized that it could have been easily implemented in
Python too since libkdumpfile provides wrappers for Python. I'm not sure what
would be preferable at this point but it wouldn't be a problem for me rewriting
this in Python.
Preliminary Feature Testing
Look at the
jiffies
of kdump incrash
:Using the same address to read the
jiffies
from drgn prototype we get the same value:Testing that feature is indeed an optional dependency
The above testing was done by enabling the feature through
setup.py
like this:Without the feature trying to open the same crash dump we get the following error:
Work left