Source code formatting cleanups
by Anatol Pomozov
Hi, Dave
Reading through the 'crash' source code I found that it uses different
styles across codebase. I went ahead and fixed the most common formatting
problems. The changes can be found here
https://github.com/anatol/crash
Here is the list of cleanups. Most of them are self descriptive:
21da621 Indent the code using GNU indent tool
8b9c671 Replace leading spaces with tabs
9ce66d8 Remove trailing whitespaces
f67b4c3 Fix misspellings using codespell tool
92fc952 Convert Windows EOL to Unix one using 'dos2unix' tool
Feel free to pick any of them. Actually most of the changes (except the
codespell one) are fully automatic and can be rerun on your local machine.
And "Replace leading spaces with tabs" is not strictly needed as "indent"
change will do the same, I just kept them separate if you want to pick only
one of the changes.
11 years, 3 months
x86_64: Function parameters from stack frames
by Alexandr Terekhov
Hello,
I'd like to introduce a small patch for the crash tool (I described an idea behind it https://www.redhat.com/archives/crash-utility/2013-March/msg00164.html).
* crash version 6.1.6
* arch x86_64
You can find it here https://github.com/hziSot/crash-stack-parser
So, here are some results from a real system:
=======> CPU #0
bin> bt
PID: 0 TASK: ffffffff81a8d020 CPU: 0 COMMAND: "swapper"
#0 [ffff880045603920] machine_kexec at ffffffff8103284b
#1 [ffff880045603980] crash_kexec at ffffffff810ba972
#2 [ffff880045603a50] oops_end at ffffffff81501860
#3 [ffff880045603a80] no_context at ffffffff81043bfb
#4 [ffff880045603ad0] __bad_area_nosemaphore at ffffffff81043e85
#5 [ffff880045603b20] bad_area_nosemaphore at ffffffff81043f53
#6 [ffff880045603b30] __do_page_fault at ffffffff810446b1
#7 [ffff880045603c50] do_page_fault at ffffffff8150383e
#8 [ffff880045603c80] page_fault at ffffffff81500bf5
#9 [ffff880045603d60] activate_task at ffffffff81053953
#10 [ffff880045603d70] try_to_wake_up at ffffffff810600c0
#11 [ffff880045603de0] default_wake_function at ffffffff810602c2
#12 [ffff880045603df0] __wake_up_common at ffffffff8104e369
#13 [ffff880045603e40] complete at ffffffff81053347
#14 [ffff880045603e70] qla24xx_msix_default at ffffffffa00a8f74 [qla2xxx]
#15 [ffff880045603ed0] handle_IRQ_event at ffffffff810dbb10
#16 [ffff880045603f20] handle_edge_irq at ffffffff810de29e
#17 [ffff880045603f60] handle_irq at ffffffff8100df09
#18 [ffff880045603f80] do_IRQ at ffffffff815060bc
--- <IRQ stack> ---
#19 [ffffffff81a01da8] ret_from_intr at ffffffff8100ba53
[exception RIP: intel_idle+222]
RIP: ffffffff812cdc0e RSP: ffffffff81a01e58 RFLAGS: 00000206
RAX: 0000000000000000 RBX: ffffffff81a01ec8 RCX: 0000000000000000
RDX: 000000000000116c RSI: 0000000000000000 RDI: 0000000000441165
RBP: ffffffff8100ba4e R8: 0000000000000005 R9: 000000000000006d
R10: 000000c26ede6d76 R11: 0000000000000000 R12: ffff8800456115a0
R13: 0000000000000000 R14: 000000c12ce6a080 R15: ffff8800456116a0
ORIG_RAX: ffffffffffffff9d CS: 0010 SS: 0018
#20 [ffffffff81a01ed0] cpuidle_idle_call at ffffffff81407997
#21 [ffffffff81a01ef0] cpu_idle at ffffffff81009e06
bin> bt -H
Backtrace:
# 0: [RSP: 0xffff880045603980, RIP: 0xffffffff8103284b] machine_kexec (struct kimage * arg = 0xffff88082659b400)
# 1: [RSP: 0xffff880045603a50, RIP: 0xffffffff810ba972] crash_kexec (struct pt_regs * arg = 0xffff880045603c88)
# 2: [RSP: 0xffff880045603a80, RIP: 0xffffffff81501860] oops_end (long unsigned int arg = unknown, struct pt_regs * arg = 0xffff880045603c88, int arg = 0x9)
# 3: [RSP: 0xffff880045603ad0, RIP: 0xffffffff81043bfb] no_context (struct pt_regs * arg = 0xffff880045603c88, long unsigned int arg = 0x10, long unsigned int arg = 0x0)
# 4: [RSP: 0xffff880045603b20, RIP: 0xffffffff81043e85] __bad_area_nosemaphore (struct pt_regs * arg = 0xffff880045603c88, long unsigned int arg = 0x10, long unsigned int arg = 0x0, int arg = 0x30001)
# 5: [RSP: 0xffff880045603b30, RIP: 0xffffffff81043f53] bad_area_nosemaphore (struct pt_regs * arg = 0xffff880045603c88, long unsigned int arg = 0x10, long unsigned int arg = 0x0)
# 6: [RSP: 0xffff880045603c50, RIP: 0xffffffff810446b1] __do_page_fault (struct pt_regs * arg = 0xffff880045603c88, long unsigned int arg = 0x4b2, long unsigned int arg = 0x10)
# 7: [RSP: 0xffff880045603c80, RIP: 0xffffffff8150383e] do_page_fault (struct pt_regs * arg = 0xffff880045603c88, long unsigned int arg = 0xffffffffffffffff)
# 8: [RSP: 0xffff880045603d30, RIP: 0xffffffff81500bf5] page_fault ()
# 9: [RSP: 0xffff880045603d60, RIP: 0xffffffff81053916] enqueue_task (struct rq * arg = 0xffff8800456d6680, struct task_struct * arg = 0xffff88082b83eae0, int arg = 0x1)
# 10: [RSP: 0xffff880045603d70, RIP: 0xffffffff81053953] activate_task (struct rq * arg = 0xffff8800456d6680, struct task_struct * arg = 0xffff88082b83eae0, int arg = 0x1)
# 11: [RSP: 0xffff880045603de0, RIP: 0xffffffff810600c0] try_to_wake_up (struct task_struct * arg = 0xffff88082b83eae0, unsigned int arg = 0x3, int arg = 0x0)
# 12: [RSP: 0xffff880045603df0, RIP: 0xffffffff810602c2] default_wake_function (wait_queue_t * arg = 0xffff8800456c3b40, unsigned int arg = 0x3, int arg = 0x0, void * arg = 0xc1416b9c06)
# 13: [RSP: 0xffff880045603e40, RIP: 0xffffffff8104e369] __wake_up_common (wait_queue_head_t * arg = 0xffff880825e6a2a8, unsigned int arg = 0x3, int arg = 0x1, int arg = 0x0, void * arg = 0x0)
# 14: [RSP: 0xffff880045603e70, RIP: 0xffffffff81053347] complete (struct completion * arg = 0xffff880825e6a2a0)
# 15: [RSP: 0xffff880045603ed0, RIP: 0xffffffffa00a8f74] qla24xx_msix_default (int arg = 0x3e, void * arg = 0xffff880826bd55c0)
# 16: [RSP: 0xffff880045603f20, RIP: 0xffffffff810dbb10] handle_IRQ_event (unsigned int arg = 0x3e, struct irqaction * arg = 0xffff880826bd5840)
# 17: [RSP: 0xffff880045603f60, RIP: 0xffffffff810de29e] handle_edge_irq (unsigned int arg = 0x3e, struct irq_desc * arg = 0xffff880824563ec0)
# 18: [RSP: 0xffff880045603f80, RIP: 0xffffffff8100df09] handle_irq (unsigned int arg = 0x3e, struct pt_regs * arg = 0xffffffff81a01da8)
# 19: [RSP: 0xffff880045603fb0, RIP: 0xffffffff815060bc] do_IRQ (struct pt_regs * arg = 0xffffffff81a01da8)
# 20: [RSP: 0xffffffff81a01e50, RIP: 0xffffffff8100ba53] common_interrupt ()
# 21: [RSP: 0xffffffff81a01ed0, RIP: 0xffffffff812cdc0e] intel_idle (struct cpuidle_device * arg = 0xffff88004561dcc0, struct cpuidle_state * arg = 0xffff88004561de50)
# 22: [RSP: 0xffffffff81a01ef0, RIP: 0xffffffff81407997] cpuidle_idle_call ()
Some of the arguments are not accurate, but many of them are correct:
bin> p/x *(( struct pt_regs * ) 0xffffffff81a01da8 )
$54 = {
r15 = 0xffff8800456116a0,
r14 = 0xc12ce6a080,
r13 = 0x0,
r12 = 0xffff8800456115a0,
bp = 0xffffffff8100ba4e,
bx = 0xffffffff81a01ec8,
r11 = 0x0,
r10 = 0xc26ede6d76,
r9 = 0x6d,
r8 = 0x5,
ax = 0x0,
cx = 0x0,
dx = 0x116c,
si = 0x0,
di = 0x441165,
orig_ax = 0xffffffffffffff9d,
ip = 0xffffffff812cdc0e,
cs = 0x10,
flags = 0x206,
sp = 0xffffffff81a01e58,
ss = 0x18
}
bin> p/x *((struct irq_desc * ) 0xffff880824563ec0)
$55 = {
irq = 0x3e,
timer_rand_state = 0x0,
kstat_irqs = 0xffff880825d7f6c0,
irq_2_iommu = 0xffff880825e70880,
handle_irq = 0xffffffff810de1c0,
chip = 0xffffffff81a934e0,
msi_desc = 0xffff880826bd56c0,
handler_data = 0x0,
chip_data = 0xffff880825e708a0,
action = 0xffff880826bd5840,
status = 0x1000100,
depth = 0x0,
wake_depth = 0x0,
irq_count = 0x2cd,
last_unhandled = 0x0,
irqs_unhandled = 0x0,
lock = {
raw_lock = {
slock = 0x5bc05bc
}
},
affinity = 0xffff880826a0f800,
affinity_hint = 0x0,
node = 0x0,
pending_mask = 0xffff88082b765a00,
threads_active = {
counter = 0x0
},
wait_for_threads = {
lock = {
raw_lock = {
slock = 0x0
}
},
task_list = {
next = 0xffff880824563f60,
prev = 0xffff880824563f60
}
},
dir = 0xffff880824563d40,
name = 0xffffffff8177f1ce
}
=======> CPU #6
bin> bt
PID: 0 TASK: ffff88082b83eae0 CPU: 6 COMMAND: "swapper"
#0 [ffff8800456c7e90] crash_nmi_callback at ffffffff81029df6
#1 [ffff8800456c7ea0] notifier_call_chain at ffffffff815038f5
#2 [ffff8800456c7ee0] atomic_notifier_call_chain at ffffffff8150395a
#3 [ffff8800456c7ef0] notify_die at ffffffff810981ee
#4 [ffff8800456c7f20] do_nmi at ffffffff81501573
#5 [ffff8800456c7f50] nmi at ffffffff81500e80
[exception RIP: _spin_lock_irq+37]
RIP: ffffffff81500615 RSP: ffff8800456c3940 RFLAGS: 00000097
RAX: 00000000000008a4 RBX: ffff8800456d6680 RCX: 000000000000c14e
RDX: 00000000000008a3 RSI: 0000000000000001 RDI: ffff8800456d6680
RBP: ffff8800456c3940 R8: 0000000000013679 R9: 00000000fffffffa
R10: 0000000000000002 R11: 0000000000000002 R12: ffff8800456d6680
R13: 0000000000000001 R14: 00000000ffffffff R15: 00000000ffffffff
ORIG_RAX: ffffffffffffffff CS: 0010 SS: 0018
--- <NMI exception stack> ---
#6 [ffff8800456c3940] _spin_lock_irq at ffffffff81500615
#7 [ffff8800456c3948] dequeue_task_idle at ffffffff81053f19
#8 [ffff8800456c3968] dequeue_task at ffffffff8105385e
#9 [ffff8800456c3998] deactivate_task at ffffffff810538a3
#10 [ffff8800456c39a8] thread_return at ffffffff814fded9
#11 [ffff8800456c3a68] schedule_timeout at ffffffff814febf2
#12 [ffff8800456c3b18] wait_for_common at ffffffff814fe8f3
#13 [ffff8800456c3ba8] wait_for_completion_timeout at ffffffff814fe9e3
#14 [ffff8800456c3bb8] qla2x00_mailbox_command at ffffffffa0098d1a [qla2xxx]
#15 [ffff8800456c3c68] qla2x00_issue_iocb_timeout at ffffffffa009cc3b [qla2xxx]
#16 [ffff8800456c3cf8] qla2x00_issue_iocb at ffffffffa009ccd4 [qla2xxx]
#17 [ffff8800456c3d08] qla24xx_abort_command at ffffffffa009f5b8 [qla2xxx]
#18 [ffff8800456c3d68] qla24xx_bsg_timeout at ffffffffa00c0ba6 [qla2xxx]
#19 [ffff8800456c3da8] fc_bsg_job_timeout at ffffffffa00718f7 [scsi_transport_fc]
#20 [ffff8800456c3dd8] blk_rq_timed_out at ffffffff8125dccb
#21 [ffff8800456c3df8] blk_rq_timed_out_timer at ffffffff8125df88
#22 [ffff8800456c3e48] run_timer_softirq at ffffffff8107e927
#23 [ffff8800456c3ed8] __do_softirq at ffffffff81073f51
#24 [ffff8800456c3f48] call_softirq at ffffffff8100c24c
#25 [ffff8800456c3f60] do_softirq at ffffffff8100de85
#26 [ffff8800456c3f80] irq_exit at ffffffff81073d35
#27 [ffff8800456c3f90] smp_apic_timer_interrupt at ffffffff815061b0
#28 [ffff8800456c3fb0] apic_timer_interrupt at ffffffff8100bc13
--- <IRQ stack> ---
#29 [ffff88082b847db8] apic_timer_interrupt at ffffffff8100bc13
[exception RIP: intel_idle+222]
RIP: ffffffff812cdc0e RSP: ffff88082b847e68 RFLAGS: 00000206
RAX: 0000000000000000 RBX: ffff88082b847ed8 RCX: 0000000000000000
RDX: 0000000000000f69 RSI: 0000000000000000 RDI: 00000000003c35fa
RBP: ffffffff8100bc0e R8: 0000000000000005 R9: 000000000000006d
R10: 000000c130c95aec R11: 0000000000000000 R12: ffff8800456d15a0
R13: 0000000000000000 R14: 000000c12d23a980 R15: ffff8800456d16a0
ORIG_RAX: ffffffffffffff10 CS: 0010 SS: 0018
#30 [ffff88082b847ee0] cpuidle_idle_call at ffffffff81407997
#31 [ffff88082b847f00] cpu_idle at ffffffff81009e06
bin> bt -H
# 0: [RSP: 0xffff8800456c7ea0, RIP: 0xffffffff81029df6] crash_nmi_callback (struct notifier_block * arg = 0xffffffff81aa5260, long unsigned int arg = 0xc, void * arg = 0xffff8800456c7ef8)
# 1: [RSP: 0xffff8800456c7ee0, RIP: 0xffffffff815038f5] notifier_call_chain (struct notifier_block ** arg = 0xffffffff81ea87a8, long unsigned int arg = 0xc, void * arg = 0xffff8800456c7ef8, int arg = 0xffffffff, int * arg = 0x0)
# 2: [RSP: 0xffff8800456c7ef0, RIP: 0xffffffff8150395a] atomic_notifier_call_chain (struct atomic_notifier_head * arg = 0xffffffff81ea87a0, long unsigned int arg = 0xc, void * arg = 0xffff8800456c7ef8)
# 3: [RSP: 0xffff8800456c7f20, RIP: 0xffffffff810981ee] notify_die (enum die_val arg = 0xc, const char * arg = 0xffffffff8177d9a2, struct pt_regs * arg = 0xffff8800456c7f58, long int arg = 0x0, int arg = 0x2, int arg = 0x2)
# 4: [RSP: 0xffff8800456c7f50, RIP: 0xffffffff81501573] do_nmi (struct pt_regs * arg = 0xffff8800456c7f58, long int arg = 0xffffffffffffffff)
# 5: [RSP: 0xffff8800456c8000, RIP: 0xffffffff81500e80] nmi ()
# 6: [RSP: 0xffff8800456c3948, RIP: 0xffffffff81500615] _spin_lock_irq (spinlock_t * arg = 0xffff8800456d6680)
# 7: [RSP: 0xffff8800456c3968, RIP: 0xffffffff81053f19] dequeue_task_idle (struct rq * arg = 0xffff8800456d6680, struct task_struct * arg = 0xffff88082b83eae0, int arg = 0x1)
# 8: [RSP: 0xffff8800456c3998, RIP: 0xffffffff8105385e] dequeue_task (struct rq * arg = 0xffff8800456d6680, struct task_struct * arg = 0xffff88082b83eae0, int arg = 0x1)
# 9: [RSP: 0xffff8800456c39a8, RIP: 0xffffffff810538a3] deactivate_task (struct rq * arg = 0xffff8800456d6680, struct task_struct * arg = 0xffff88082b83eae0, int arg = 0x1)
# 10: [RSP: 0xffff8800456c3a68, RIP: 0xffffffff814fded9] thread_return ()
# 11: [RSP: 0xffff8800456c3b18, RIP: 0xffffffff814febf2] schedule_timeout (long int arg = 0x7530)
# 12: [RSP: 0xffff8800456c3ba8, RIP: 0xffffffff814fe8f3] wait_for_common (struct completion * arg = 0xffff880825e6a2a0, long int arg = 0x7530, int arg = 0x2)
# 13: [RSP: 0xffff8800456c3bb8, RIP: 0xffffffff814fe9e3] wait_for_completion_timeout (struct completion * arg = 0xffff880825e6a2a0, long unsigned int arg = 0x7530)
# 14: [RSP: 0xffff8800456c3c68, RIP: 0xffffffffa0098d1a] qla2x00_mailbox_command (scsi_qla_host_t * arg = 0xffff880824562de0, mbx_cmd_t * arg = 0xffff8800456c3c70)
# 15: [RSP: 0xffff8800456c3cf8, RIP: 0xffffffffa009cc3b] qla2x00_issue_iocb_timeout (scsi_qla_host_t * arg = 0xffff880824562de0, void * arg = 0xffff880824561100, dma_addr_t arg = 0x824561100, size_t arg = 0x0, uint32_t arg = 0x1e)
# 16: [RSP: 0xffff8800456c3d08, RIP: 0xffffffffa009ccd4] qla2x00_issue_iocb (scsi_qla_host_t * arg = 0xffff880824562de0, void * arg = 0xffff880824561100, dma_addr_t arg = 0x824561100, size_t arg = 0x0)
# 17: [RSP: 0xffff8800456c3d68, RIP: 0xffffffffa009f5b8] qla24xx_abort_command (srb_t * arg = 0xffff8808145db480)
# 18: [RSP: 0xffff8800456c3da8, RIP: 0xffffffffa00c0ba6] qla24xx_bsg_timeout (struct fc_bsg_job * arg = 0xffff8808268a2740)
# 19: [RSP: 0xffff8800456c3dd8, RIP: 0xffffffffa00718f7] fc_bsg_job_timeout (struct request * arg = 0xffff88082446b360)
# 20: [RSP: 0xffff8800456c3df8, RIP: 0xffffffff8125dccb] blk_rq_timed_out (struct request * arg = 0xffff88082446b360)
# 21: [RSP: 0xffff8800456c3e48, RIP: 0xffffffff8125df88] blk_rq_timed_out_timer (long unsigned int arg = 0xffff88082477cea0)
# 22: [RSP: 0xffff8800456c3ed8, RIP: 0xffffffff8107e927] run_timer_softirq (struct softirq_action * arg = 0xffffffff81a83088)
# 23: [RSP: 0xffff8800456c3f48, RIP: 0xffffffff81073f51] __do_softirq ()
# 24: [RSP: 0xffff8800456c3f60, RIP: 0xffffffff8100c24c] call_softirq ()
# 25: [RSP: 0xffff8800456c3f80, RIP: 0xffffffff8100de85] do_softirq ()
# 26: [RSP: 0xffff8800456c3f90, RIP: 0xffffffff81073d35] irq_exit ()
# 27: [RSP: 0xffff8800456c3fb0, RIP: 0xffffffff815061b0] smp_apic_timer_interrupt (struct pt_regs * arg = 0xffff88082b847db8)
# 28: [RSP: 0xffff88082b847e60, RIP: 0xffffffff8100bc13] apic_timer_interrupt ()
# 29: [RSP: 0xffff88082b847ee0, RIP: 0xffffffff812cdc0e] intel_idle (struct cpuidle_device * arg = 0xffff8800456ddcc0, struct cpuidle_state * arg = 0xffff8800456dde50)
# 30: [RSP: 0xffff88082b847f00, RIP: 0xffffffff81407997] cpuidle_idle_call ()
Please feel free to submit any found issues via email or github.
11 years, 3 months
[PATCH] Make 'kmem -S' work on kernel 3.11
by Anatol Pomozov
Signed-off-by: Anatol Pomozov <anatol.pomozov(a)gmail.com>
---
memory.c | 26 +++++++++++++++++---------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/memory.c b/memory.c
index b57c1ed..56df54a 100755
--- a/memory.c
+++ b/memory.c
@@ -323,6 +323,7 @@ vm_init(void)
int i, len, dimension;
struct syment *sp_array[2];
ulong value1, value2;
+ char *kmem_cache_node_struct;
MEMBER_OFFSET_INIT(task_struct_mm, "task_struct", "mm");
MEMBER_OFFSET_INIT(mm_struct_mmap, "mm_struct", "mmap");
@@ -548,10 +549,12 @@ vm_init(void)
if (MEMBER_EXISTS("kmem_cache", "lists"))
MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", "lists");
- else if (MEMBER_EXISTS("kmem_cache", "nodelists")) {
+ else if (MEMBER_EXISTS("kmem_cache", "nodelists") ||
+ MEMBER_EXISTS("kmem_cache", "node")) {
+ char *nodelists_field = MEMBER_EXISTS("kmem_cache", "node") ? "node" : "nodelists";
vt->flags |= PERCPU_KMALLOC_V2_NODES;
- MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", "nodelists");
- if (MEMBER_TYPE("kmem_cache", "nodelists") == TYPE_CODE_PTR) {
+ MEMBER_OFFSET_INIT(kmem_cache_s_lists, "kmem_cache", nodelists_field);
+ if (MEMBER_TYPE("kmem_cache", nodelists_field) == TYPE_CODE_PTR) {
int nr_node_ids;
/*
* nodelists now a pointer to an outside array
@@ -563,9 +566,12 @@ vm_init(void)
vt->kmem_cache_len_nodes = nr_node_ids;
} else
vt->kmem_cache_len_nodes = 1;
- } else
+ } else {
+ // This should never happen with kmem_cache.node,
+ // only with kmem_cache.nodelists
ARRAY_LENGTH_INIT(vt->kmem_cache_len_nodes, NULL,
"kmem_cache.nodelists", NULL, 0);
+ }
}
MEMBER_OFFSET_INIT(kmem_cache_s_array, "kmem_cache", "array");
ARRAY_LENGTH_INIT(len, NULL, "kmem_cache.array", NULL, 0);
@@ -590,15 +596,17 @@ vm_init(void)
MEMBER_OFFSET_INIT(array_cache_limit, "array_cache", "limit");
STRUCT_SIZE_INIT(array_cache, "array_cache");
+ // kmem_list3 renamed to kmem_cache_node in kernel 3.10
+ kmem_cache_node_struct = STRUCT_EXISTS("kmem_cache_node") ? "kmem_cache_node" : "kmem_list3";
MEMBER_OFFSET_INIT(kmem_list3_slabs_partial,
- "kmem_list3", "slabs_partial");
+ kmem_cache_node_struct, "slabs_partial");
MEMBER_OFFSET_INIT(kmem_list3_slabs_full,
- "kmem_list3", "slabs_full");
+ kmem_cache_node_struct, "slabs_full");
MEMBER_OFFSET_INIT(kmem_list3_slabs_free,
- "kmem_list3", "slabs_free");
+ kmem_cache_node_struct, "slabs_free");
MEMBER_OFFSET_INIT(kmem_list3_free_objects,
- "kmem_list3", "free_objects");
- MEMBER_OFFSET_INIT(kmem_list3_shared, "kmem_list3", "shared");
+ kmem_cache_node_struct, "free_objects");
+ MEMBER_OFFSET_INIT(kmem_list3_shared, kmem_cache_node_struct, "shared");
} else if (MEMBER_EXISTS("kmem_cache", "cpu_slab") &&
STRUCT_EXISTS("kmem_cache_node")) {
vt->flags |= KMALLOC_SLUB;
--
1.8.3
11 years, 3 months
[PATCH] Make 'irq -d' work on x86 kernel 3.11-rc
by Anatol Pomozov
The scructure was renamed from gate_struct to gate_desc in 2.6.25 kernel
Tested: works on 3.11 dump
---
x86_64.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/x86_64.c b/x86_64.c
index 4264bae..3e2d5b4 100755
--- a/x86_64.c
+++ b/x86_64.c
@@ -298,7 +298,12 @@ x86_64_init(int when)
machdep->machspec->modules_end = MODULES_END_2_6_31;
}
STRUCT_SIZE_INIT(cpuinfo_x86, "cpuinfo_x86");
- STRUCT_SIZE_INIT(gate_struct, "gate_struct");
+ if (STRUCT_EXISTS("gate_desc")) {
+ STRUCT_SIZE_INIT(gate_struct, "gate_desc");
+ } else {
+ // before 2.6.25 the structure called gate_struct
+ STRUCT_SIZE_INIT(gate_struct, "gate_struct");
+ }
STRUCT_SIZE_INIT(e820map, "e820map");
STRUCT_SIZE_INIT(e820entry, "e820entry");
MEMBER_OFFSET_INIT(e820map_nr_map, "e820map", "nr_map");
--
1.8.3
11 years, 3 months
cannot load slab info from 3.11 dump because of invalid pointer in kmem_cache
by Anatol Pomozov
Hi,
Not clear if it is a 3.11 issue or just general memory corruption. But
I clearly cannot load slab information from any of my 3.11 dumps. Slab
info contain incorrect pointer and "crash" just drops all slab
information.
Crash expects that kmem_cache.array contains either valid pointer or
NULL. And most slabs indeed have valid data. But there is also struct
like below and crash says:
crash: invalid kernel virtual address: 28 type: "array cache limit"
Dave, do you have any pointer what it can be?
If this is a memory corruption in one of the slab, would it be better
if "crash" just skipped this slab (or marked it as 'fail to load') and
show info for the rest of caches?
struct kmem_cache {
batchcount = 16,
limit = 32,
shared = 8,
size = 64,
reciprocal_buffer_size = 67108864,
flags = 10240,
num = 59,
gfporder = 0,
allocflags = 0,
colour = 0,
colour_off = 64,
slabp_cache = 0x0 <irq_stack_union>,
slab_size = 320,
ctor = 0x0 <irq_stack_union>,
name = 0xffff88065786ea60 "fib6_nodes",
list = {
next = 0xffff880654d9d618,
prev = 0xffff880c50f24f98
},
refcount = 1,
object_size = 48,
align = 64,
num_active = 5,
num_allocations = 32,
high_mark = 20,
grown = 1,
reaped = 0,
errors = 0,
max_freeable = 0,
node_allocs = 0,
node_frees = 0,
node_overflow = 0,
allochit = {
counter = 3
},
allocmiss = {
counter = 2
},
freehit = {
counter = 0
},
freemiss = {
counter = 0
},
obj_offset = 0,
memcg_params = 0x0 <irq_stack_union>,
node = 0xffff880654da37b0,
array = {0xffff880654d68e00, 0xffff880654d69e00, 0xffff880654d6ae00,
0xffff880654da4e00, 0xffff880654da5e00, 0xffff880654da6e00,
0xffff880c50faee00, 0xffff880c50fb2e00, 0xffff880c51722e00,
0xffff880c51723e00, 0xffff880c4e83de00, 0xffff880c5172be00,
0xffff880654da7e00, 0xffff880654da8e00, 0xffff880654da9e00,
0xffff880654daae00, 0xffff880654dabe00, 0xffff880654dade00,
0xffff880c4e83ee00, 0xffff880c4e83fe00, 0xffff880c5172ae00,
0xffff880c51724e00, 0xffff880c50e69e00, 0xffff880c510b3e00,
0xffff880654e07a80, 0xffff880c4e903940, 0x24 <irq_stack_union+36>,
0xc000100003c1b, 0xe7e0 <ftrace_stack+2016>, 0x19
<irq_stack_union+25>, 0x1000200003c2a, 0x54670, 0x1fe
<irq_stack_union+510>, 0xc000100003c48, 0xe8d7 <ftrace_stack+2263>,
0xf <irq_stack_union+15>, 0xc000100003c57, 0xe8c0 <ftrace_stack+2240>,
0x17 <irq_stack_union+23>, 0x1000200003c66, 0x54870, 0x2a3
<irq_stack_union+675>, 0xc000100003c79, 0xe8a0 <ftrace_stack+2208>,
0x13 <irq_stack_union+19>, 0x19000100003c88, 0x0 <irq_stack_union>,
0x28 <irq_stack_union+40>, 0x1000200003c99, 0x54b20, 0x917
<irq_stack_union+2327>, 0xc000100003cab, 0xe8f0 <ftrace_stack+2288>,
0x16 <irq_stack_union+22>, 0x1000200003cba, 0x55440, 0x30
<irq_stack_union+48>, 0x1000200003cce, 0x55470, 0x2bb
<irq_stack_union+699>, 0xc000100003ce5, 0xe930 <ftrace_stack+2352>,
0x17 <irq_stack_union+23>, 0x1000200003cf4, 0x55730, 0x38
<irq_stack_union+56>, 0x1000200003d0a, 0x55770}
}
"crash" fails on array[26] that has value "0x24 <irq_stack_union+36>"
11 years, 3 months
[PATCH] PPC64: Support virtual to physical address translation (VTOP) for huge pages.
by Hari Bathini
Crash utility currently does not supporting virtual to physical address translation for huge pages on PPC64.
This patch tries to address this issue by providing address translation support for huge pages in 'vtop' command on PPC64.
Below are couple of outputs for address translation of huge pages on crash-7.0.1 (with Dave's patch for vtop issue on >=3.10 kernel)
#On kernel release 3.6.0-rc1
crash> set 8149
PID: 8149
COMMAND: "hugepage-mmap"
TASK: c000000079ce49f0 [THREAD_INFO: c00000007795c000]
CPU: 0
STATE: TASK_INTERRUPTIBLE
crash> vtop 0xefff0000000
VIRTUAL PHYSICAL
vtop: invalid kernel virtual address: 4000000079060000 type: "page table"
crash>
#On kernel release 3.11.0-rc2
crash> set 13011
PID: 13011
COMMAND: "hugepage-mmap"
TASK: c000000071600000 [THREAD_INFO: c000000078240000]
CPU: 0
STATE: TASK_INTERRUPTIBLE
crash> vtop 0x1efff0000000
VIRTUAL PHYSICAL
1efff0000000 (not mapped)
PAGE DIRECTORY: c000000002770000
L4: c000000002770df8 => 0
VMA START END FLAGS FILE
c000000024f13af0 1efff0000000 1f0000000000 4400fb /mnt/huge/hugepagefile
FILE: /mnt/huge/hugepagefile OFFSET: 0
crash>
In the two cases mentioned above, crash fails to convert huge pages to corresponding physical addresses.
Below are the outputs with this patch "applied"
#On kernel release 3.6.0-rc1
crash> vtop 0xefff0000000
VIRTUAL PHYSICAL
efff0000000 37000000
PAGE DIRECTORY: c00000007906f800
L4: c00000007906f870 => c00000007c588000
PMD: c00000007c58fff8 => 4000000079063798
HUGE PAGE: 37000000
PTE PHYSICAL FLAGS
dc008000393 37000000 (PRESENT|USER|COHERENT|DIRTY|ACCESSED)
VMA START END FLAGS FILE
c00000007bf3a140 efff0000000 f0000000000 4800fb /mnt/huge/hugepagefile
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
c00000007f380000 37000000 c00000007af00e88 0 2 3701000004018
crash>
#On kernel release 3.11.0-rc2
crash> vtop 0x1efff0000000
VIRTUAL PHYSICAL
1efff0000000 45000000
PAGE DIRECTORY: c000000002770000
L4: c000000002773df8 => c00000007ab80000
PMD: c00000007ab81f80 => 114008000393
HUGE PAGE: 45000000
PTE PHYSICAL FLAGS
114008000393 45000000 (PRESENT|USER|COHERENT|DIRTY|ACCESSED)
VMA START END FLAGS FILE
c000000024f13af0 1efff0000000 1f0000000000 4400fb /mnt/huge/hugepagefile
PAGE PHYSICAL MAPPING INDEX CNT FLAGS
c00000007f460000 45000000 c000000072ea0c70 0 2 1140400004018
crash>
With the patch applied huge pages could be converted to corresponding physical pages
from huge pte in 3.11 kernel and from huge page directory on 3.6 kernel respectively.
Though, there are couple of things still to be taken up (see TODOs).
1) Only base physical address is returned for a huge page as of now.
2) Appropraite offset in huge page directory to get the actual physical page for a given huge page.
Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
---
defs.h | 6 +++-
ppc64.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 92 insertions(+), 5 deletions(-)
diff --git a/defs.h b/defs.h
index 275697b..7196bc9 100755
--- a/defs.h
+++ b/defs.h
@@ -3494,7 +3494,11 @@ struct efi_memory_desc_t {
#define PTE_SHIFT_L4_BOOK3E_4K 24
#define PMD_MASKED_BITS_64K 0x1ff
-#define L4_OFFSET(vaddr) ((vaddr >> (machdep->machspec->l4_shift)) & 0x1ff)
+#define PD_HUGE 0x8000000000000000
+#define HUGE_PTE_MASK 0x03
+#define HUGEPD_SHIFT_MASK 0x3f
+#define L4_MASK (THIS_KERNEL_VERSION >= LINUX(3,10,0) ? 0xfff : 0x1ff)
+#define L4_OFFSET(vaddr) ((vaddr >> (machdep->machspec->l4_shift)) & L4_MASK)
#define PGD_OFFSET_L4(vaddr) \
((vaddr >> (machdep->machspec->l3_shift)) & (machdep->machspec->ptrs_per_l3 - 1))
diff --git a/ppc64.c b/ppc64.c
index 6f4f623..bf7def3 100755
--- a/ppc64.c
+++ b/ppc64.c
@@ -55,7 +55,51 @@ static int ppc64_get_cpu_map(void);
static void ppc64_clear_machdep_cache(void);
static void ppc64_vmemmap_init(void);
static int ppc64_get_kvaddr_ranges(struct vaddr_range *);
+static uint get_ptetype(ulong pte);
+static int is_hugepage(ulong pte);
+static int is_hugepd(ulong pte);
+static ulong hugepage_dir(ulong pte);
+static inline uint get_ptetype(ulong pte)
+{
+ uint pte_type = 0; /* 0: regular entry; 1: huge pte; 2: huge pd */
+
+ if (is_hugepage(pte))
+ pte_type = 1;
+ else if (is_hugepd(pte))
+ pte_type = 2;
+
+ return pte_type;
+}
+
+static int is_hugepage(ulong pte)
+{
+ /*
+ * leaf pte for huge page, bottom two bits != 00
+ */
+ return ((pte & HUGE_PTE_MASK) != 0x0);
+}
+
+static inline int is_hugepd(ulong pte)
+{
+ if (THIS_KERNEL_VERSION >= LINUX(3,10,0)) {
+ /*
+ * hugepd pointer, bottom two bits == 00 and next 4 bits
+ * indicate size of table
+ */
+ return (((pte & HUGE_PTE_MASK) == 0x0) &&
+ ((pte & HUGEPD_SHIFT_MASK) != 0));
+ } else
+ return ((pte & PD_HUGE) == 0x0);
+}
+
+static inline ulong hugepage_dir(ulong pte)
+{
+ if (THIS_KERNEL_VERSION >= LINUX(3,10,0))
+ return (ulong)(pte & ~HUGEPD_SHIFT_MASK);
+ else
+ return (ulong)((pte & ~HUGEPD_SHIFT_MASK) | PD_HUGE);
+}
static int book3e_is_kvaddr(ulong addr)
{
@@ -637,6 +681,7 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4, physaddr_t *paddr, int verbose)
ulong *page_table;
ulong level4_pte, pgd_pte, pmd_pte;
ulong pte;
+ uint hugepage_type = 0; /* 0: regular entry; 1: huge pte; 2: huge pd */
if (verbose)
fprintf(fp, "PAGE DIRECTORY: %lx\n", (ulong)level4);
@@ -649,6 +694,12 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4, physaddr_t *paddr, int verbose)
if (!level4_pte)
return FALSE;
+ hugepage_type = get_ptetype(level4_pte);
+ if (hugepage_type) {
+ pte = level4_pte;
+ goto out;
+ }
+
/* Sometimes we don't have level3 pagetable entries */
if (machdep->machspec->l3_index_size != 0) {
page_dir = (ulong *)((ulong *)level4_pte + PGD_OFFSET_L4(vaddr));
@@ -659,6 +710,12 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4, physaddr_t *paddr, int verbose)
fprintf(fp, " PGD: %lx => %lx\n", (ulong)page_dir, pgd_pte);
if (!pgd_pte)
return FALSE;
+
+ hugepage_type = get_ptetype(pgd_pte);
+ if (hugepage_type) {
+ pte = pgd_pte;
+ goto out;
+ }
} else {
pgd_pte = level4_pte;
}
@@ -673,6 +730,12 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4, physaddr_t *paddr, int verbose)
if (!(pmd_pte))
return FALSE;
+ hugepage_type = get_ptetype(pmd_pte);
+ if (hugepage_type) {
+ pte = pmd_pte;
+ goto out;
+ }
+
page_table = (ulong *)(pmd_pte & ~(machdep->machspec->l2_masked_bits))
+ (BTOP(vaddr) & (machdep->machspec->ptrs_per_l1 - 1));
if (verbose)
@@ -696,17 +759,37 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4, physaddr_t *paddr, int verbose)
if (!pte)
return FALSE;
- *paddr = PAGEBASE(PTOB(pte >> machdep->machspec->pte_shift))
- + PAGEOFFSET(vaddr);
+out:
+ if (hugepage_type) {
+ if (hugepage_type == 2) {
+ /* TODO: Calculate the offset within the huge page
+ * directory for this huge page to get corresponding
+ * physical address. In the current form, it may
+ * return the physical address of the first huge page
+ * in this directory for all the huge pages
+ * in this huge page directory.
+ */
+ readmem(hugepage_dir(pte), KVADDR, &pte, sizeof(pte),
+ "hugepd_entry", RETURN_ON_ERROR);
+ }
+ /* TODO: get page offset for huge pages based on page size */
+ *paddr = PAGEBASE(PTOB(pte >> machdep->machspec->pte_shift));
+ } else {
+ *paddr = PAGEBASE(PTOB(pte >> machdep->machspec->pte_shift))
+ + PAGEOFFSET(vaddr);
+ }
if (verbose) {
- fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr));
+ if (hugepage_type)
+ fprintf(fp, " HUGE PAGE: %lx\n\n", PAGEBASE(*paddr));
+ else
+ fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr));
ppc64_translate_pte(pte, 0, machdep->machspec->pte_shift);
}
return TRUE;
}
-
+
/*
* Translates a user virtual address to its physical address. cmd_vtop()
* sets the verbose flag so that the pte translation gets displayed; all
11 years, 3 months
Re: [Crash-utility] [PATCH] PPC64: Support virtual to physical address translation (VTOP) for huge pages. (Hari Bathini)
by Dave Anderson
Hari,
Thanks for looking into this. I'm currently on vacation and
and so I'll check out this patch next week.
Thanks,
Dave Anderson
>
> Crash utility currently does not supporting virtual to physical address
> translation for huge pages on PPC64.
> This patch tries to address this issue by providing address translation
> support for huge pages in 'vtop' command on PPC64.
> Below are couple of outputs for address translation of huge pages on
> crash-7.0.1 (with Dave's patch for vtop issue on >=3.10 kernel)
>
> #On kernel release 3.6.0-rc1
>
> crash> set 8149
> PID: 8149
> COMMAND: "hugepage-mmap"
> TASK: c000000079ce49f0 [THREAD_INFO: c00000007795c000]
> CPU: 0
> STATE: TASK_INTERRUPTIBLE
> crash> vtop 0xefff0000000
> VIRTUAL PHYSICAL
> vtop: invalid kernel virtual address: 4000000079060000 type: "page table"
> crash>
>
>
> #On kernel release 3.11.0-rc2
>
> crash> set 13011
> PID: 13011
> COMMAND: "hugepage-mmap"
> TASK: c000000071600000 [THREAD_INFO: c000000078240000]
> CPU: 0
> STATE: TASK_INTERRUPTIBLE
> crash> vtop 0x1efff0000000
> VIRTUAL PHYSICAL
> 1efff0000000 (not mapped)
>
> PAGE DIRECTORY: c000000002770000
> L4: c000000002770df8 => 0
>
> VMA START END FLAGS FILE
> c000000024f13af0 1efff0000000 1f0000000000 4400fb
> /mnt/huge/hugepagefile
>
> FILE: /mnt/huge/hugepagefile OFFSET: 0
>
> crash>
>
> In the two cases mentioned above, crash fails to convert huge pages to
> corresponding physical addresses.
> Below are the outputs with this patch "applied"
>
> #On kernel release 3.6.0-rc1
>
> crash> vtop 0xefff0000000
> VIRTUAL PHYSICAL
> efff0000000 37000000
>
> PAGE DIRECTORY: c00000007906f800
> L4: c00000007906f870 => c00000007c588000
> PMD: c00000007c58fff8 => 4000000079063798
> HUGE PAGE: 37000000
>
> PTE PHYSICAL FLAGS
> dc008000393 37000000 (PRESENT|USER|COHERENT|DIRTY|ACCESSED)
>
> VMA START END FLAGS FILE
> c00000007bf3a140 efff0000000 f0000000000 4800fb
> /mnt/huge/hugepagefile
>
> PAGE PHYSICAL MAPPING INDEX CNT FLAGS
> c00000007f380000 37000000 c00000007af00e88 0 2 3701000004018
> crash>
>
> #On kernel release 3.11.0-rc2
>
> crash> vtop 0x1efff0000000
> VIRTUAL PHYSICAL
> 1efff0000000 45000000
>
> PAGE DIRECTORY: c000000002770000
> L4: c000000002773df8 => c00000007ab80000
> PMD: c00000007ab81f80 => 114008000393
> HUGE PAGE: 45000000
>
> PTE PHYSICAL FLAGS
> 114008000393 45000000 (PRESENT|USER|COHERENT|DIRTY|ACCESSED)
>
> VMA START END FLAGS FILE
> c000000024f13af0 1efff0000000 1f0000000000 4400fb
> /mnt/huge/hugepagefile
>
> PAGE PHYSICAL MAPPING INDEX CNT FLAGS
> c00000007f460000 45000000 c000000072ea0c70 0 2 1140400004018
> crash>
>
> With the patch applied huge pages could be converted to corresponding
> physical pages
> from huge pte in 3.11 kernel and from huge page directory on 3.6 kernel
> respectively.
> Though, there are couple of things still to be taken up (see TODOs).
> 1) Only base physical address is returned for a huge page as of now.
> 2) Appropraite offset in huge page directory to get the actual physical
> page for a given huge page.
>
> Signed-off-by: Hari Bathini <hbathini(a)linux.vnet.ibm.com>
> ---
> defs.h | 6 +++-
> ppc64.c | 91
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
> 2 files changed, 92 insertions(+), 5 deletions(-)
>
> diff --git a/defs.h b/defs.h
> index 275697b..7196bc9 100755
> --- a/defs.h
> +++ b/defs.h
> @@ -3494,7 +3494,11 @@ struct efi_memory_desc_t {
> #define PTE_SHIFT_L4_BOOK3E_4K 24
> #define PMD_MASKED_BITS_64K 0x1ff
>
> -#define L4_OFFSET(vaddr) ((vaddr >> (machdep->machspec->l4_shift)) &
> 0x1ff)
> +#define PD_HUGE 0x8000000000000000
> +#define HUGE_PTE_MASK 0x03
> +#define HUGEPD_SHIFT_MASK 0x3f
> +#define L4_MASK (THIS_KERNEL_VERSION >= LINUX(3,10,0) ? 0xfff :
> 0x1ff)
> +#define L4_OFFSET(vaddr) ((vaddr >> (machdep->machspec->l4_shift)) &
> L4_MASK)
>
> #define PGD_OFFSET_L4(vaddr) \
> ((vaddr >> (machdep->machspec->l3_shift)) &
> (machdep->machspec->ptrs_per_l3 - 1))
> diff --git a/ppc64.c b/ppc64.c
> index 6f4f623..bf7def3 100755
> --- a/ppc64.c
> +++ b/ppc64.c
> @@ -55,7 +55,51 @@ static int ppc64_get_cpu_map(void);
> static void ppc64_clear_machdep_cache(void);
> static void ppc64_vmemmap_init(void);
> static int ppc64_get_kvaddr_ranges(struct vaddr_range *);
> +static uint get_ptetype(ulong pte);
> +static int is_hugepage(ulong pte);
> +static int is_hugepd(ulong pte);
> +static ulong hugepage_dir(ulong pte);
>
> +static inline uint get_ptetype(ulong pte)
> +{
> + uint pte_type = 0; /* 0: regular entry; 1: huge pte; 2: huge pd */
> +
> + if (is_hugepage(pte))
> + pte_type = 1;
> + else if (is_hugepd(pte))
> + pte_type = 2;
> +
> + return pte_type;
> +}
> +
> +static int is_hugepage(ulong pte)
> +{
> + /*
> + * leaf pte for huge page, bottom two bits != 00
> + */
> + return ((pte & HUGE_PTE_MASK) != 0x0);
> +}
> +
> +static inline int is_hugepd(ulong pte)
> +{
> + if (THIS_KERNEL_VERSION >= LINUX(3,10,0)) {
> + /*
> + * hugepd pointer, bottom two bits == 00 and next 4 bits
> + * indicate size of table
> + */
> + return (((pte & HUGE_PTE_MASK) == 0x0) &&
> + ((pte & HUGEPD_SHIFT_MASK) != 0));
> + } else
> + return ((pte & PD_HUGE) == 0x0);
> +}
> +
> +static inline ulong hugepage_dir(ulong pte)
> +{
> + if (THIS_KERNEL_VERSION >= LINUX(3,10,0))
> + return (ulong)(pte & ~HUGEPD_SHIFT_MASK);
> + else
> + return (ulong)((pte & ~HUGEPD_SHIFT_MASK) | PD_HUGE);
> +}
>
> static int book3e_is_kvaddr(ulong addr)
> {
> @@ -637,6 +681,7 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4,
> physaddr_t *paddr, int verbose)
> ulong *page_table;
> ulong level4_pte, pgd_pte, pmd_pte;
> ulong pte;
> + uint hugepage_type = 0; /* 0: regular entry; 1: huge pte; 2: huge pd */
>
> if (verbose)
> fprintf(fp, "PAGE DIRECTORY: %lx\n", (ulong)level4);
> @@ -649,6 +694,12 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4,
> physaddr_t *paddr, int verbose)
> if (!level4_pte)
> return FALSE;
>
> + hugepage_type = get_ptetype(level4_pte);
> + if (hugepage_type) {
> + pte = level4_pte;
> + goto out;
> + }
> +
> /* Sometimes we don't have level3 pagetable entries */
> if (machdep->machspec->l3_index_size != 0) {
> page_dir = (ulong *)((ulong *)level4_pte + PGD_OFFSET_L4(vaddr));
> @@ -659,6 +710,12 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4,
> physaddr_t *paddr, int verbose)
> fprintf(fp, " PGD: %lx => %lx\n", (ulong)page_dir, pgd_pte);
> if (!pgd_pte)
> return FALSE;
> +
> + hugepage_type = get_ptetype(pgd_pte);
> + if (hugepage_type) {
> + pte = pgd_pte;
> + goto out;
> + }
> } else {
> pgd_pte = level4_pte;
> }
> @@ -673,6 +730,12 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4,
> physaddr_t *paddr, int verbose)
> if (!(pmd_pte))
> return FALSE;
>
> + hugepage_type = get_ptetype(pmd_pte);
> + if (hugepage_type) {
> + pte = pmd_pte;
> + goto out;
> + }
> +
> page_table = (ulong *)(pmd_pte & ~(machdep->machspec->l2_masked_bits))
> + (BTOP(vaddr) & (machdep->machspec->ptrs_per_l1 - 1));
> if (verbose)
> @@ -696,17 +759,37 @@ ppc64_vtop_level4(ulong vaddr, ulong *level4,
> physaddr_t *paddr, int verbose)
> if (!pte)
> return FALSE;
>
> - *paddr = PAGEBASE(PTOB(pte >> machdep->machspec->pte_shift))
> - + PAGEOFFSET(vaddr);
> +out:
> + if (hugepage_type) {
> + if (hugepage_type == 2) {
> + /* TODO: Calculate the offset within the huge page
> + * directory for this huge page to get corresponding
> + * physical address. In the current form, it may
> + * return the physical address of the first huge page
> + * in this directory for all the huge pages
> + * in this huge page directory.
> + */
> + readmem(hugepage_dir(pte), KVADDR, &pte, sizeof(pte),
> + "hugepd_entry", RETURN_ON_ERROR);
> + }
> + /* TODO: get page offset for huge pages based on page size */
> + *paddr = PAGEBASE(PTOB(pte >> machdep->machspec->pte_shift));
> + } else {
> + *paddr = PAGEBASE(PTOB(pte >> machdep->machspec->pte_shift))
> + + PAGEOFFSET(vaddr);
> + }
>
> if (verbose) {
> - fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr));
> + if (hugepage_type)
> + fprintf(fp, " HUGE PAGE: %lx\n\n", PAGEBASE(*paddr));
> + else
> + fprintf(fp, " PAGE: %lx\n\n", PAGEBASE(*paddr));
> ppc64_translate_pte(pte, 0, machdep->machspec->pte_shift);
> }
>
> return TRUE;
> }
> -
> +
> /*
> * Translates a user virtual address to its physical address.
> cmd_vtop()
> * sets the verbose flag so that the pte translation gets displayed; all
>
>
>
> ------------------------------
>
> --
> Crash-utility mailing list
> Crash-utility(a)redhat.com
> https://www.redhat.com/mailman/listinfo/crash-utility
>
> End of Crash-utility Digest, Vol 95, Issue 3
> ********************************************
>
>
11 years, 3 months
[PATCH] Parse two number kernel versions i.e. 3.8
by Troy Heber
Hello Dave,
A Debian user, Timo Juhani Lindfors <timo.lindfors(a)iki.fi>, reported
this issue that and delivered the patch to resolve it. The original
strcpy is being called with overlapping arguments because it is
expecting an additional version number.
Troy
---
diff -urpN -urN ori/kernel.c new/kernel.c
--- ori/kernel.c 2013-08-01 11:40:01.299157220 -0600
+++ new/kernel.c 2013-08-01 11:42:12.506364789 -0600
@@ -218,21 +218,29 @@ kernel_init()
strncpy(buf, kt->utsname.release, MIN(strlen(kt->utsname.release), 65));
if (ascii_string(kt->utsname.release)) {
+ char separator;
+
p1 = p2 = buf;
while (*p2 != '.')
p2++;
*p2 = NULLCHAR;
kt->kernel_version[0] = atoi(p1);
p1 = ++p2;
- while (*p2 != '.')
+ while (*p2 != '.' && *p2 != '-' && *p2 != '\0')
p2++;
+ separator = *p2;
*p2 = NULLCHAR;
kt->kernel_version[1] = atoi(p1);
- p1 = ++p2;
- while ((*p2 >= '0') && (*p2 <= '9'))
- p2++;
- *p2 = NULLCHAR;
- kt->kernel_version[2] = atoi(p1);
+ *p2 = separator;
+ if (*p2 == '.') {
+ p1 = ++p2;
+ while ((*p2 >= '0') && (*p2 <= '9'))
+ p2++;
+ *p2 = NULLCHAR;
+ kt->kernel_version[2] = atoi(p1);
+ } else {
+ kt->kernel_version[2] = 0;
+ }
if (CRASHDEBUG(1))
fprintf(fp, "base kernel version: %d.%d.%d\n",
11 years, 3 months