From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1AB9C2054E5 for ; Thu, 9 Jan 2025 22:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736461286; cv=none; b=kHr+J4npa8Xum1mLMUdgLGJYVTTlkNQzpLL2lO359rNwigSTMkYeTsx3ivSlyhMmDmrEkZLAxqD5gpNHZE1+Of3/9XHFKge2POR54He47Aa5AT/DPV98pmiSGrZZooZQ7VKmnsYzcfby8VSFUnAShHSV5VbFd6g/FgQmL3XgD8Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736461286; c=relaxed/simple; bh=3fyRdYULzCN3MTYnfAQ+Nm9siIjPNFw3tb7woOJt0Yk=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=WnF4bTLkJOyNdFWnB2KONV/8aLGomXHh7oCIcd2ExvslBwKuOO2g4E89ucRsw3LDTD9Ipe8u/LSgC96zFWaLwClpHoY7wEUGgKwAw1kjjEDTWoHnRySnh4Tug4M/Y61lejLVYRECXF77xZRfIftwn4FIXt5cDRa9lIIPIGdGAp4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=eH4BThZ6; arc=none smtp.client-ip=209.85.219.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--irogers.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="eH4BThZ6" Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e549dac2eccso3781970276.0 for ; Thu, 09 Jan 2025 14:21:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1736461284; x=1737066084; darn=vger.kernel.org; h=cc:to:from:subject:references:mime-version:message-id:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SuhWWO6Q6WZEB3o/osEw6pkCcgeBn8X4yXFkO6XvAnA=; b=eH4BThZ6QCzHbOLvryy8yiN/sZqkZwNe+uSYEq1MIvmLBv2jGl49t1do40E/DPrbNm RZtlf6/oJUMajkC07XKjGGvNb7oCNPAprJKYa21w+msQ3/Wxbmmk33SKIVogkUUSVlzD +KLh1k+53D514QtxxJeoIeb1YazvGAkadHPJGvymbvQ4FMFBC1tQdX/QSBY39OLD4wLN iabIWSzV87xunEHMvQ5Mj3FRTs8M38BaIl5dvKGl8bbhZl69DcLmU3PxlN2pZO/bKLIY oN4CZsdWcRv/L3JpeeupNV+gNUkSmVrzyKBSf6I0rSFT9uog5QqbpeInbBguuwWQrOdr Y/MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736461284; x=1737066084; 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=SuhWWO6Q6WZEB3o/osEw6pkCcgeBn8X4yXFkO6XvAnA=; b=DqUmy+dJqZKeWDDULpdrwZbEt+UskkYx31i+yepApAHpkeAzgXd6/Fm3TFq4st75jN 2DD5oFeias/HMmCucsH6OsUOZbzUhLhSvv1ekhLEW6hLAwNMGvWmzzFQqtgk1Zv+z6gO ccNF2xqapr9uPwFIHHobiFdgCrlRLE5wF3/sSxblQlvmvsbdL7GagfJnw5N7JF1xYxY1 Lhwy0LbdyzD2GCvHNmZx8J+H6CX8ZOnLJV8/mmirNkw9RFicwd9KqNqKuZ1Jn9T+7Ogu jaZOvk/nJKkpbsGUp6w8djkBjxQ6snFBTYgdQaJBSRKMAounxTNpOnHGOYO0Z12KVW5+ r9Qw== X-Forwarded-Encrypted: i=1; AJvYcCVwguI7cGE+8Icj4IdXH5WiJjtIJ249l/rdYOSZWtMHuWPgrEyz7epo/rcdT7mM9aTobqh3fEMVc0zFrxhRyByb@vger.kernel.org X-Gm-Message-State: AOJu0YxOS/14VO5gp92gFJ6CMfQphmkAelLZQRy6Re5xcquagF8RtX3X 5Dgrot8aNBpsxAWxj4B/SGhnE8mYMrdQYa7taxdaqZYqj2gVxIbgWs8fAmFNhZJruLhCNcmQLps ecA9POg== X-Google-Smtp-Source: AGHT+IEiDOmJm22fE+a1VviBu2xKodkwuLge66gjDYaGITLNEuD+cAMnJj6OhIIJzoCm936tjQ8xgSbqHO8m X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:7ea3:d1e5:495a:9a4f]) (user=irogers job=sendgmr) by 2002:a25:7a45:0:b0:e48:4eb:2653 with SMTP id 3f1490d57ef6-e54ee1653edmr17157276.3.1736461284133; Thu, 09 Jan 2025 14:21:24 -0800 (PST) Date: Thu, 9 Jan 2025 14:21:06 -0800 In-Reply-To: <20250109222109.567031-1-irogers@google.com> Message-Id: <20250109222109.567031-2-irogers@google.com> Precedence: bulk X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250109222109.567031-1-irogers@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v5 1/4] perf evsel: Add pmu_name helper From: Ian Rogers To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Namhyung Kim , Mark Rutland , Alexander Shishkin , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , James Clark , Ze Gao , Weilin Wang , Dominique Martinet , Jean-Philippe Romain , Junhao He , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Aditya Bodkhe Cc: Leo Yan , Atish Patra Content-Type: text/plain; charset="UTF-8" Add helper to get the name of the evsel's PMU. This handles the case where there's no sysfs PMU via parse_events event_type helper. Signed-off-by: Ian Rogers Tested-by: James Clark Tested-by: Leo Yan Tested-by: Atish Patra --- tools/perf/util/evsel.c | 10 ++++++++++ tools/perf/util/evsel.h | 1 + 2 files changed, 11 insertions(+) diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index bc144388f892..026cf9a9893c 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -237,6 +237,16 @@ int evsel__object_config(size_t object_size, int (*init)(struct evsel *evsel), return 0; } +const char *evsel__pmu_name(const struct evsel *evsel) +{ + struct perf_pmu *pmu = evsel__find_pmu(evsel); + + if (pmu) + return pmu->name; + + return event_type(evsel->core.attr.type); +} + #define FD(e, x, y) (*(int *)xyarray__entry(e->core.fd, x, y)) int __evsel__sample_size(u64 sample_type) diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h index 5e789fa80590..2dd108a14b89 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -236,6 +236,7 @@ int evsel__object_config(size_t object_size, void (*fini)(struct evsel *evsel)); struct perf_pmu *evsel__find_pmu(const struct evsel *evsel); +const char *evsel__pmu_name(const struct evsel *evsel); bool evsel__is_aux_event(const struct evsel *evsel); struct evsel *evsel__new_idx(struct perf_event_attr *attr, int idx); -- 2.47.1.613.gc27f4b7a9f-goog