From patchwork Wed Dec 21 22:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Rogers X-Patchwork-Id: 13079208 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 59B8EC4332F for ; Wed, 21 Dec 2022 22:38:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=7k0MqlzuZZPUoCwNs5a6Xwf40UtBtQz18GROqeY/KfE=; b=qiCa6CM6h4U9ZiD1zCO3WAz+b2 PruYNA1gjO5JD4uX9b+5rnZUt3hw/7UugVznkDiT5X/z8fK6d19qbRQilMDbft4nJ3Aqdir1kTABT fNwceHKSUdcjK5xAtvwc91aP9nbRvl263UaCROPB/QZXIxMIED8IU+cBhHZat4dmTZjjQJLcAIxLu ll2a1ITGBYf2ONQb0/rU6YrdXaoYZD0yE0NsRNUQZHoHBvEVf+QFnjaY3QBLTf2hfrAiS3AanyTxT 0I1QugwmhQN0hH/181P2FIvz+pvxz7vTmsnTyh6ynOxITnvMVXaolKWZrkBuXZ2X6GRLOboJOWSLc 8twys40w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1p87hx-003ALz-P7; Wed, 21 Dec 2022 22:37:07 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1p87gE-0039KW-9x for linux-arm-kernel@bombadil.infradead.org; Wed, 21 Dec 2022 22:35:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Type:Cc:To:From:Subject: References:Mime-Version:Message-Id:In-Reply-To:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=A5e+q2J2T13Zjvz/NSuIdISxQnXr8PJB3Wc0tTKT5vY=; b=YAJAcVD5M6I/l8NNejSpLF9nqN VAMlja1xlJ++yT4Yh+ekORw5UANmX4qtPGTYFnrpoYbdzLeoMDRgYNHckRBgqqbS59xNG3gO4oABP N80ASeNLZ67twsU2U2LkGDrzYd8DdCvN1DyWvTVvpfRU838FWWx32jUXDGivDVbvA8TbSwOkpLlU1 5WdQ8FpMLMQVJDXKFUkhVNGKNJtyxi6j1yF1z7xZXkya5qB9mwz7+ZAaRu+byVhE9hRlCYAzgyaXS o9crBipzwHylwDTG2ArXh09HlZc4bWschSjyKqqrMtWTKXykhRvTucAyaRyga8KGDIdUTvUJAfs8U sMIQWgKQ==; Received: from mail-yb1-xb49.google.com ([2607:f8b0:4864:20::b49]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1p87g8-00DX5Y-0E for linux-arm-kernel@lists.infradead.org; Wed, 21 Dec 2022 22:35:15 +0000 Received: by mail-yb1-xb49.google.com with SMTP id y6-20020a25b9c6000000b006c1c6161716so22185ybj.8 for ; Wed, 21 Dec 2022 14:35:11 -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=A5e+q2J2T13Zjvz/NSuIdISxQnXr8PJB3Wc0tTKT5vY=; b=aFZ+LpBPBWHwljcXxvgoSkrKpfn4vq/pAQhTdoqJDKJ3/jamd3650pn5kRPZwfutSb ypM+VTaEjb+lF3d6L6CzC6xarC2kUModgKntYDc1H/CnF5tU//k8jgSDginpbcEzhCTk raCv9myav/YWCpJOwFwwfrAseUyq9csf+wPfOgd+4Gm89Z7zLPY+6GEvzXwI2gvUHCBD IhoaCG1QlP/t/0Jspj5M/vWTONQbBobmtCGieH6iSkVVY4wWzqNPzuErZrx31m7UAxmI T7Ia7YYec8Wf/fMD1Ywjs3LYt8JekMUoHdLHt7FXEywrAsQ26CVb61W2bxfZjW11bb1i PEkg== 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=A5e+q2J2T13Zjvz/NSuIdISxQnXr8PJB3Wc0tTKT5vY=; b=YSJkLEeW64t4sF0O1DAVEV7PTaAZv5xRozJGbNE0J5HqeXbXwkksVNK4KNBFPa0GkA J1wMxbVMJmXxrg15TR40g1ovo5EqBbtAZuaAG3Ro3CRuU3YCQjqpJMjV3lyj5HNFphms lwPeoHdM+h88Sgw6wpSDM/eLpB0dVKNWrlLHLhMNVQi+NYErTaviPaNp5ugd/jPMiIcq FzYVtVIIUS7QNti33rRZhvXAtN6jn4PrJ5/zsSi3RhUa71MWEAGFLGFKADYSr1U538T1 GfoDDhVuCDF7Qxmu6TsQJM9zteyM5P/m7gMg/N+BwGJkmcdlnYaPYv6vsAHPGqRw1pAl tmrw== X-Gm-Message-State: AFqh2kraLPSjpLE/tNA8nZBv5apMKVXnIJi6o3qZtewNturCwY5BW9Cg cqNYylGuewL6CNuxAgMV6vT2zyGiRdsK X-Google-Smtp-Source: AMrXdXsGZ3Drpvj0peXwqzWVI5ormin6RpJoMKCej19VRZJ90L1xJTqpRv14sEFlGAt2+X6k2RQ4OrUu7PyV X-Received: from irogers.svl.corp.google.com ([2620:15c:2d4:203:62bd:f120:1fd8:1d21]) (user=irogers job=sendgmr) by 2002:a05:6902:3ce:b0:6f8:92de:92e3 with SMTP id g14-20020a05690203ce00b006f892de92e3mr350895ybs.105.1671662108352; Wed, 21 Dec 2022 14:35:08 -0800 (PST) Date: Wed, 21 Dec 2022 14:34:16 -0800 In-Reply-To: <20221221223420.2157113-1-irogers@google.com> Message-Id: <20221221223420.2157113-6-irogers@google.com> Mime-Version: 1.0 References: <20221221223420.2157113-1-irogers@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Subject: [PATCH v2 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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221221_223512_479797_E2405C32 X-CRM114-Status: GOOD ( 18.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 Reviewed-by: John Garry --- 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 9f3e4b257516..5d18a5a6f662 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c @@ -2524,7 +2524,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 999dd1700502..4d198529911a 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 212031b97910..8c450b3d0080 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 cadb2df23c87..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 = cur->pkey; - - 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);