Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753794Ab3JUPEq (ORCPT ); Mon, 21 Oct 2013 11:04:46 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:41646 "EHLO g1t0029.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753526Ab3JUPEK (ORCPT ); Mon, 21 Oct 2013 11:04:10 -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 , Davidlohr Bueso , Waiman Long Subject: [PATCH v3 1/3] perf: streamline append_chain() function Date: Mon, 21 Oct 2013 11:03:37 -0400 Message-Id: <1382367819-19643-2-git-send-email-Waiman.Long@hp.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1382367819-19643-1-git-send-email-Waiman.Long@hp.com> References: <1382367819-19643-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/