kernel/patches/0196-perf-metricgroup-Always-place-duration_time-last.patch
2023-11-10 14:47:39 +08:00

94 lines
3.2 KiB
Diff

From 9600c58c83d3c192fb75d43cb4f52e5b2fc25f19 Mon Sep 17 00:00:00 2001
From: Ian Rogers <irogers@google.com>
Date: Wed, 20 May 2020 11:20:05 -0700
Subject: [PATCH 079/201] perf metricgroup: Always place duration_time last
mainline inclusion
from mainline-v5.8-rc1
commit 4e21c13aca38b69c4470b68ef29d198802e7d74e
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I8C0CX
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4e21c13aca38b69c4470b68ef29d198802e7d74e
----------------------------------------------------------------------
If a metric contains the duration_time event then the event is placed
outside of the metric's group of events. Rather than split the group,
make it so the duration_time is immediately after the group.
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Andrii Nakryiko <andriin@fb.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Kim Phillips <kim.phillips@amd.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Clarke <pc@us.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Song Liu <songliubraving@fb.com>
Cc: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Stephane Eranian <eranian@google.com>
Cc: Vince Weaver <vincent.weaver@maine.edu>
Cc: bpf@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lore.kernel.org/lkml/20200520182011.32236-2-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: hongrongxuan <hongrongxuan@huawei.com>
---
tools/perf/util/metricgroup.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 4a5baf5719c4..9f803fd81c8f 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -420,8 +420,8 @@ static void metricgroup__add_metric_weak_group(struct strbuf *events,
struct expr_parse_ctx *ctx)
{
struct hashmap_entry *cur;
- size_t bkt, i = 0;
- bool no_group = false;
+ size_t bkt;
+ bool no_group = true, has_duration = false;
hashmap__for_each_entry((&ctx->ids), cur, bkt) {
pr_debug("found event %s\n", (const char *)cur->key);
@@ -431,20 +431,20 @@ static void metricgroup__add_metric_weak_group(struct strbuf *events,
* group.
*/
if (!strcmp(cur->key, "duration_time")) {
- if (i > 0)
- strbuf_addf(events, "}:W,");
- strbuf_addf(events, "duration_time");
- no_group = true;
+ has_duration = true;
continue;
}
strbuf_addf(events, "%s%s",
- i == 0 || no_group ? "{" : ",",
+ no_group ? "{" : ",",
(const char *)cur->key);
no_group = false;
- i++;
}
- if (!no_group)
+ if (!no_group) {
strbuf_addf(events, "}:W");
+ if (has_duration)
+ strbuf_addf(events, ",duration_time");
+ } else if (has_duration)
+ strbuf_addf(events, "duration_time");
}
static void metricgroup__add_metric_non_group(struct strbuf *events,
--
2.27.0