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.l...@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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/