Skip to content

Commit de19e5c

Browse files
ahunter6acmel
authored andcommitted
perf tools: Fix trigger class trigger_on()
trigger_on() means that the trigger is available but not ready, however trigger_on() was making it ready. That can segfault if the signal comes before trigger_ready(). e.g. (USR2 signal delivery not shown) $ perf record -e intel_pt//u -S sleep 1 perf: Segmentation fault Obtained 16 stack frames. /home/ahunter/bin/perf(sighandler_dump_stack+0x40) [0x4ec550] /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf] /home/ahunter/bin/perf(perf_evsel__disable+0x26) [0x4b9dd6] /home/ahunter/bin/perf() [0x43a45b] /lib/x86_64-linux-gnu/libc.so.6(+0x36caf) [0x7fa76411acaf] /lib/x86_64-linux-gnu/libc.so.6(__xstat64+0x15) [0x7fa7641d2cc5] /home/ahunter/bin/perf() [0x4ec6c9] /home/ahunter/bin/perf() [0x4ec73b] /home/ahunter/bin/perf() [0x4ec73b] /home/ahunter/bin/perf() [0x4ec73b] /home/ahunter/bin/perf() [0x4eca15] /home/ahunter/bin/perf(machine__create_kernel_maps+0x257) [0x4f0b77] /home/ahunter/bin/perf(perf_session__new+0xc0) [0x4f86f0] /home/ahunter/bin/perf(cmd_record+0x722) [0x43c132] /home/ahunter/bin/perf() [0x4a11ae] /home/ahunter/bin/perf(main+0x5d4) [0x427fb4] Note, for testing purposes, this is hard to hit unless you add some sleep() in builtin-record.c before record__open(). Signed-off-by: Adrian Hunter <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Wang Nan <[email protected]> Cc: [email protected] Fixes: 3dcc443 ("perf tools: Introduce trigger class") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 2e2967f commit de19e5c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tools/perf/util/trigger.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* States and transits:
1313
*
1414
*
15-
* OFF--(on)--> READY --(hit)--> HIT
15+
* OFF--> ON --> READY --(hit)--> HIT
1616
* ^ |
1717
* | (ready)
1818
* | |
@@ -27,8 +27,9 @@ struct trigger {
2727
volatile enum {
2828
TRIGGER_ERROR = -2,
2929
TRIGGER_OFF = -1,
30-
TRIGGER_READY = 0,
31-
TRIGGER_HIT = 1,
30+
TRIGGER_ON = 0,
31+
TRIGGER_READY = 1,
32+
TRIGGER_HIT = 2,
3233
} state;
3334
const char *name;
3435
};
@@ -50,7 +51,7 @@ static inline bool trigger_is_error(struct trigger *t)
5051
static inline void trigger_on(struct trigger *t)
5152
{
5253
TRIGGER_WARN_ONCE(t, TRIGGER_OFF);
53-
t->state = TRIGGER_READY;
54+
t->state = TRIGGER_ON;
5455
}
5556

5657
static inline void trigger_ready(struct trigger *t)

0 commit comments

Comments
 (0)