perf: Fix a precedence bug
PATCH 1/1 perf: Fix a precedence bug
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.
--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-event.c +1 -1
@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }
Signature · 1 line
2.2.0.33.gc18b867
Quoted 19 lines · He Kuang
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-event.c +1
-1@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }
Hi,
Quoted 2 lines · He Kuang
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.
Thank you for fixing that,
Could you give us an actual example of the result? e.g. What happened? and how to reproduce it?
Thank you,
Quoted 18 lines
--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-event.c +1
-1@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
PATCH 1/1 perf: Fix a precedence bug
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.
Before this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events $ perf probe -l -k ../vmlinux kprobes:myprobe (on do_sys_open)
After this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events $ perf probe -l -k ../vmlinux kprobes:myprobe (on [email protected]/fs/open.c)
--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-event.c +1 -1
@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }
Signature · 1 line
2.2.0.33.gc18b867
Quoted 4 lines · He Kuang
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.Before this patch:
Quoted 8 lines
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events $ perf probe -l -k ../vmlinux kprobes:myprobe (on do_sys_open)After this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events $ perf probe -l -k ../vmlinux kprobes:myprobe (on [email protected]/fs/open.c)
Thanks for finding this bug!
Quoted 20 lines
Signed-off-by He Kuang <[email protected]>--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-event.c +1
-1@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
Quoted 4 lines · He Kuang
The minus operator has higher precedence than ?:
Add parentheses around ?: fix this.Before this patch:
Quoted 8 lines
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events $ perf probe -l -k ../vmlinux kprobes:myprobe (on do_sys_open)After this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events $ perf probe -l -k ../vmlinux kprobes:myprobe (on [email protected]/fs/open.c)
BTW, on my environment (CentOS7)
# ./perf probe -a do_fork Added new event: probe:do_fork (on do_fork)
You can now use it in all perf tools, such as:
perf record -e probe:do_fork -aR sleep 1
# ./perf probe -l probe:do_fork (on do_fork@kernel/fork.c)
# ./perf probe -l -k /usr/lib/debug/lib/modules/3.10.0-123.13.2.el7.x86_64/vmlinux probe:do_fork (on do_fork@kernel/fork.c)
Hm, the current perf (without this patch) seems work... But anyway, it looks safer to brace it.
Thank you,
Quoted 20 lines
Signed-off-by He Kuang <[email protected]>--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/probe-event.c +1
-1@@ -150,7 +150,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }
Signature · 4 lines
Masami HIRAMATSU Software Platform Research Dept. Linux Technology Research Center Hitachi, Ltd., Yokohama Research Laboratory E-mail: [email protected]
tip-bot for He Kuang
merge bot[tip:perf/core] perf probe: Fix a precedence bug
In reply to He Kuangperf probe: Fix a precedence bug
Commit-ID: f56847c2e99810781f6941d01baff9ae223eeac3 Gitweb: http://git.kernel.org/tip/f56847c2e99810781f6941d01baff9ae223eeac3 Author: He Kuang <[email protected]> AuthorDate: Fri, 27 Feb 2015 18:52:53 +0800 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 27 Feb 2015 10:31:09 -0300
perf probe: Fix a precedence bug
The minus operator has higher precedence than ?: Add parentheses around ?: fix this.
Before this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
$ perf probe -l -k ../vmlinux
kprobes:myprobe (on do_sys_open)After this patch:
$ echo 'p:myprobe do_sys_open' > /sys/kernel/debug/tracing/kprobe_events
$ perf probe -l -k ../vmlinux
kprobes:myprobe (on [email protected]/fs/open.c)--- tools/perf/util/probe-event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/probe-event.c +1 -1
@@ -151,7 +151,7 @@ static u64 kernel_get_symbol_address_by_name(const char *name, bool reloc) sym =__find_kernel_function_by_name (name, &map);if (sym)return map->unmap_ip (map, sym->start) - - (reloc) ?0 : map->reloc; + ((reloc) ?0 : map->reloc); }return 0 ; }