lkml.org 
[lkml]   [2013]   [Oct]   [21]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 1/3] perf: streamline append_chain() function
Date
When callgraph is enabled, the append_chain() function consumes a major
portion of the total CPU time. This patch tries to streamline the
append_chain() function by removing unneeded conditional test as well as
using ?: statement which can be more efficient than the regular if
statement in some architectures.

Signed-off-by: Waiman Long <Waiman.Long@hp.com>
---
tools/perf/util/callchain.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c
index 482f680..1e79001 100644
--- a/tools/perf/util/callchain.c
+++ b/tools/perf/util/callchain.c
@@ -315,6 +315,7 @@ append_chain(struct callchain_node *root,
struct callchain_list *cnode;
u64 start = cursor->pos;
bool found = false;
+ bool func_mode = (callchain_param.key == CCKEY_FUNCTION);
u64 matches;

/*
@@ -331,17 +332,15 @@ append_chain(struct callchain_node *root,
if (!node)
break;

- sym = node->sym;
+ sym = func_mode ? node->sym : NULL;

- if (cnode->ms.sym && sym &&
- callchain_param.key == CCKEY_FUNCTION) {
+ if (cnode->ms.sym && sym) {
if (cnode->ms.sym->start != sym->start)
break;
} else if (cnode->ip != node->ip)
break;

- if (!found)
- found = true;
+ found = true;

callchain_cursor_advance(cursor);
}
--
1.7.1


\
 
 \ /
  Last update: 2013-10-21 17:21    [W:0.037 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site