Skip to content

Commit 02dabc2

Browse files
DanielTimLeeAlexei Starovoitov
authored andcommitted
samples/bpf: fix symbol mismatch by compiler optimization
Currently, multiple kprobe programs are suffering from symbol mismatch due to compiler optimization. These optimizations might induce additional suffix to the symbol name such as '.isra' or '.constprop'. # egrep ' finish_task_switch| __netif_receive_skb_core' /proc/kallsyms ffffffff81135e50 t finish_task_switch.isra.0 ffffffff81dd36d0 t __netif_receive_skb_core.constprop.0 ffffffff8205cc0e t finish_task_switch.isra.0.cold ffffffff820b1aba t __netif_receive_skb_core.constprop.0.cold To avoid this, this commit replaces the original kprobe section to kprobe.multi in order to match symbol with wildcard characters. Here, asterisk is used for avoiding symbol mismatch. Signed-off-by: Daniel T. Lee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 4a0ee78 commit 02dabc2

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

samples/bpf/offwaketime.bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ int oncpu(struct trace_event_raw_sched_switch *ctx)
118118
/* record previous thread sleep time */
119119
u32 pid = ctx->prev_pid;
120120
#else
121-
SEC("kprobe/finish_task_switch")
121+
SEC("kprobe.multi/finish_task_switch*")
122122
int oncpu(struct pt_regs *ctx)
123123
{
124124
struct task_struct *p = (void *) PT_REGS_PARM1(ctx);

samples/bpf/tracex1.bpf.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
* Number of arguments and their positions can change, etc.
2323
* In such case this bpf+kprobe example will no longer be meaningful
2424
*/
25-
SEC("kprobe/__netif_receive_skb_core")
25+
SEC("kprobe.multi/__netif_receive_skb_core*")
2626
int bpf_prog1(struct pt_regs *ctx)
2727
{
2828
/* attaches to kprobe __netif_receive_skb_core,
2929
* looks for packets on loobpack device and prints them
30+
* (wildcard is used for avoiding symbol mismatch due to optimization)
3031
*/
3132
char devname[IFNAMSIZ];
3233
struct net_device *dev;

0 commit comments

Comments
 (0)