tracing: improve symbolic printing
Subsystems (7)
v5 cover tracing: improve symbolic printing
v2 was:
- rebased on 6.9-rc1
- always search for __print_sym() and get rid of the DYNPRINT flag and associated code; I think ideally we'll just remove the older __print_symbolic() entirely
- use ':' as the separator instead of "//" since that makes searching for it much easier and it's still not a valid char in an identifier
- fix RCU
v3:
- fix #undef issues
- fix drop_monitor default
- rebase on linux-trace/for-next (there were no conflicts)
- move net patches to 3/4
- clarify symbol name matching logic (and remove ")" from it)
v4:
- fix non-module build and possibly dynamic event handling
v5:
- fix build warning in non-module build
To recap, it's annoying to have
irq/65-iwlwifi:-401 [000] 22.790000: kfree_skb: ... reason: 0x20000
and much nicer to see
irq/65-iwlwifi:-401 [000] 22.790000: kfree_skb: ... reason: RX_DROP_MONITOR
but this doesn't work now because __print_symbolic() can only deal with a hard-coded list (which is actually really big.)
So here's __print_sym() which doesn't build the list into the kernel image, but creates it at runtime. For userspace, it will look the same as __print_symbolic() (it literally shows __print_symbolic() to userspace) so no changes are needed, but the actual list of values exposed to userspace in there is built dynamically. For SKB drop reasons, this then has all the reasons known when userspace queries the trace format.
I guess patch 3/4 should go through net-next, so not sure how to handle this patch series. Or perhaps, as this will not cause conflicts, in fact I've been rebasing it for a long time, go through tracing anyway with an Ack from netdev? But I can also just wait for the trace patch(es) to land and resubmit the net patches after. Assuming this looks good at all :-)
Thanks,
johannes
PATCH v5 1/4 tracing: add __print_sym() to replace __print_symbolic()
From: Johannes Berg <[email protected]>
The way __print_symbolic() works is limited and inefficient in multiple ways:
- you can only use it with a static list of symbols, but e.g. the SKB dropreasons are now a dynamic list
- it builds the list in memory _three_ times, so it takes a lot of memory:
- The print_fmt contains the list (since it's passed to the macro there). This actually contains the names _twice_, which is fixed up at runtime.
- TRACE_DEFINE_ENUM() puts a 24-byte struct trace_eval_map for every entry, plus the string pointed to by it, which cannot be deduplicated with the strings in the print_fmt
- The in-kernel symbolic printing creates yet another list of struct trace_print_flags for trace_print_symbols_seq()
- it also requires runtime fixup during init, which is a lot of string parsing due to the print_fmt fixup
Introduce __print_sym() to - over time - replace the old one. We can easily extend this also to __print_flags later, but I cared only about the SKB dropreasons for now, which has only __print_symbolic().
This new __print_sym() requires only a single list of items, created by TRACE_DEFINE_SYM_LIST(), or can even use another already existing list by using TRACE_DEFINE_SYM_FNS() with lookup and show methods.
Then, instead of doing an init-time fixup, just do this at the time when userspace reads the print_fmt. This way, dynamically updated lists are possible.
For userspace, nothing actually changes, because the print_fmt is shown exactly the same way the old __print_symbolic() was.
This adds about 4k .text in my test builds, but that'll be more than paid for by the actual conversions.
---
v2:
- fix RCU
- use ':' as separator to simplify the code, that's still not valid in a C identifier
v3:
- add missing #undef lines (reported by Simon Horman)
- clarify name is not NUL-terminated and fix logic for the comparison for that
v4:
- fix non-modular builds and handle TRACE_EVENT_FL_DYNAMIC
v5:
- fix build warning in non-modular build
--- include/asm-generic/vmlinux.lds.h | 3 +- include/linux/module.h | 2 + include/linux/trace_events.h | 7 ++ include/linux/tracepoint.h | 20 +++++ include/trace/stages/init.h | 55 ++++++++++++ include/trace/stages/stage2_data_offsets.h | 6 ++ include/trace/stages/stage3_trace_output.h | 9 ++ include/trace/stages/stage7_class_define.h | 3 + kernel/module/main.c | 3 + kernel/trace/trace_events.c | 99 +++++++++++++++++++++- kernel/trace/trace_output.c | 45 ++++++++++ 11 files changed, 249 insertions(+), 3 deletions(-)
include/asm-generic/vmlinux.lds.h +2 -1
@@ -258,7 +258,8 @@#define FTRACE_EVENTS () \ . = ALIGN(8); \ BOUNDED_SECTION(_ftrace_events) \ - BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps) + BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps) \ + BOUNDED_SECTION(_ftrace_sym_defs)#else #define FTRACE_EVENTS ()#endif
include/linux/module.h +2 -0
@@ -524,6 +524,8 @@ struct module {unsigned int num_trace_events;struct trace_eval_map **trace_evals;unsigned int num_trace_evals; +struct trace_sym_def **trace_sym_defs; +unsigned int num_trace_sym_defs;#endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD unsigned int num_ftrace_callsites;
include/linux/trace_events.h +7 -0
@@ -27,6 +27,13 @@ const char *trace_print_flags_seq(struct trace_seq *p, const char *delim,const char *trace_print_symbols_seq (struct trace_seq *p,unsigned long val,const struct trace_print_flags *symbol_array); +const char *trace_print_sym_seq (struct trace_seq *p,unsigned long long val, +const char *(*lookup)(unsigned long long val)); +const char *trace_sym_lookup (const struct trace_sym_entry *list, +size_t len,unsigned long long value); +void trace_sym_show (struct seq_file *m, +const struct trace_sym_entry *list,size_t len); +#if BITS_PER_LONG ==32 const char *trace_print_flags_seq_u64(struct trace_seq *p, const char *delim, unsigned long long flags,
include/linux/tracepoint.h +20 -0
@@ -31,6 +31,24 @@ struct trace_eval_map {unsigned long eval_value; }; +struct trace_sym_def { +const char *system; +const char *symbol_id; +/* may return NULL, called under rcu_read_lock() */ +const char * (*lookup)(unsigned long long ); +/* +* Must print the list: ', { val, "name"}, ...' +* with no trailing comma, but with the leading ', ' +* to simplify things: +*/ +void (*show)(struct seq_file *); +}; + +struct trace_sym_entry { +unsigned long long value; +const char *name; +}; +#define TRACEPOINT_DEFAULT_PRIO 10extern struct srcu_struct tracepoint_srcu;
@@ -109,6 +127,8 @@ extern void syscall_unregfunc(void);#define TRACE_DEFINE_ENUM (x)#define TRACE_DEFINE_SIZEOF (x) +#define TRACE_DEFINE_SYM_FNS (...) +#define TRACE_DEFINE_SYM_LIST (...)#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS static inline struct tracepoint *tracepoint_ptr_deref (tracepoint_ptr_t *p)
include/trace/stages/init.h +55 -0
61 lines not on this page · raw message
include/trace/stages/stage2_data_offsets.h +6 -0
@@ -5,6 +5,12 @@#undef TRACE_DEFINE_ENUM#define TRACE_DEFINE_ENUM (a) +#undef TRACE_DEFINE_SYM_FNS +#define TRACE_DEFINE_SYM_FNS (_symbol_id, _lookup, _show) + +#undef TRACE_DEFINE_SYM_LIST +#define TRACE_DEFINE_SYM_LIST (_symbol_id, ...) +#undef TRACE_DEFINE_SIZEOF#define TRACE_DEFINE_SIZEOF (a)
include/trace/stages/stage3_trace_output.h +9 -0
@@ -79,6 +79,15 @@trace_print_symbols_seq (p, value, symbols); \ }) +#undef __print_sym +#define __print_sym (value, symbol_id) \ + ___print_sym(TRACE_SYSTEM, value, symbol_id) +#define ___print_sym (sys, value, symbol_id) \ + ____print_sym(sys, value, symbol_id) +#define ____print_sym (sys, value, symbol_id) \ + trace_print_sym_seq(p, value, \ + __trace_sym_def_p_ ## sys ## _ ## symbol_id->lookup) +#undef __print_flags_u64#undef __print_symbolic_u64#if BITS_PER_LONG ==32
include/trace/stages/stage7_class_define.h +3 -0
@@ -25,6 +25,9 @@#undef __print_hex_dump#undef __get_buf +#undef __print_sym +#define __print_sym (value, symbol_id) __print_sym(value:symbol_id) +/* * The below is not executed in the kernel. It is only what is * displayed in the print format for userspace to parse.
kernel/module/main.c +3 -0
@@ -2179,6 +2179,9 @@ static int find_module_sections(struct module *mod, struct load_info *info) mod->trace_evals =section_objs (info,"_ftrace_eval_map" ,sizeof (*mod->trace_evals), &mod->num_trace_evals); + mod->trace_sym_defs =section_objs (info,"_ftrace_sym_defs" , +sizeof (*mod->trace_sym_defs), + &mod->num_trace_sym_defs);#endif #ifdef CONFIG_TRACING mod->trace_bprintk_fmt_start = section_objs(info, "__trace_printk_fmt",
kernel/trace/trace_events.c +97 -2
111 lines not on this page · raw message
kernel/trace/trace_output.c +45 -0
51 lines not on this page · raw message
Signature · 1 line
2.45.2
PATCH v5 2/4 tracing/timer: use __print_sym()
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Use the new __print_sym() in the timer tracing, just to show how to convert something. This adds ~80 bytes of .text for a saving of ~1.5K of data in my builds.
Note the format changes from
print fmt: "success=%d dependency=%s", REC->success, __print_symbolic(REC->dependency, { 0, "NONE" }, { (1 << 0), "POSIX_TIMER" }, { (1 << 1), "PERF_EVENTS" }, { (1 << 2), "SCHED" }, { (1 << 3), "CLOCK_UNSTABLE" }, { (1 << 4), "RCU" }, { (1 << 5), "RCU_EXP" })
to
print fmt: "success=%d dependency=%s", REC->success, __print_symbolic(REC->dependency, { 0, "NONE" }, { 1, "POSIX_TIMER" }, { 2, "PERF_EVENTS" }, { 4, "SCHED" }, { 8, "CLOCK_UNSTABLE" }, { 16, "RCU" }, { 32, "RCU_EXP" })
since the values are now just printed in the show function as pure decimal values.
--- include/trace/events/timer.h | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-)
include/trace/events/timer.h +7 -15
@@ -402,26 +402,18 @@ TRACE_EVENT(itimer_expire,#undef tick_dep_mask_name#undef tick_dep_name_end -/* The MASK will convert to their bits and they need to be processed too */ -#define tick_dep_name (sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \ - TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep); -#define tick_dep_name_end (sdep) TRACE_DEFINE_ENUM(TICK_DEP_BIT_##sdep); \ - TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep); -/* NONE only has a mask defined for it */ -#define tick_dep_mask_name (sdep) TRACE_DEFINE_ENUM(TICK_DEP_MASK_##sdep); - -TICK_DEP_NAMES - -#undef tick_dep_name -#undef tick_dep_mask_name -#undef tick_dep_name_end -#define tick_dep_name (sdep) { TICK_DEP_MASK_##sdep, #sdep },#define tick_dep_mask_name (sdep) { TICK_DEP_MASK_##sdep, #sdep },#define tick_dep_name_end (sdep) { TICK_DEP_MASK_##sdep, #sdep } +TRACE_DEFINE_SYM_LIST (tick_dep_names,TICK_DEP_NAMES ); + +#undef tick_dep_name +#undef tick_dep_mask_name +#undef tick_dep_name_end +#define show_tick_dep_name (val) \ - __print_symbolic(val, TICK_DEP_NAMES) + __print_sym(val, tick_dep_names) TRACE_EVENT(tick_stop,
Signature · 1 line
2.45.2
PATCH v5 3/4 net: dropreason: use new __print_sym() in tracing
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
The __print_symbolic() could only ever print the core drop reasons, since that's the way the infrastructure works. Now that we have __print_sym() with all the advantages mentioned in that commit, convert to that and get all the drop reasons from all subsystems. As we already have a list of them, that's really easy.
This is a little bit of .text (~100 bytes in my build) and saves a lot of .data (~17k).
--- include/net/dropreason.h | 5 +++++ include/trace/events/skb.h | 16 +++----------- net/core/skbuff.c | 43 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 13 deletions(-)
include/net/dropreason.h +5 -0
@@ -42,6 +42,11 @@ struct drop_reason_list {extern const struct drop_reason_list __rcu * drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM ]; +#ifdef CONFIG_TRACEPOINTS +const char *drop_reason_lookup (unsigned long long value); +void drop_reason_show (struct seq_file *m); +#endif +void drop_reasons_register_subsys (enum skb_drop_reason_subsys subsys,const struct drop_reason_list *list);void drop_reasons_unregister_subsys (enum skb_drop_reason_subsys subsys);
include/trace/events/skb.h +3 -13
@@ -8,15 +8,9 @@#include <linux/skbuff.h> #include <linux/netdevice.h> #include <linux/tracepoint.h> +#include <net/dropreason.h> -#undef FN -#define FN (reason) TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason); -DEFINE_DROP_REASON(FN, FN) - -#undef FN -#undef FNe -#define FN (reason) { SKB_DROP_REASON_##reason, #reason }, -#define FNe (reason) { SKB_DROP_REASON_##reason, #reason } +TRACE_DEFINE_SYM_FNS (drop_reason, drop_reason_lookup, drop_reason_show);/* * Tracepoint for free an sk_buff:
@@ -44,13 +38,9 @@ TRACE_EVENT(kfree_skb,TP_printk ("skbaddr=%p protocol=%u location=%pS reason: %s" , __entry->skbaddr, __entry->protocol, __entry->location, -__print_symbolic (__entry->reason, -DEFINE_DROP_REASON (FN , FNe))) +__print_sym (__entry->reason, drop_reason )) ); -#undef FN -#undef FNe - TRACE_EVENT(consume_skb, TP_PROTO(struct sk_buff *skb, void *location),
net/core/skbuff.c +43 -0
49 lines not on this page · raw message
Signature · 1 line
2.45.2
Paolo Abeni
maintainerRe: [PATCH v5 3/4] net: dropreason: use new __print_sym() in tracing
Quoted 58 lines · Johannes Berg
From: Johannes Berg <[email protected]>
The
__print_symbolic()could only ever print the core drop reasons, since that's the way the infrastructure works. Now that we have__print_sym()with all the advantages mentioned in that commit, convert to that and get all the drop reasons from all subsystems. As we already have a list of them, that's really easy.This is a little bit of .text (~100 bytes in my build) and saves a lot of .data (~17k).
Signed-off-by Johannes Berg <[email protected]>--- include/net/dropreason.h | 5 +++++ include/trace/events/skb.h | 16 +++----------- net/core/skbuff.c | 43 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 13 deletions(-)include/net/dropreason.h +5
-0@@ -42,6 +42,11 @@ struct drop_reason_list {extern const struct drop_reason_list __rcu * drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM ]; +#ifdef CONFIG_TRACEPOINTS +const char *drop_reason_lookup (unsigned long long value); +void drop_reason_show (struct seq_file *m); +#endif +void drop_reasons_register_subsys (enum skb_drop_reason_subsys subsys,const struct drop_reason_list *list);void drop_reasons_unregister_subsys (enum skb_drop_reason_subsys subsys);include/trace/events/skb.h +2
-8@@ -8,15 +8,9 @@#include <linux/skbuff.h> #include <linux/netdevice.h> #include <linux/tracepoint.h> +#include <net/dropreason.h> -#undef FN -#define FN (reason) TRACE_DEFINE_ENUM(SKB_DROP_REASON_##reason); -DEFINE_DROP_REASON(FN, FN) - -#undef FN -#undef FNe -#define FN (reason) { SKB_DROP_REASON_##reason, #reason }, -#define FNe (reason) { SKB_DROP_REASON_##reason, #reason } +TRACE_DEFINE_SYM_FNS (drop_reason, drop_reason_lookup, drop_reason_show);/* * Tracepoint for free an sk_buff:
include/trace/events/skb.h TRACE_EVENT(kfree_skb, · line 41
Quoted 6 lines
include/trace/events/skb.h +1
-2@@ -44,13 +38,9 @@ TRACE_EVENT(kfree_skb,TP_printk ("skbaddr=%p protocol=%u location=%pS reason: %s" , __entry->skbaddr, __entry->protocol, __entry->location, -__print_symbolic (__entry->reason, -DEFINE_DROP_REASON (FN , FNe))) +__print_sym (__entry->reason, drop_reason ))
Minor nit: if you have to repost for other reasons, ^^ here
checkpatch complains for the extra space.
Otherwise LGTM,
Thanks!
Paolo
PATCH v5 4/4 net: drop_monitor: use drop_reason_lookup()
In reply to Johannes BergFrom: Johannes Berg <[email protected]>
Now that we have drop_reason_lookup(), we can just use it for drop_monitor as well, rather than exporting the list itself.
---
v3:
- look up SKB_DROP_REASON_NOT_SPECIFIED if initial lookup returns NULL, to preserve previous behaviour
--- include/net/dropreason.h | 4 ---- net/core/drop_monitor.c | 20 +++++--------------- net/core/skbuff.c | 6 +++--- 3 files changed, 8 insertions(+), 22 deletions(-)
include/net/dropreason.h +0 -4
@@ -38,10 +38,6 @@ struct drop_reason_list {size_t n_reasons; }; -/* Note: due to dynamic registrations, access must be under RCU */ -extern const struct drop_reason_list __rcu * -drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM ]; -#ifdef CONFIG_TRACEPOINTS const char *drop_reason_lookup (unsigned long long value);void drop_reason_show (struct seq_file *m);
net/core/drop_monitor.c +5 -15
@@ -610,9 +610,8 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, size_t payload_len) {struct net_dm_skb_cb *cb =NET_DM_SKB_CB (skb); -const struct drop_reason_list *list =NULL ; -unsigned int subsys, subsys_reason;char buf[NET_DM_MAX_SYMBOL_LEN ]; +const char *reason_str;struct nlattr *attr;void *hdr;int rc;
@@ -630,19 +629,10 @@ static int net_dm_packet_report_fill(struct sk_buff *msg, struct sk_buff *skb, goto nla_put_failure;rcu_read_lock (); - subsys =u32_get_bits (cb->reason,SKB_DROP_REASON_SUBSYS_MASK ); -if (subsys <SKB_DROP_REASON_SUBSYS_NUM ) - list =rcu_dereference (drop_reasons_by_subsys[subsys]); - subsys_reason = cb->reason & ~SKB_DROP_REASON_SUBSYS_MASK ; -if (!list || - subsys_reason >= list->n_reasons || - !list->reasons[subsys_reason] || -strlen (list->reasons[subsys_reason]) >NET_DM_MAX_REASON_LEN ) { - list =rcu_dereference (drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_CORE ]); - subsys_reason =SKB_DROP_REASON_NOT_SPECIFIED ; - } -if (nla_put_string (msg,NET_DM_ATTR_REASON , - list->reasons[subsys_reason])) { + reason_str =drop_reason_lookup (cb->reason); +if (unlikely (!reason_str)) + reason_str =drop_reason_lookup (SKB_DROP_REASON_NOT_SPECIFIED ); +if (nla_put_string (msg,NET_DM_ATTR_REASON , reason_str)) {rcu_read_unlock (); goto nla_put_failure; }
net/core/skbuff.c +3 -3
@@ -139,13 +139,11 @@ static const struct drop_reason_list drop_reasons_core = { .n_reasons = ARRAY_SIZE(drop_reasons), }; -const struct drop_reason_list __rcu * +static const struct drop_reason_list __rcu * drop_reasons_by_subsys[SKB_DROP_REASON_SUBSYS_NUM ] = { [SKB_DROP_REASON_SUBSYS_CORE ] =RCU_INITIALIZER (&drop_reasons_core), }; -EXPORT_SYMBOL (drop_reasons_by_subsys); -#ifdef CONFIG_TRACEPOINTS const char *drop_reason_lookup (unsigned long long value) {unsigned long long subsys_id = value >>SKB_DROP_REASON_SUBSYS_SHIFT ;
@@ -162,7 +160,9 @@ const char *drop_reason_lookup(unsigned long long value)return NULL ;return subsys->reasons[reason]; } +EXPORT_SYMBOL (drop_reason_lookup); +#ifdef CONFIG_TRACEPOINTS void drop_reason_show (struct seq_file *m) {u32 subsys_id;
Signature · 1 line
2.45.2
Steven Rostedt
maintainerHi Johannes,
I finally got around to testing your patches.
I did the following:
# cat /sys/kernel/tracing/events/*/*/format
and hit this:
BUG: unable to handle page fault for address: ffffffff8e6333d0 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 183c40067 P4D 183c40067 PUD 183c41063 PMD 1003ef063 PTE 800ffffe7b9cc062 Oops: Oops: 0000 [#1] PREEMPT SMP PTI CPU: 7 UID: 0 PID: 893 Comm: cat Not tainted 6.11.0-rc4-test-00004-g4ce2836f008b #56 68afcee1248519f8b3b088836c40746e4a6b69d3 Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:f_show (kernel/trace/trace_events.c:1601 kernel/trace/trace_events.c:1651 kernel/trace/trace_events.c:1689) Code: 33 63 8e 48 2d d0 33 63 8e 48 c1 f8 03 85 c0 74 67 89 c0 4c 89 c3 49 8d 04 c0 48 89 04 24 eb 0a 48 83 c3 08 48 39 1c 24 74 4e <4c> 8b 3b 4d 85 ff 74 ee 49 8b 45 10 48 8b 00 49 39 07 75 e2 49 8b All code ======== 0: 33 63 8e xor -0x72(%rbx),%esp 3: 48 2d d0 33 63 8e sub $0xffffffff8e6333d0,%rax 9: 48 c1 f8 03 sar $0x3,%rax d: 85 c0 test %eax,%eax f: 74 67 je 0x78 11: 89 c0 mov %eax,%eax 13: 4c 89 c3 mov %r8,%rbx 16: 49 8d 04 c0 lea (%r8,%rax,8),%rax 1a: 48 89 04 24 mov %rax,(%rsp) 1e: eb 0a jmp 0x2a 20: 48 83 c3 08 add $0x8,%rbx 24: 48 39 1c 24 cmp %rbx,(%rsp) 28: 74 4e je 0x78 2a:* 4c 8b 3b mov (%rbx),%r15 <-- trapping instruction 2d: 4d 85 ff test %r15,%r15 30: 74 ee je 0x20 32: 49 8b 45 10 mov 0x10(%r13),%rax 36: 48 8b 00 mov (%rax),%rax 39: 49 39 07 cmp %rax,(%r15) 3c: 75 e2 jne 0x20 3e: 49 rex.WB 3f: 8b .byte 0x8b
Code starting with the faulting instruction
===========================================
0: 4c 8b 3b mov (%rbx),%r15 3: 4d 85 ff test %r15,%r15 6: 74 ee je 0xfffffffffffffff6 8: 49 8b 45 10 mov 0x10(%r13),%rax c: 48 8b 00 mov (%rax),%rax f: 49 39 07 cmp %rax,(%r15) 12: 75 e2 jne 0xfffffffffffffff6 14: 49 rex.WB 15: 8b .byte 0x8b RSP: 0018:ffffb43981457ca8 EFLAGS: 00010202 RAX: ffffffff8e6333e0 RBX: ffffffff8e6333d0 RCX: 00000000000002cd RDX: ffff942b4b0bd000 RSI: 000000000000006e RDI: ffff942b42f9cc30 RBP: ffff942b42f9cc30 R08: ffffffff8e6333d0 R09: 63696c6f626d7973 R10: 735f746e6972705f R11: 2863696c6f626d79 R12: 0000000000000000 R13: ffffffff8de44880 R14: ffffffff8de44516 R15: ffffffff8de44515 FS: 00007f556c562740(0000) GS:ffff942cbdfc0000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: ffffffff8e6333d0 CR3: 000000010a1d0006 CR4: 0000000000170ef0 Call Trace: <TASK> ? __die (arch/x86/kernel/dumpstack.c:421 arch/x86/kernel/dumpstack.c:434)
? page_fault_oops (arch/x86/mm/fault.c:715)
? search_module_extables (kernel/module/main.c:3280)
? search_bpf_extables (kernel/bpf/core.c:799)
? exc_page_fault (arch/x86/mm/fault.c:1198 arch/x86/mm/fault.c:1479 arch/x86/mm/fault.c:1539) ? asm_exc_page_fault (arch/x86/include/asm/idtentry.h:623)
? f_show (kernel/trace/trace_events.c:1601 kernel/trace/trace_events.c:1651 kernel/trace/trace_events.c:1689) ? f_show (kernel/trace/trace_events.c:1623 kernel/trace/trace_events.c:1689)
seq_read_iter (fs/seq_file.c:273)seq_read (fs/seq_file.c:163)vfs_read (fs/read_write.c:474)
? __handle_mm_fault (mm/memory.c:3945 mm/memory.c:5521 mm/memory.c:5664) ksys_read (fs/read_write.c:619)
do_syscall_64 (arch/x86/entry/common.c:52 (discriminator 1) arch/x86/entry/common.c:83 (discriminator 1)) ? handle_mm_fault (mm/memory.c:5744 (discriminator 1) mm/memory.c:5840 (discriminator 1)) ? exc_page_fault (arch/x86/mm/fault.c:1342 arch/x86/mm/fault.c:1481 arch/x86/mm/fault.c:1539) ? irqentry_exit_to_user_mode (arch/x86/include/asm/entry-common.h:57 (discriminator 1) include/linux/entry-common.h:330 (discriminator 1) kernel/entry/common.c:231 (discriminator 1)) entry_SYSCALL_64_after_hwframe (arch/x86/entry/entry_64.S:130) RIP: 0033:0x7f556c65ca5d Code: 31 c0 e9 c6 fe ff ff 50 48 8d 3d a6 60 0a 00 e8 a9 08 02 00 66 0f 1f 84 00 00 00 00 00 80 3d 81 3b 0e 00 00 74 17 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 5b c3 66 2e 0f 1f 84 00 00 00 00 00 48 83 ec All code ======== 0: 31 c0 xor %eax,%eax 2: e9 c6 fe ff ff jmp 0xfffffffffffffecd 7: 50 push %rax 8: 48 8d 3d a6 60 0a 00 lea 0xa60a6(%rip),%rdi # 0xa60b5 f: e8 a9 08 02 00 call 0x208bd 14: 66 0f 1f 84 00 00 00 nopw 0x0(%rax,%rax,1) 1b: 00 00 1d: 80 3d 81 3b 0e 00 00 cmpb $0x0,0xe3b81(%rip) # 0xe3ba5 24: 74 17 je 0x3d 26: 31 c0 xor %eax,%eax 28: 0f 05 syscall 2a:* 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax <-- trapping instruction 30: 77 5b ja 0x8d 32: c3 ret 33: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) 3a: 00 00 00 3d: 48 rex.W 3e: 83 .byte 0x83 3f: ec in (%dx),%al
Code starting with the faulting instruction
===========================================
0: 48 3d 00 f0 ff ff cmp $0xfffffffffffff000,%rax 6: 77 5b ja 0x63 8: c3 ret 9: 66 2e 0f 1f 84 00 00 cs nopw 0x0(%rax,%rax,1) 10: 00 00 00 13: 48 rex.W 14: 83 .byte 0x83 15: ec in (%dx),%al
RSP: 002b:00007ffc88ecb878 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 0000000000020000 RCX: 00007f556c65ca5d
RDX: 0000000000020000 RSI: 00007f556c541000 RDI: 0000000000000003
RBP: 0000000000020000 R08: 00000000ffffffff R09: 0000000000000000
R10: 0000000000000022 R11: 0000000000000246 R12: 00007f556c541000
R13: 0000000000000003 R14: 0000000000020000 R15: 0000000000000000
</TASK> Modules linked in: snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hwdep snd_hda_core CR2: ffffffff8e6333d0 ---[ end trace 0000000000000000 ]---
-- Steve
Hi Steven,
Quoted 9 lines
I finally got around to testing your patches.
I did the following:
# cat /sys/kernel/tracing/events/*/*/formatand hit this:
BUG: unable to handle page fault for address: ffffffff8e6333d0
Ugh. That's ... unfortunate.
I couldn't reproduce this so far, do you happen to have the .config and qemu command line perhaps?
Quoted 5 lines
#PF: supervisor read access in kernel mode
#PF:error_code(0x0000)- not-present page
PGD183c40067P4D183c40067PUD183c41063PMD1003ef063PTE800ffffe7b9cc062Oops: Oops: 0000 [#1] PREEMPT SMP PTI CPU: 7 UID: 0 PID: 893 Comm: cat Not tainted 6.11.0-rc4-test-00004-g4ce2836f008b #56 68afcee1248519f8b3b088836c40746e4a6b69d3
I guess that's just my four patches; reproducing that (rc4 + the patches, seems there was a small conflict in skb tracing) ...
Quoted 2 lines
Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-debian-1.16.3-2 04/01/2014 RIP: 0010:f_show (kernel/trace/trace_events.c:1601 kernel/trace/trace_events.c:1651 kernel/trace/trace_events.c:1689)
means this was
for (i = 0; i < n_sym_defs; i++) {
unsigned int sym_len;
if (!sym_defs[i]) // <--- HERE
continue;which seems really strange to me.
Sadly the
Quoted 1 line
Code: [...]
was compiled so we don't see 'i' here, and the stop value is on the stack...
Quoted 4 lines
All code
========0: 33 63 8e xor -0x72(%rbx),%esp 3: 48 2d d0 33 63 8e sub $0xffffffff8e6333d0,%rax
the big constant here must be __start_ftrace_sym_defs, being subtracted from an already loaded __stop_ftrace_sym_defs in %rax ...
Quoted 1 line
9: 48 c1 f8 03 sar $0x3,%rax
also part of the size calculation (n_sym_defs) - we have 8 byte pointers in each entry, so >>= 3 makes sense.
Given RBX is 0xffffffff8e6333d0 as well, that means __start_ftrace_sym_defs isn't a valid pointer? But then what was __stop_ftrace_sym_defs? And why would the section be non-empty but invalid to dereference?
Quoted 2 lines
d: 85 c0 test %eax,%eax f: 74 67 je 0x78
Anyway this aborts if there are 0 entries so we get non-zero in %eax/%rax ...
I've actually tried now with an empty section, and that also works OK.
Is there something special about your build here?
johannes