Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp1358129ybj; Thu, 7 May 2020 22:41:26 -0700 (PDT) X-Google-Smtp-Source: APiQypKjc1CUBOSX+IfjtsEOUv7yOB9DPOc+PCpxHBFz7EXv1o3cMeFuXf4IJQFHuiensFX6zqgU X-Received: by 2002:a50:e80a:: with SMTP id e10mr781772edn.204.1588916486393; Thu, 07 May 2020 22:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588916486; cv=none; d=google.com; s=arc-20160816; b=un3VCaWgUHO3Wdpv+K9dPMqhbL1w41vWSW/cW2QnM27j/g+LiJ/6WzPvSGJtspgnWl doCsL3wu1+e1fy2VAbkSxyJKZ8DqWG4PhU45EBGdcsjggXNUMX+bRWFMRaXlufcGDTZQ cRlW9an00AlNH51Qe6utD7rSBdFTx2d4xRxKEDOJAYBCnaUv1e6IxohotYa97PXjqRv1 NfFHyRCp1XK/pQbDrO0X/eznE8KPH6BTwHq+zzW/c6RVSsOADXwVMFMlFfvL2HVO2bGI 9PLfFhRULiYby3e6+TYxxsOR5ONB5uL6H3uxqmrkV9Uu7gNTWMMNZvAAijATKtiT6gyk wifg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=0QS1YqAYu664zYAVy5D9As+p1Vggn2+qgtokmxG8BMQ=; b=kI8Zb/bCvZuol/JkRSn9mVNiXu8sstXy28yTithSddtn5CDfWAXZ13Yz6dvKYt7HQx SYE5+UGpKO1OAgu2xNTqaDa29GaYykWArrJhhr7Ue077Sdd+3CPTJ6mFiaMHK4IS35lE J47T93BBrsTxJXiFb3JGC08tFP/h93ij7wWegZEFoo7vtz0dV3CI0hXMHRyvB8xtxIz7 I9vo/ULATyQluupU8aok7lmKFvt8icByU76t/65MraMR4AJlSaUShdMMSqeNIx/+9bG1 b8tIkF5fJV3Y2D3guqjjkCZ+pt8MiHFFDSjh1QDsB+77cR4jASkjwbpfes20sdgoYzH6 cFDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WdaMO2k2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t28si359688edi.408.2020.05.07.22.41.03; Thu, 07 May 2020 22:41:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=WdaMO2k2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727909AbgEHFh0 (ORCPT + 99 others); Fri, 8 May 2020 01:37:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727110AbgEHFgx (ORCPT ); Fri, 8 May 2020 01:36:53 -0400 Received: from mail-yb1-xb49.google.com (mail-yb1-xb49.google.com [IPv6:2607:f8b0:4864:20::b49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F35C3C05BD0E for ; Thu, 7 May 2020 22:36:52 -0700 (PDT) Received: by mail-yb1-xb49.google.com with SMTP id y7so750860ybj.15 for ; Thu, 07 May 2020 22:36:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=0QS1YqAYu664zYAVy5D9As+p1Vggn2+qgtokmxG8BMQ=; b=WdaMO2k2Y5pTljLKBJ0d+Y2TyM+fRid8W+wbZXFfMKUEmpNUE66nlFIgfWEtFPAr7L CqOKVwmwFYYlMF56xmSj5qCNhwYVnaRoUBy4pQUNYdHJsWcs8c3JahIOuVgpIz2UcSQb 82foWpW+AbFOOZpv2wCDJ0VZ6yWEgeoa3MDgb0c75ADt33hDUr2YKSlALKJCG4viXCoC AsR+VbfVak6o1lcWU78xIIR+SoOKJ7RM6N6ma5tNRUfR43R9WF+1LC/RSIMZIEdDWlGO TMOBH3b/anKG9yG4krGWerI0oEC9haNtALFX4AWIw+/B+DhKdCYovPJTGDGCXOM59qz8 WENQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=0QS1YqAYu664zYAVy5D9As+p1Vggn2+qgtokmxG8BMQ=; b=LRz+VaPPCpRjaZfvf+V4jat1nQqGLsmK+nwIcqQCLhiO9Iq4WVHZl74zv9qvt7WYAB fhg6Waoq/fbyoC3vjb4F4ipHv9YmbvVA0rZ/3GCus9eP/aOH0homWWp4ibwEbBLEYMqX N1G67f4XxklPHSs57Vc8Lrc4ChFlRjMPvXo06diL+5fLft1/JsN4EQFNm8suuPHgdb8q eCdl6WGvPqgeqNpNz+7/VtdQZzX3TZAtyxNqmhE+kTuzPbZhVmJ0t+RPAAWL3R/onvCs g+0UzjYlfhf2RhTTR8YYFZe0h7gzTtOsqe+r8tdu6FWNabyjUniw3ZpIfLhWGIiU+wSO 2K5Q== X-Gm-Message-State: AGi0PuYAW/hd10Ze7ykGwuDLImBuatrV1BpBK5XVN0v7zF5y1P+LnKjZ 3AczuZsozm/HGhwx/c61sniDxoZerSFP X-Received: by 2002:a25:cb17:: with SMTP id b23mr1959004ybg.515.1588916212125; Thu, 07 May 2020 22:36:52 -0700 (PDT) Date: Thu, 7 May 2020 22:36:25 -0700 In-Reply-To: <20200508053629.210324-1-irogers@google.com> Message-Id: <20200508053629.210324-11-irogers@google.com> Mime-Version: 1.0 References: <20200508053629.210324-1-irogers@google.com> X-Mailer: git-send-email 2.26.2.645.ge9eca65c58-goog Subject: [RFC PATCH v3 10/14] perf metricgroup: always place duration_time last From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , Andrii Nakryiko , John Fastabend , KP Singh , Kajol Jain , Andi Kleen , John Garry , Jin Yao , Kan Liang , Cong Wang , Kim Phillips , linux-kernel@vger.kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, Vince Weaver , Stephane Eranian , Ian Rogers Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 7e1725d61c39..2c684fd3c4e3 100644 --- a/tools/perf/util/metricgroup.c +++ b/tools/perf/util/metricgroup.c @@ -422,8 +422,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); @@ -433,20 +433,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.26.2.645.ge9eca65c58-goog