public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: Fix a precedence bug
@ 2015-02-27  9:35 He Kuang
  2015-02-27 10:38 ` He Kuang
  2015-02-27 10:40 ` Masami Hiramatsu
  0 siblings, 2 replies; 7+ messages in thread
From: He Kuang @ 2015-02-27  9:35 UTC (permalink / raw)
  To: masami.hiramatsu.pt, acme, mingo; +Cc: wangnan0, linux-kernel

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(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 919937e..bed8d0f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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;
 }
-- 
2.2.0.33.gc18b867


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Fix a precedence bug
  2015-02-27  9:35 [PATCH] perf: Fix a precedence bug He Kuang
@ 2015-02-27 10:38 ` He Kuang
  2015-02-27 10:40 ` Masami Hiramatsu
  1 sibling, 0 replies; 7+ messages in thread
From: He Kuang @ 2015-02-27 10:38 UTC (permalink / raw)
  To: masami.hiramatsu.pt, acme, mingo; +Cc: wangnan0, linux-kernel

Signed-off-by: He Kuang <hekuang@huawei.com>
在 2015/2/27 17:35, 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(-)
>
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -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;
>   }



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Fix a precedence bug
  2015-02-27  9:35 [PATCH] perf: Fix a precedence bug He Kuang
  2015-02-27 10:38 ` He Kuang
@ 2015-02-27 10:40 ` Masami Hiramatsu
  2015-02-27 10:52   ` He Kuang
  1 sibling, 1 reply; 7+ messages in thread
From: Masami Hiramatsu @ 2015-02-27 10:40 UTC (permalink / raw)
  To: He Kuang; +Cc: acme, mingo, wangnan0, linux-kernel

Hi,

(2015/02/27 18:35), He Kuang wrote:
> 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,

> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -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;
>  }
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] perf: Fix a precedence bug
  2015-02-27 10:40 ` Masami Hiramatsu
@ 2015-02-27 10:52   ` He Kuang
  2015-02-27 11:12     ` Masami Hiramatsu
                       ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: He Kuang @ 2015-02-27 10:52 UTC (permalink / raw)
  To: masami.hiramatsu.pt, acme, mingo; +Cc: wangnan0, linux-kernel

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 do_sys_open@linux.git/fs/open.c)

Signed-off-by: He Kuang <hekuang@huawei.com>
---
 tools/perf/util/probe-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 919937e..bed8d0f 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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;
 }
-- 
2.2.0.33.gc18b867


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Fix a precedence bug
  2015-02-27 10:52   ` He Kuang
@ 2015-02-27 11:12     ` Masami Hiramatsu
  2015-02-27 11:17     ` Masami Hiramatsu
  2015-02-28  9:32     ` [tip:perf/core] perf probe: " tip-bot for He Kuang
  2 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2015-02-27 11:12 UTC (permalink / raw)
  To: He Kuang; +Cc: acme, mingo, wangnan0, linux-kernel

(2015/02/27 19:52), He Kuang wrote:
> 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 do_sys_open@linux.git/fs/open.c)

Thanks for finding this bug!

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -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;
>  }
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] perf: Fix a precedence bug
  2015-02-27 10:52   ` He Kuang
  2015-02-27 11:12     ` Masami Hiramatsu
@ 2015-02-27 11:17     ` Masami Hiramatsu
  2015-02-28  9:32     ` [tip:perf/core] perf probe: " tip-bot for He Kuang
  2 siblings, 0 replies; 7+ messages in thread
From: Masami Hiramatsu @ 2015-02-27 11:17 UTC (permalink / raw)
  To: He Kuang; +Cc: acme, mingo, wangnan0, linux-kernel

(2015/02/27 19:52), He Kuang wrote:
> 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 do_sys_open@linux.git/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,


> 
> Signed-off-by: He Kuang <hekuang@huawei.com>
> ---
>  tools/perf/util/probe-event.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 919937e..bed8d0f 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -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;
>  }
> 


-- 
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Research Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [tip:perf/core] perf probe: Fix a precedence bug
  2015-02-27 10:52   ` He Kuang
  2015-02-27 11:12     ` Masami Hiramatsu
  2015-02-27 11:17     ` Masami Hiramatsu
@ 2015-02-28  9:32     ` tip-bot for He Kuang
  2 siblings, 0 replies; 7+ messages in thread
From: tip-bot for He Kuang @ 2015-02-28  9:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: hekuang, masami.hiramatsu.pt, wangnan0, acme, linux-kernel, mingo,
	hpa, tglx

Commit-ID:  f56847c2e99810781f6941d01baff9ae223eeac3
Gitweb:     http://git.kernel.org/tip/f56847c2e99810781f6941d01baff9ae223eeac3
Author:     He Kuang <hekuang@huawei.com>
AuthorDate: Fri, 27 Feb 2015 18:52:53 +0800
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
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 do_sys_open@linux.git/fs/open.c)

Signed-off-by: He Kuang <hekuang@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1425034373-14511-1-git-send-email-hekuang@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 9526cf3..7c0e765 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -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;
 }

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2015-02-28  9:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27  9:35 [PATCH] perf: Fix a precedence bug He Kuang
2015-02-27 10:38 ` He Kuang
2015-02-27 10:40 ` Masami Hiramatsu
2015-02-27 10:52   ` He Kuang
2015-02-27 11:12     ` Masami Hiramatsu
2015-02-27 11:17     ` Masami Hiramatsu
2015-02-28  9:32     ` [tip:perf/core] perf probe: " tip-bot for He Kuang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox