From patchwork Tue Dec 13 05:00:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 32632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2637065wrr; Mon, 12 Dec 2022 21:06:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf40o5FRNFkHAps9qvoKfHg28AMRbDeMM2QxnMikLnP2URYoCyKnvTcMjq6AMWs9ndtIUbb4 X-Received: by 2002:a05:6402:3710:b0:45c:835b:8fb3 with SMTP id ek16-20020a056402371000b0045c835b8fb3mr14327091edb.30.1670907997021; Mon, 12 Dec 2022 21:06:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670907997; cv=none; d=google.com; s=arc-20160816; b=tiHtGZjFmQvmOgdPtG9REyqTQEIdE75FmJBbh8ZRU98fZ24l3nmRumCUyvIHBENUUl jSuR7Rxak12v9kPqxZ80RMdB2SkuLxA/9pET0KyAAxxhwqcay02g83AIsQPSGm6l5h1G VyUt46t4RCxcPejw1oORaTsOoeoRDYasNnlQZfkjS3LorGOlrUsQqwzPATeC5cHguGJR 0TktdjEnKQhv+f8gtRZc9aL4zUg3W7hgGOtScXU0VJnmquv91ZkoEloxtuSup/ITOyxh eb+HUb0/rZStZdZKUQwfYqvkSiG5+SIjZ4LfGTt2ueD8MQvcOLZvDVjtFmbo3Qxl71MH 9wxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:references:mime-version :message-id:in-reply-to:date:dkim-signature; bh=ZnWxFQBwg+4TuktUxM4ZN6qiSwvuuY4rpOosCRgVzqk=; b=iM+v9QOve3qnoCqxHVDBpywRqs1EHpZwAINQrqEm1Pg78mHdgCKm02DXDCI9cGgrzE Jm0lIdtyEkh83X3RTEQVY2y+u6vtTOOeXA7yJhrDwjVc6r/psRW7xI8RCnHJW0//lRgt 4CiQI2c7mxvj1S2inOB9oafRj1Zmpu1f8AvH/XyjoeD8CCfPLjk69lxc21VnsZAMPcaX AYL00GK+Q99H0KQQ3olx8UhLtcOQ1qTNE62sXmKUNy8/KNEHYAE/dTcasZbBZBDnFprG v4RS5mLWQ0TPg/270dwpvNC1kRLelNCTeSCrK0I7dX+7MZhP9JZ3s4BgwG5FKOJzEras abqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hsfNeGUm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cx8-20020a05640222a800b00468f9f21c11si8103288edb.245.2022.12.12.21.06.12; Mon, 12 Dec 2022 21:06:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=hsfNeGUm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234314AbiLMFF3 (ORCPT + 99 others); Tue, 13 Dec 2022 00:05:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44708 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234527AbiLMFEn (ORCPT ); Tue, 13 Dec 2022 00:04:43 -0500 Received: from mail-pf1-x44a.google.com (mail-pf1-x44a.google.com [IPv6:2607:f8b0:4864:20::44a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52A42205FE for ; Mon, 12 Dec 2022 21:02:04 -0800 (PST) Received: by mail-pf1-x44a.google.com with SMTP id z13-20020aa79f8d000000b00576b614b7d2so1323403pfr.14 for ; Mon, 12 Dec 2022 21:02:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=ZnWxFQBwg+4TuktUxM4ZN6qiSwvuuY4rpOosCRgVzqk=; b=hsfNeGUmwtkaTyzxRJJjLnhuqMhXfim2nNEe3WV5OIqRFraqUOmtIBl1Iu1/ir6sys Vh9VZG0OQ8mARGAXf0m7M4ecHilH4Tl+mEpAAcSiQ8BrfIMY+8MtDllGm//XmZcLMqd5 6bFdVb5yS5hnvptMaPDi2OXcsDlvN0Wcn2GnPDPO6d1Dj77vFbGw1bpgYe0PE3qL5CDY N8zH/BO4ZwkKm3He2y7kG4+aonA4sVyfozwR7qp/2sUhTAPghVdUm5X5c/6oN+Cz2KZU tqO3Y6SS89/XcQC3a2JK6BbBhpYhUX+ZALjQRqljjQX0SFqRiPM1cfYuY1tn7SbmTLen 8ojg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ZnWxFQBwg+4TuktUxM4ZN6qiSwvuuY4rpOosCRgVzqk=; b=vVgXBdeqik+2iRcPJQrUsTYW50HrTuT3x+rlY9kQjvVyLCr0UoBjJaNYNr4vzzYvSk MNTeyMBtRZ1RTprKc+TbWtJ07B4YcUE9gAlexYNxVugiNfaGLP+D8rlnLl0HlyWXyz+n EsC7RZHJqAWWROXjIhQetaIC8np5Kx2+o2bAp2HmorrDVpBtz1jNSbUe9PnkMQcFUrbz HhiSthzI9urBumhf6jIDd6Xtc7NY0ylX9awd6odde2+XsuWh4GPh9xwGmr2l3IJI0/E9 o63KALpXpC2McOSEyv/VnCFBJ39ShkTarxxF9XkWXlG+C5iAkfYuUna0hzwf/BvsUTOY CMJA== X-Gm-Message-State: ANoB5plRfSwSsCsVTtt0VvowYY9gRrtBwoh9nnhbZzOMM96u8Iux+IQL gkMsagb12NA8pSziKDCKCK9XVRRLoq6K X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:6b9f:864c:28da:e99b]) (user=irogers job=sendgmr) by 2002:a05:6a00:4097:b0:576:cadf:16cc with SMTP id bw23-20020a056a00409700b00576cadf16ccmr22136338pfb.55.1670907723781; Mon, 12 Dec 2022 21:02:03 -0800 (PST) Date: Mon, 12 Dec 2022 21:00:39 -0800 In-Reply-To: <20221213050043.1199380-1-irogers@google.com> Message-Id: <20221213050043.1199380-6-irogers@google.com> Mime-Version: 1.0 References: <20221213050043.1199380-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.rc1.256.g54fd8350bd-goog Subject: [PATCH v1 5/9] perf stat: Remove evsel metric_name/expr From: Ian Rogers To: John Garry , Will Deacon , James Clark , Mike Leach , Leo Yan , Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Adrian Hunter , Kan Liang , Kim Phillips , Florian Fischer , Ravi Bangoria , Xing Zhengjun , Rob Herring , Kang Minchul , linux-arm-kernel@lists.infradead.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, Sandipan Das , Jing Zhang , linuxppc-dev@lists.ozlabs.org, Kajol Jain Cc: Stephane Eranian , Perry Taylor , Caleb Biggers , Ian Rogers X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1752074024016661582?= X-GMAIL-MSGID: =?utf-8?q?1752074024016661582?= Metrics are their own unit and these variables held broken metrics previously and now just hold the value NULL. Remove code that used these variables. Signed-off-by: Ian Rogers --- tools/perf/builtin-stat.c | 1 - tools/perf/util/cgroup.c | 1 - tools/perf/util/evsel.c | 2 - tools/perf/util/evsel.h | 2 - tools/perf/util/python.c | 7 --- tools/perf/util/stat-shadow.c | 112 ---------------------------------- tools/perf/util/stat.h | 1 - 7 files changed, 126 deletions(-) diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index d040fbcdcc5a..ac83b86cb247 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2529,7 +2529,6 @@ int cmd_stat(int argc, const char **argv) &stat_config.metric_events); zfree(&metrics); } - perf_stat__collect_metric_expr(evsel_list); perf_stat__init_shadow_stats(); if (add_default_attributes()) diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c index e99b41f9be45..dc2db0ff7ab4 100644 --- a/tools/perf/util/cgroup.c +++ b/tools/perf/util/cgroup.c @@ -468,7 +468,6 @@ int evlist__expand_cgroup(struct evlist *evlist, const char *str, nr_cgroups++; if (metric_events) { - perf_stat__collect_metric_expr(tmp_list); if (metricgroup__copy_metric_events(tmp_list, cgrp, metric_events, &orig_metric_events) < 0) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index 77b2cf5a214e..49460a224b0d 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -285,8 +285,6 @@ void evsel__init(struct evsel *evsel, evsel->sample_size = __evsel__sample_size(attr->sample_type); evsel__calc_id_pos(evsel); evsel->cmdline_group_boundary = false; - evsel->metric_expr = NULL; - evsel->metric_name = NULL; evsel->metric_events = NULL; evsel->per_pkg_mask = NULL; evsel->collect_stat = false; diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index d572be41b960..24cb807ef6ce 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -105,8 +105,6 @@ struct evsel { * metric fields are similar, but needs more care as they can have * references to other metric (evsel). */ - const char * metric_expr; - const char * metric_name; struct evsel **metric_events; struct evsel *metric_leader; diff --git a/tools/perf/util/python.c b/tools/perf/util/python.c index 7320f7f777fe..417db74fa04e 100644 --- a/tools/perf/util/python.c +++ b/tools/perf/util/python.c @@ -75,13 +75,6 @@ const char *perf_env__arch(struct perf_env *env __maybe_unused) return NULL; } -/* - * Add this one here not to drag util/stat-shadow.c - */ -void perf_stat__collect_metric_expr(struct evlist *evsel_list) -{ -} - /* * This one is needed not to drag the PMU bandwagon, jevents generated * pmu_sys_event_tables, etc and evsel__find_pmu() is used so far just for diff --git a/tools/perf/util/stat-shadow.c b/tools/perf/util/stat-shadow.c index 9bde9224a97c..35ea4813f468 100644 --- a/tools/perf/util/stat-shadow.c +++ b/tools/perf/util/stat-shadow.c @@ -346,114 +346,6 @@ static const char *get_ratio_color(enum grc_type type, double ratio) return color; } -static struct evsel *perf_stat__find_event(struct evlist *evsel_list, - const char *name) -{ - struct evsel *c2; - - evlist__for_each_entry (evsel_list, c2) { - if (!strcasecmp(c2->name, name) && !c2->collect_stat) - return c2; - } - return NULL; -} - -/* Mark MetricExpr target events and link events using them to them. */ -void perf_stat__collect_metric_expr(struct evlist *evsel_list) -{ - struct evsel *counter, *leader, **metric_events, *oc; - bool found; - struct expr_parse_ctx *ctx; - struct hashmap_entry *cur; - size_t bkt; - int i; - - ctx = expr__ctx_new(); - if (!ctx) { - pr_debug("expr__ctx_new failed"); - return; - } - evlist__for_each_entry(evsel_list, counter) { - bool invalid = false; - - leader = evsel__leader(counter); - if (!counter->metric_expr) - continue; - - expr__ctx_clear(ctx); - metric_events = counter->metric_events; - if (!metric_events) { - if (expr__find_ids(counter->metric_expr, - counter->name, - ctx) < 0) - continue; - - metric_events = calloc(sizeof(struct evsel *), - hashmap__size(ctx->ids) + 1); - if (!metric_events) { - expr__ctx_free(ctx); - return; - } - counter->metric_events = metric_events; - } - - i = 0; - hashmap__for_each_entry(ctx->ids, cur, bkt) { - const char *metric_name = (const char *)cur->key; - - found = false; - if (leader) { - /* Search in group */ - for_each_group_member (oc, leader) { - if (!strcasecmp(oc->name, - metric_name) && - !oc->collect_stat) { - found = true; - break; - } - } - } - if (!found) { - /* Search ignoring groups */ - oc = perf_stat__find_event(evsel_list, - metric_name); - } - if (!oc) { - /* Deduping one is good enough to handle duplicated PMUs. */ - static char *printed; - - /* - * Adding events automatically would be difficult, because - * it would risk creating groups that are not schedulable. - * perf stat doesn't understand all the scheduling constraints - * of events. So we ask the user instead to add the missing - * events. - */ - if (!printed || - strcasecmp(printed, metric_name)) { - fprintf(stderr, - "Add %s event to groups to get metric expression for %s\n", - metric_name, - counter->name); - free(printed); - printed = strdup(metric_name); - } - invalid = true; - continue; - } - metric_events[i++] = oc; - oc->collect_stat = true; - } - metric_events[i] = NULL; - if (invalid) { - free(metric_events); - counter->metric_events = NULL; - counter->metric_expr = NULL; - } - } - expr__ctx_free(ctx); -} - static double runtime_stat_avg(struct runtime_stat *st, enum stat_type type, int map_idx, struct runtime_stat_data *rsd) @@ -1299,10 +1191,6 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, color = NULL; print_metric(config, ctxp, color, "%8.1f%%", "Core Bound", core_bound * 100.); - } else if (evsel->metric_expr) { - generic_metric(config, evsel->metric_expr, evsel->metric_events, NULL, - evsel->name, evsel->metric_name, NULL, 1, - map_idx, out, st); } else if (runtime_stat_n(st, STAT_NSECS, map_idx, &rsd) != 0) { char unit = ' '; char unit_buf[10] = "/sec"; diff --git a/tools/perf/util/stat.h b/tools/perf/util/stat.h index 499c3bf81333..b1c29156c560 100644 --- a/tools/perf/util/stat.h +++ b/tools/perf/util/stat.h @@ -257,7 +257,6 @@ void perf_stat__print_shadow_stats(struct perf_stat_config *config, struct perf_stat_output_ctx *out, struct rblist *metric_events, struct runtime_stat *st); -void perf_stat__collect_metric_expr(struct evlist *); int evlist__alloc_stats(struct perf_stat_config *config, struct evlist *evlist, bool alloc_raw);