Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755456Ab3JROkN (ORCPT ); Fri, 18 Oct 2013 10:40:13 -0400 Received: from g5t0008.atlanta.hp.com ([15.192.0.45]:9634 "EHLO g5t0008.atlanta.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949Ab3JROje (ORCPT ); Fri, 18 Oct 2013 10:39:34 -0400 From: Waiman Long To: Ingo Molnar , Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Paul Mackerras , Namhyung Kim , Jiri Olsa , Adrian Hunter , David Ahern , Stephane Eranian , linux-kernel@vger.kernel.org, Aswin Chandramouleeswaran , Scott J Norton , Waiman Long Subject: [PATCH v2 2/4] perf: streamline append_chain() function Date: Fri, 18 Oct 2013 10:38:47 -0400 Message-Id: <1382107129-2010-3-git-send-email-Waiman.Long@hp.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1382107129-2010-1-git-send-email-Waiman.Long@hp.com> References: <1382107129-2010-1-git-send-email-Waiman.Long@hp.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1572 Lines: 52 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 --- 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 majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/