* [RFC] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
[not found] <CAE3E0fDuYbhSj_EESFh2OKzBUQS=oGKWm3+H7XJARi=m7CLxqQ@mail.gmail.com>
@ 2017-10-04 6:13 ` Ravi Bangoria
2017-10-04 13:08 ` Jiri Olsa
0 siblings, 1 reply; 7+ messages in thread
From: Ravi Bangoria @ 2017-10-04 6:13 UTC (permalink / raw)
To: pozdneyev, acme, linux-kernel
Cc: linux-perf-users, peterz, mingo, alexander.shishkin, yao.jin, ak,
jolsa, kjlx, milian.wolff, zhangmengting, Ravi Bangoria
Two functions from different binaries can have same start
address. Thus, comparing only start address in match_chain()
leads to inconsistent callchains. Fix this by adding a check
for dsos as well.
Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
tools/perf/util/callchain.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 510b513..6d5a483 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -678,6 +678,9 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
{
struct symbol *sym = node->sym;
u64 left, right;
+ struct dso *left_dso = NULL;
+ struct dso *right_dso = NULL;
+
if (callchain_param.key == CCKEY_SRCLINE) {
enum match_result match = match_chain_srcline(node, cnode);
@@ -689,12 +692,16 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
left = cnode->ms.sym->start;
right = sym->start;
+ if (cnode->ms.map && node->map) {
+ left_dso = cnode->ms.map->dso;
+ right_dso = node->map->dso;
+ }
} else {
left = cnode->ip;
right = node->ip;
}
- if (left == right) {
+ if (left == right && left_dso == right_dso) {
if (node->branch) {
cnode->branch_count++;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [RFC] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
2017-10-04 6:13 ` [RFC] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION Ravi Bangoria
@ 2017-10-04 13:08 ` Jiri Olsa
2017-10-05 3:50 ` [PATCH] " Ravi Bangoria
0 siblings, 1 reply; 7+ messages in thread
From: Jiri Olsa @ 2017-10-04 13:08 UTC (permalink / raw)
To: Ravi Bangoria
Cc: pozdneyev, acme, linux-kernel, linux-perf-users, peterz, mingo,
alexander.shishkin, yao.jin, ak, jolsa, kjlx, milian.wolff,
zhangmengting
On Wed, Oct 04, 2017 at 11:43:08AM +0530, Ravi Bangoria wrote:
> Two functions from different binaries can have same start
> address. Thus, comparing only start address in match_chain()
> leads to inconsistent callchains. Fix this by adding a check
> for dsos as well.
>
> Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
>
> Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
> tools/perf/util/callchain.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index 510b513..6d5a483 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -678,6 +678,9 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
> {
> struct symbol *sym = node->sym;
> u64 left, right;
> + struct dso *left_dso = NULL;
> + struct dso *right_dso = NULL;
> +
>
> if (callchain_param.key == CCKEY_SRCLINE) {
> enum match_result match = match_chain_srcline(node, cnode);
> @@ -689,12 +692,16 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
> if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
> left = cnode->ms.sym->start;
> right = sym->start;
> + if (cnode->ms.map && node->map) {
> + left_dso = cnode->ms.map->dso;
> + right_dso = node->map->dso;
makes sense.. but why not to get those maps separately?
if (cnode->ms.map)
left_dso = cnode->ms.map->dso;
if (node->map) {
right_dso = node->map->dso;
I'd think that if one is missing, it's most likely different
map/dso and you want to fail the == check
jirka
> + }
> } else {
> left = cnode->ip;
> right = node->ip;
> }
>
> - if (left == right) {
> + if (left == right && left_dso == right_dso) {
> if (node->branch) {
> cnode->branch_count++;
>
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
2017-10-04 13:08 ` Jiri Olsa
@ 2017-10-05 3:50 ` Ravi Bangoria
2017-10-05 4:13 ` Namhyung Kim
0 siblings, 1 reply; 7+ messages in thread
From: Ravi Bangoria @ 2017-10-05 3:50 UTC (permalink / raw)
To: pozdneyev, acme, linux-kernel, jolsa
Cc: linux-perf-users, peterz, mingo, alexander.shishkin, yao.jin, ak,
kjlx, milian.wolff, zhangmengting, Ravi Bangoria
Two functions from different binaries can have same start
address. Thus, comparing only start address in match_chain()
leads to inconsistent callchains. Fix this by adding a check
for dsos as well.
Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
tools/perf/util/callchain.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index be09d77..6d7f645 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -685,6 +685,9 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
{
struct symbol *sym = node->sym;
u64 left, right;
+ struct dso *left_dso = NULL;
+ struct dso *right_dso = NULL;
+
if (callchain_param.key == CCKEY_SRCLINE) {
enum match_result match = match_chain_srcline(node, cnode);
@@ -696,12 +699,16 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
left = cnode->ms.sym->start;
right = sym->start;
+ if (cnode->ms.map)
+ left_dso = cnode->ms.map->dso;
+ if (node->map)
+ right_dso = node->map->dso;
} else {
left = cnode->ip;
right = node->ip;
}
- if (left == right) {
+ if (left == right && left_dso == right_dso) {
if (node->branch) {
cnode->branch_count++;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
2017-10-05 3:50 ` [PATCH] " Ravi Bangoria
@ 2017-10-05 4:13 ` Namhyung Kim
2017-10-05 9:12 ` [PATCH v2] " Ravi Bangoria
0 siblings, 1 reply; 7+ messages in thread
From: Namhyung Kim @ 2017-10-05 4:13 UTC (permalink / raw)
To: Ravi Bangoria
Cc: pozdneyev, acme, linux-kernel, jolsa, linux-perf-users, peterz,
mingo, alexander.shishkin, yao.jin, ak, kjlx, milian.wolff,
zhangmengting, kernel-team
Hi,
On Thu, Oct 05, 2017 at 09:20:21AM +0530, Ravi Bangoria wrote:
> Two functions from different binaries can have same start
> address. Thus, comparing only start address in match_chain()
> leads to inconsistent callchains. Fix this by adding a check
> for dsos as well.
>
> Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
>
> Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
> tools/perf/util/callchain.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index be09d77..6d7f645 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -685,6 +685,9 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
> {
> struct symbol *sym = node->sym;
> u64 left, right;
> + struct dso *left_dso = NULL;
> + struct dso *right_dso = NULL;
> +
>
> if (callchain_param.key == CCKEY_SRCLINE) {
> enum match_result match = match_chain_srcline(node, cnode);
> @@ -696,12 +699,16 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
> if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
> left = cnode->ms.sym->start;
> right = sym->start;
> + if (cnode->ms.map)
> + left_dso = cnode->ms.map->dso;
> + if (node->map)
> + right_dso = node->map->dso;
AFAIK having a symbol guarantees having a map too. So it could simply
be:
left_dso = cnode->ms.map->dso;
right_dso = node->map->dso;
Thanks,
Namhyung
> } else {
> left = cnode->ip;
> right = node->ip;
> }
>
> - if (left == right) {
> + if (left == right && left_dso == right_dso) {
> if (node->branch) {
> cnode->branch_count++;
>
> --
> 1.8.3.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-perf-users" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
2017-10-05 4:13 ` Namhyung Kim
@ 2017-10-05 9:12 ` Ravi Bangoria
2017-10-05 9:26 ` Jiri Olsa
2017-10-05 18:12 ` [tip:perf/urgent] " tip-bot for Ravi Bangoria
0 siblings, 2 replies; 7+ messages in thread
From: Ravi Bangoria @ 2017-10-05 9:12 UTC (permalink / raw)
To: pozdneyev, acme, linux-kernel, jolsa, namhyung
Cc: linux-perf-users, peterz, mingo, alexander.shishkin, yao.jin, ak,
kjlx, milian.wolff, zhangmengting, Ravi Bangoria
Two functions from different binaries can have same start
address. Thus, comparing only start address in match_chain()
leads to inconsistent callchains. Fix this by adding a check
for dsos as well.
Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
---
Changes in v2:
- Remove unnecessary checks for 'map'
tools/perf/util/callchain.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index be09d77..a971caf 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -685,6 +685,8 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
{
struct symbol *sym = node->sym;
u64 left, right;
+ struct dso *left_dso = NULL;
+ struct dso *right_dso = NULL;
if (callchain_param.key == CCKEY_SRCLINE) {
enum match_result match = match_chain_srcline(node, cnode);
@@ -696,12 +698,14 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
left = cnode->ms.sym->start;
right = sym->start;
+ left_dso = cnode->ms.map->dso;
+ right_dso = node->map->dso;
} else {
left = cnode->ip;
right = node->ip;
}
- if (left == right) {
+ if (left == right && left_dso == right_dso) {
if (node->branch) {
cnode->branch_count++;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
2017-10-05 9:12 ` [PATCH v2] " Ravi Bangoria
@ 2017-10-05 9:26 ` Jiri Olsa
2017-10-05 18:12 ` [tip:perf/urgent] " tip-bot for Ravi Bangoria
1 sibling, 0 replies; 7+ messages in thread
From: Jiri Olsa @ 2017-10-05 9:26 UTC (permalink / raw)
To: Ravi Bangoria
Cc: pozdneyev, acme, linux-kernel, jolsa, namhyung, linux-perf-users,
peterz, mingo, alexander.shishkin, yao.jin, ak, kjlx,
milian.wolff, zhangmengting
On Thu, Oct 05, 2017 at 02:42:34PM +0530, Ravi Bangoria wrote:
> Two functions from different binaries can have same start
> address. Thus, comparing only start address in match_chain()
> leads to inconsistent callchains. Fix this by adding a check
> for dsos as well.
>
> Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
>
> Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> ---
> Changes in v2:
> - Remove unnecessary checks for 'map'
Acked-by: Jiri Olsa <jolsa@kernel.org>
thanks,
jirka
>
> tools/perf/util/callchain.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
> index be09d77..a971caf 100644
> --- a/tools/perf/util/callchain.c
> +++ b/tools/perf/util/callchain.c
> @@ -685,6 +685,8 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
> {
> struct symbol *sym = node->sym;
> u64 left, right;
> + struct dso *left_dso = NULL;
> + struct dso *right_dso = NULL;
>
> if (callchain_param.key == CCKEY_SRCLINE) {
> enum match_result match = match_chain_srcline(node, cnode);
> @@ -696,12 +698,14 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
> if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
> left = cnode->ms.sym->start;
> right = sym->start;
> + left_dso = cnode->ms.map->dso;
> + right_dso = node->map->dso;
> } else {
> left = cnode->ip;
> right = node->ip;
> }
>
> - if (left == right) {
> + if (left == right && left_dso == right_dso) {
> if (node->branch) {
> cnode->branch_count++;
>
> --
> 1.8.3.1
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* [tip:perf/urgent] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
2017-10-05 9:12 ` [PATCH v2] " Ravi Bangoria
2017-10-05 9:26 ` Jiri Olsa
@ 2017-10-05 18:12 ` tip-bot for Ravi Bangoria
1 sibling, 0 replies; 7+ messages in thread
From: tip-bot for Ravi Bangoria @ 2017-10-05 18:12 UTC (permalink / raw)
To: linux-tip-commits
Cc: mingo, yao.jin, namhyung, tglx, alexander.shishkin, acme,
pozdneyev, ak, hpa, ravi.bangoria, peterz, milian.wolff, jolsa,
kjlx, linux-kernel
Commit-ID: c1fbc0cf81f1c464f5fda322c1104d4bb1da6711
Gitweb: https://git.kernel.org/tip/c1fbc0cf81f1c464f5fda322c1104d4bb1da6711
Author: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
AuthorDate: Thu, 5 Oct 2017 14:42:34 +0530
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 5 Oct 2017 10:52:54 -0300
perf callchain: Compare dsos (as well) for CCKEY_FUNCTION
Two functions from different binaries can have same start address. Thus,
comparing only start address in match_chain() leads to inconsistent
callchains. Fix this by adding a check for dsos as well.
Ex, https://www.spinics.net/lists/linux-perf-users/msg04067.html
Reported-by: Alexander Pozdneev <pozdneyev@gmail.com>
Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Krister Johansen <kjlx@templeofstupid.com>
Cc: Milian Wolff <milian.wolff@kdab.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Yao Jin <yao.jin@linux.intel.com>
Cc: zhangmengting@huawei.com
Link: http://lkml.kernel.org/r/20171005091234.5874-1-ravi.bangoria@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/callchain.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index be09d77..a971caf 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -685,6 +685,8 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
{
struct symbol *sym = node->sym;
u64 left, right;
+ struct dso *left_dso = NULL;
+ struct dso *right_dso = NULL;
if (callchain_param.key == CCKEY_SRCLINE) {
enum match_result match = match_chain_srcline(node, cnode);
@@ -696,12 +698,14 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
left = cnode->ms.sym->start;
right = sym->start;
+ left_dso = cnode->ms.map->dso;
+ right_dso = node->map->dso;
} else {
left = cnode->ip;
right = node->ip;
}
- if (left == right) {
+ if (left == right && left_dso == right_dso) {
if (node->branch) {
cnode->branch_count++;
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2017-10-05 18:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <CAE3E0fDuYbhSj_EESFh2OKzBUQS=oGKWm3+H7XJARi=m7CLxqQ@mail.gmail.com>
2017-10-04 6:13 ` [RFC] perf callchain: Compare dsos (as well) for CCKEY_FUNCTION Ravi Bangoria
2017-10-04 13:08 ` Jiri Olsa
2017-10-05 3:50 ` [PATCH] " Ravi Bangoria
2017-10-05 4:13 ` Namhyung Kim
2017-10-05 9:12 ` [PATCH v2] " Ravi Bangoria
2017-10-05 9:26 ` Jiri Olsa
2017-10-05 18:12 ` [tip:perf/urgent] " tip-bot for Ravi Bangoria
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).