From nobody Wed Dec 17 03:00:15 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB787EE49B0 for ; Thu, 24 Aug 2023 04:14:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240075AbjHXEOe (ORCPT ); Thu, 24 Aug 2023 00:14:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240074AbjHXEOD (ORCPT ); Thu, 24 Aug 2023 00:14:03 -0400 Received: from mail-pg1-x549.google.com (mail-pg1-x549.google.com [IPv6:2607:f8b0:4864:20::549]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29E0F1713 for ; Wed, 23 Aug 2023 21:13:57 -0700 (PDT) Received: by mail-pg1-x549.google.com with SMTP id 41be03b00d2f7-56c4e3441f0so3414752a12.1 for ; Wed, 23 Aug 2023 21:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1692850436; x=1693455236; h=to:from:subject:references:mime-version:message-id:in-reply-to:date :from:to:cc:subject:date:message-id:reply-to; bh=2BhHz8yEC3pLTHC5QxPQtooiXn41z8hQeFyuHW+faxU=; b=5w0PmB8jTlGIO6l6Zpmp5jK22kd9GWITqHQyjbKGRdZcCGdCPsigR34nfN6+4tnhxT dnD95ihtffYI9ukp7ATsglhTrCW5D8ZsgF18W6LExTrBwdv+bVEMNSr+/qgnEeXN4HqN +5X8Kn23Cy2HzlKRGCLSZRN5piWmlS3squ8Px5XB2zrfY2VR8N5xkKlzsALS3kdCwskI 2x8JC6rX28d66hv10ndvlco4pwgDOdoQ7VSGBZloPwMQY4WP5+xCP7EJjZKDc0v79LXS msZSSCyRi5sgS89CaPJTEgW0R95rDfTKPBThDZZ3D9MorJa43JoOKegi1SOdAP2s0+ec xcVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692850436; x=1693455236; h=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=2BhHz8yEC3pLTHC5QxPQtooiXn41z8hQeFyuHW+faxU=; b=bHBZpRjnb2pc6FdKJTRbVzUMpP/bGbyKVnWkMl9VWIUlTli14TCyzRV+4MaMvpKBbK EV0V1Likn7L0Qe3yvgFt2x08T/xOJJkF40UCnGkHKCLXaptdA1/Rw9GrzRJqmTfrpHg/ bsImxJaw9Rix0hMG6KqOif7jXfX79sPQOEoaZM2/dkGAYwMvnaIP9hErRoEWvzSoWcGc tqaLPES3QRIXFVufU5j0eLrDTQCiTmrfQNSU/lUJp3gwXRpXbPmR9KZp+ML3ZfP1JmsN um73/ADRhqi76xQNCEEO50sJUB39/A87TasgxKfcgP+Z4rwNkJ6vJ6Oq9mLPuTe9RKsX eLOw== X-Gm-Message-State: AOJu0YzzlPHjDPHbRTAfFVJljMpwjfCXu3BKhuHRAaJNXubVgd1ZX76l yMhoy5WfX2+SMvJThoiBgbAGumMujduW X-Google-Smtp-Source: AGHT+IGUi6LS5pUmuPAExD0diPuK2wX3IZnkRAIaW7HOWdNG1KsUu72YQfpTzNbinwYI8ZlJyOoYKJ1dSiJn X-Received: from irogers.svl.corp.google.com ([2620:15c:2a3:200:fbb9:d9e7:7405:2651]) (user=irogers job=sendgmr) by 2002:a65:6a87:0:b0:563:e825:7f3a with SMTP id q7-20020a656a87000000b00563e8257f3amr2463561pgu.11.1692850436670; Wed, 23 Aug 2023 21:13:56 -0700 (PDT) Date: Wed, 23 Aug 2023 21:13:18 -0700 In-Reply-To: <20230824041330.266337-1-irogers@google.com> Message-Id: <20230824041330.266337-7-irogers@google.com> Mime-Version: 1.0 References: <20230824041330.266337-1-irogers@google.com> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog Subject: [PATCH v2 06/18] perf s390 s390_cpumcfdg_dump: Don't scan all PMUs From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Ian Rogers , Adrian Hunter , James Clark , Kan Liang , John Garry , Kajol Jain , Jing Zhang , Ravi Bangoria , Rob Herring , Gaosheng Cui , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Rather than scanning all PMUs for a counter name, scan the PMU associated with the evsel of the sample. This is done to remove a dependence on pmu-events.h. Signed-off-by: Ian Rogers --- tools/perf/util/s390-sample-raw.c | 50 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/tools/perf/util/s390-sample-raw.c b/tools/perf/util/s390-sampl= e-raw.c index 91330c874170..dc1ed3e95d4d 100644 --- a/tools/perf/util/s390-sample-raw.c +++ b/tools/perf/util/s390-sample-raw.c @@ -27,7 +27,7 @@ #include "color.h" #include "sample-raw.h" #include "s390-cpumcf-kernel.h" -#include "pmu-events/pmu-events.h" +#include "util/pmu.h" #include "util/sample.h" =20 static size_t ctrset_size(struct cf_ctrset_entry *set) @@ -132,56 +132,57 @@ static int get_counterset_start(int setnr) =20 struct get_counter_name_data { int wanted; - const char *result; + char *result; }; =20 -static int get_counter_name_callback(const struct pmu_event *evp, - const struct pmu_events_table *table __maybe_unused, - void *vdata) +static int get_counter_name_callback(void *vdata, struct pmu_event_info *i= nfo) { struct get_counter_name_data *data =3D vdata; int rc, event_nr; + const char *event_str; =20 - if (evp->name =3D=3D NULL || evp->event =3D=3D NULL) + if (info->str =3D=3D NULL) return 0; - rc =3D sscanf(evp->event, "event=3D%x", &event_nr); + + event_str =3D strstr(info->str, "event=3D"); + if (!event_str) + return 0; + + rc =3D sscanf(event_str, "event=3D%x", &event_nr); if (rc =3D=3D 1 && event_nr =3D=3D data->wanted) { - data->result =3D evp->name; + data->result =3D strdup(info->name); return 1; /* Terminate the search. */ } return 0; } =20 -/* Scan the PMU table and extract the logical name of a counter from the - * PMU events table. Input is the counter set and counter number with in t= he - * set. Construct the event number and use this as key. If they match retu= rn - * the name of this counter. +/* Scan the PMU and extract the logical name of a counter from the event. = Input + * is the counter set and counter number with in the set. Construct the ev= ent + * number and use this as key. If they match return the name of this count= er. * If no match is found a NULL pointer is returned. */ -static const char *get_counter_name(int set, int nr, const struct pmu_even= ts_table *table) +static char *get_counter_name(int set, int nr, struct perf_pmu *pmu) { struct get_counter_name_data data =3D { .wanted =3D get_counterset_start(set) + nr, .result =3D NULL, }; =20 - if (!table) + if (!pmu) return NULL; =20 - pmu_events_table__for_each_event(table, get_counter_name_callback, &data); + perf_pmu__for_each_event(pmu, &data, get_counter_name_callback); return data.result; } =20 -static void s390_cpumcfdg_dump(struct perf_sample *sample) +static void s390_cpumcfdg_dump(struct perf_pmu *pmu, struct perf_sample *s= ample) { size_t i, len =3D sample->raw_size, offset =3D 0; unsigned char *buf =3D sample->raw_data; const char *color =3D PERF_COLOR_BLUE; struct cf_ctrset_entry *cep, ce; - const struct pmu_events_table *table; u64 *p; =20 - table =3D pmu_events_table__find(); while (offset < len) { cep =3D (struct cf_ctrset_entry *)(buf + offset); =20 @@ -199,11 +200,12 @@ static void s390_cpumcfdg_dump(struct perf_sample *sa= mple) color_fprintf(stdout, color, " [%#08zx] Counterset:%d" " Counters:%d\n", offset, ce.set, ce.ctr); for (i =3D 0, p =3D (u64 *)(cep + 1); i < ce.ctr; ++i, ++p) { - const char *ev_name =3D get_counter_name(ce.set, i, table); + char *ev_name =3D get_counter_name(ce.set, i, pmu); =20 color_fprintf(stdout, color, "\tCounter:%03d %s Value:%#018lx\n", i, ev_name ?: "", be64_to_cpu(*p)); + free(ev_name); } offset +=3D ctrset_size(&ce); } @@ -216,14 +218,14 @@ static void s390_cpumcfdg_dump(struct perf_sample *sa= mple) */ void evlist__s390_sample_raw(struct evlist *evlist, union perf_event *even= t, struct perf_sample *sample) { - struct evsel *ev_bc000; + struct evsel *evsel; =20 if (event->header.type !=3D PERF_RECORD_SAMPLE) return; =20 - ev_bc000 =3D evlist__event2evsel(evlist, event); - if (ev_bc000 =3D=3D NULL || - ev_bc000->core.attr.config !=3D PERF_EVENT_CPUM_CF_DIAG) + evsel =3D evlist__event2evsel(evlist, event); + if (evsel =3D=3D NULL || + evsel->core.attr.config !=3D PERF_EVENT_CPUM_CF_DIAG) return; =20 /* Display raw data on screen */ @@ -231,5 +233,5 @@ void evlist__s390_sample_raw(struct evlist *evlist, uni= on perf_event *event, str pr_err("Invalid counter set data encountered\n"); return; } - s390_cpumcfdg_dump(sample); + s390_cpumcfdg_dump(evsel->pmu, sample); } --=20 2.42.0.rc1.204.g551eb34607-goog