Skip to content

Commit 00b72fd

Browse files
docularxuyonghong-song
authored andcommitted
In GCC10.2 suffix '.isra.0' was appended to 'finish_task_switch'
When buildiing kernel with GCC10 [2] in Debian on an Arm64 machine, it was found the new "inter-procedural optimization improvements" [1] makes symbol name 'finish_task_switch' changed to 'finish_task_switch.isra.0'. Details: The results, when built with gcc 9.3: nm ../linux.buildout/kernel/sched/core.o | grep finish_task_switch 0000000000001288 t finish_task_switch However, when built with gcc 10.2: nm ../linux.buildout/kernel/sched/core.o | grep finish_task_switch 00000000000012d0 t finish_task_switch.isra.0 The same symbols (with xxx.isra.0 or without, respectively of course) also appear in final file 'System.map' and in '/proc/kallsyms' when booting. This negatively impact the tracing tools commonly used in kernel debugging, such as bcc tools offcputime and runqlat. They hardcode 'finish_task_switch' (without the .isra.0 suffix) into their scripts. This patch fix the issue by changing the hardcoded 'finish_task_switch' string to a python regular expression pattern who can match both the traditional form 'finish_task_switch' and the new gcc10 form 'finish_task_switch.isra.0' (with single digit at the end). attach_kprobe()'s input parameter 'event_re' is used for this type of pattern matching. [1] https://gcc.gnu.org/gcc-10/changes.html [2] ARCH=arm64 make Image Signed-off-by: Guodong Xu <guodong.xu@linaro.org>
1 parent 8bab454 commit 00b72fd

File tree

7 files changed

+14
-7
lines changed

7 files changed

+14
-7
lines changed

examples/tracing/task_switch.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
from time import sleep
77

88
b = BPF(src_file="task_switch.c")
9-
b.attach_kprobe(event="finish_task_switch", fn_name="count_sched")
9+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
10+
fn_name="count_sched")
1011

1112
# generate many schedule events
1213
for i in range(0, 100): sleep(0.01)

tests/python/test_trace2.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ class TestTracingEvent(TestCase):
3131
def setUp(self):
3232
b = BPF(text=text, debug=0)
3333
self.stats = b.get_table("stats")
34-
b.attach_kprobe(event="finish_task_switch", fn_name="count_sched")
34+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
35+
fn_name="count_sched")
3536

3637
def test_sched1(self):
3738
for i in range(0, 100):

tools/cpudist.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@
159159
max_pid = int(open("/proc/sys/kernel/pid_max").read())
160160

161161
b = BPF(text=bpf_text, cflags=["-DMAX_PID=%d" % max_pid])
162-
b.attach_kprobe(event="finish_task_switch", fn_name="sched_switch")
162+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
163+
fn_name="sched_switch")
163164

164165
print("Tracing %s-CPU time... Hit Ctrl-C to end." %
165166
("off" if args.offcpu else "on"))

tools/offcputime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,8 @@ def signal_ignore(signal, frame):
251251

252252
# initialize BPF
253253
b = BPF(text=bpf_text)
254-
b.attach_kprobe(event="finish_task_switch", fn_name="oncpu")
254+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
255+
fn_name="oncpu")
255256
matched = b.num_open_kprobes()
256257
if matched == 0:
257258
print("error: 0 functions traced. Exiting.", file=stderr)

tools/offwaketime.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ def signal_ignore(signal, frame):
288288

289289
# initialize BPF
290290
b = BPF(text=bpf_text)
291-
b.attach_kprobe(event="finish_task_switch", fn_name="oncpu")
291+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
292+
fn_name="oncpu")
292293
b.attach_kprobe(event="try_to_wake_up", fn_name="waker")
293294
matched = b.num_open_kprobes()
294295
if matched == 0:

tools/runqlat.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@
252252
if not is_support_raw_tp:
253253
b.attach_kprobe(event="ttwu_do_wakeup", fn_name="trace_ttwu_do_wakeup")
254254
b.attach_kprobe(event="wake_up_new_task", fn_name="trace_wake_up_new_task")
255-
b.attach_kprobe(event="finish_task_switch", fn_name="trace_run")
255+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
256+
fn_name="trace_run")
256257

257258
print("Tracing run queue latency... Hit Ctrl-C to end.")
258259

tools/runqslower.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,8 @@ def print_event(cpu, data, size):
255255
if not is_support_raw_tp:
256256
b.attach_kprobe(event="ttwu_do_wakeup", fn_name="trace_ttwu_do_wakeup")
257257
b.attach_kprobe(event="wake_up_new_task", fn_name="trace_wake_up_new_task")
258-
b.attach_kprobe(event="finish_task_switch", fn_name="trace_run")
258+
b.attach_kprobe(event_re="^finish_task_switch$|^finish_task_switch\.isra\.\d$",
259+
fn_name="trace_run")
259260

260261
print("Tracing run queue latency higher than %d us" % min_us)
261262
print("%-8s %-16s %-6s %14s" % ("TIME", "COMM", "TID", "LAT(us)"))

0 commit comments

Comments
 (0)