Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2145699imm; Thu, 9 Aug 2018 08:03:04 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz3Na6zNMQLE3GZpu2UQwBHsAYvAbRXeUVuAgzrbaqMVVwQ+HOvCkfrV2yl1PRt96LXuEJn X-Received: by 2002:a62:1089:: with SMTP id 9-v6mr2739184pfq.30.1533826984514; Thu, 09 Aug 2018 08:03:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533826984; cv=none; d=google.com; s=arc-20160816; b=MroBwKMxSvcVDfd13GDuU9kOQLwGsWU31Vh6iwKrFaCdAoCQYM1L4AwzyMJ2YqjJU8 X44S6sjiJfO/7hs+6cfU6xtd1dw8dNxzUMK/WlOxknxnLrjnm0RGlnAtmjaTmDn3Z/z7 HxS5aNxN9+OcchzgVKbAR9IyRglb3S9otqi04zaDeU/n/QLrS3KO28YNM1bELhXAx0yK QiIAKHHv8yE4RKclYuz4C72+RvBBgtAZGrDAzXouAc7IfOIHXcUwVRFIaNjRmumZiU0v btnkoUwBEqRh1OjXrhyCwRWBHsDICUC71tU2xErEyAiflahmN0XCa9usm4nqeAiqdarY uYKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=7kD2DU5Q+Qs9t13vx16BpMslB2/k0nwuPWw/QZqJSNQ=; b=zQXiedTks40sgKR4qwnZHtDJK4nwZwiPy+1OK7LuX1HjSBdpOYQXNjLAGIF7ujP9Mp iZxJIM9tKuaJzCxF6sD/EXncUCcXz9oo0WAoyoUfsJJFdbfwvArldqAb5ETL2fNMArD0 vh2u0dOuZOG7Htkpmn8uNMm6OzV5vTIIxWm3otN1YUrRarVefOnw9Z0hJp0JNlt4hes6 FfyRvUVaISU0FwVyFmaArpHKoQEWaexvUrSvH8/QIxetR0NUZk40cjkL4w8AfAE76lSn dvYQJj7SO20MvYFqE5bJnHrzyRRMGVNszQdPKO/euTYLD1HpBkZOHm11Cjd+W5XEP+KS TWKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZUmbImD6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p126-v6si7952491pfb.77.2018.08.09.08.02.49; Thu, 09 Aug 2018 08:03:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZUmbImD6; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733050AbeHIR0Z (ORCPT + 99 others); Thu, 9 Aug 2018 13:26:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:38220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733042AbeHIR0Y (ORCPT ); Thu, 9 Aug 2018 13:26:24 -0400 Received: from jouet.infradead.org (179-240-153-38.3g.claro.net.br [179.240.153.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id ACD992183D; Thu, 9 Aug 2018 15:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1533826867; bh=t+IZqyOP/YXei4Lpa+GyOvGblQ2XA5QG0IbV71tZYgk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZUmbImD6/S9/lkFbWAG4RspbgMiSoQegCYcHmiY40dFbeBKNoOc+eY9YvfpwuJTog 4nqsq3mlFNaj0goR+DMdhLlKTloJOEINLx/Mb3RuBW0MFGJlie13SOAZRRKAUj97Zy d+8wUqGkvR3w9yBcVShq5fM7nFXP5J8XDdvE2D78= From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: Clark Williams , linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, Jiri Olsa , Alexander Shishkin , David Ahern , Namhyung Kim , Peter Zijlstra , Stephane Eranian , Arnaldo Carvalho de Melo Subject: [PATCH 31/44] perf annotate: Add --percent-type option Date: Thu, 9 Aug 2018 11:58:09 -0300 Message-Id: <20180809145822.21391-32-acme@kernel.org> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180809145822.21391-1-acme@kernel.org> References: <20180809145822.21391-1-acme@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa Add --percent-type option to set annotation percent type from following choices: global-period, local-period, global-hits, local-hits Examples: $ perf annotate --percent-type period-local --stdio | head -1 Percent | Source code ... es, percent: local period) $ perf annotate --percent-type hits-local --stdio | head -1 Percent | Source code ... es, percent: local hits) $ perf annotate --percent-type hits-global --stdio | head -1 Percent | Source code ... es, percent: global hits) $ perf annotate --percent-type period-global --stdio | head -1 Percent | Source code ... es, percent: global period) The local/global keywords set if the percentage is computed in the scope of the function (local) or the whole data (global). The period/hits keywords set the base the percentage is computed on - the samples period or the number of samples (hits). Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Cc: Alexander Shishkin Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Link: http://lkml.kernel.org/r/20180804130521.11408-20-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/Documentation/perf-annotate.txt | 9 ++++++ tools/perf/builtin-annotate.c | 4 +++ tools/perf/util/annotate.c | 52 ++++++++++++++++++++++++++++++ tools/perf/util/annotate.h | 2 ++ 4 files changed, 67 insertions(+) diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt index 749cc6055dac..e8c972f89357 100644 --- a/tools/perf/Documentation/perf-annotate.txt +++ b/tools/perf/Documentation/perf-annotate.txt @@ -118,6 +118,15 @@ OPTIONS --group:: Show event group information together +--percent-type:: + Set annotation percent type from following choices: + global-period, local-period, global-hits, local-hits + + The local/global keywords set if the percentage is computed + in the scope of the function (local) or the whole data (global). + The period/hits keywords set the base the percentage is computed + on - the samples period or the number of samples (hits). + SEE ALSO -------- linkperf:perf-record[1], linkperf:perf-report[1] diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c index 8180319285af..830481b8db26 100644 --- a/tools/perf/builtin-annotate.c +++ b/tools/perf/builtin-annotate.c @@ -542,6 +542,10 @@ int cmd_annotate(int argc, const char **argv) OPT_CALLBACK_DEFAULT(0, "stdio-color", NULL, "mode", "'always' (default), 'never' or 'auto' only applicable to --stdio mode", stdio__config_color, "always"), + OPT_CALLBACK(0, "percent-type", &annotate.opts, "local-period", + "Set percent type local/global-period/hits", + annotate_parse_percent_type), + OPT_END() }; int ret; diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 6316fa96d984..e4268b948e0e 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -2799,3 +2799,55 @@ void annotation_config__init(void) annotation__default_options.show_total_period = symbol_conf.show_total_period; annotation__default_options.show_nr_samples = symbol_conf.show_nr_samples; } + +static unsigned int parse_percent_type(char *str1, char *str2) +{ + unsigned int type = (unsigned int) -1; + + if (!strcmp("period", str1)) { + if (!strcmp("local", str2)) + type = PERCENT_PERIOD_LOCAL; + else if (!strcmp("global", str2)) + type = PERCENT_PERIOD_GLOBAL; + } + + if (!strcmp("hits", str1)) { + if (!strcmp("local", str2)) + type = PERCENT_HITS_LOCAL; + else if (!strcmp("global", str2)) + type = PERCENT_HITS_GLOBAL; + } + + return type; +} + +int annotate_parse_percent_type(const struct option *opt, const char *_str, + int unset __maybe_unused) +{ + struct annotation_options *opts = opt->value; + unsigned int type; + char *str1, *str2; + int err = -1; + + str1 = strdup(_str); + if (!str1) + return -ENOMEM; + + str2 = strchr(str1, '-'); + if (!str2) + goto out; + + *str2++ = 0; + + type = parse_percent_type(str1, str2); + if (type == (unsigned int) -1) + type = parse_percent_type(str2, str1); + if (type != (unsigned int) -1) { + opts->percent_type = type; + err = 0; + } + +out: + free(str1); + return err; +} diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h index 760a6678edff..005a5fe8a8c6 100644 --- a/tools/perf/util/annotate.h +++ b/tools/perf/util/annotate.h @@ -397,4 +397,6 @@ static inline int symbol__tui_annotate(struct symbol *sym __maybe_unused, void annotation_config__init(void); +int annotate_parse_percent_type(const struct option *opt, const char *_str, + int unset); #endif /* __PERF_ANNOTATE_H */ -- 2.14.4