From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) (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 12C152054E2 for ; Thu, 9 Jan 2025 22:21:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736461286; cv=none; b=GZxafV/ZaHLjXcNMXogWXcQYWzGvujzIwbUChKgNId0DurN6aTd5gshGCwNyLlIuBY1bftyBF4ArZud8CPw7lVreZPEA9NeuYPkA4btlvid0qqO14aAGDi2LelH8MjQiPtVFfnNW06Z0S+nX1XwzGo9bhkbYV5KgNULqVmpA6Vk= 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.201 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-f201.google.com with SMTP id 3f1490d57ef6-e549dac2eccso3781971276.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=lIITHV5f01tpyQlZphM+ZL3PJEQMneM0iphIargykXObytsxu4pK5jmLAUGCSJL5Db ii+TD5NPrm7KJOib5+7YV7oSqffbe0QY5ljgjZ4bRg5CQ5h0C+GbFjD3nE9Ih1e2oiLb QFgbXMEwBCHSh+SjNSNh3LcB71dUvGY3gTw4UdiGApNbyHA4zPtikjLIPB8loTz9Ma1A 7mR5E1IN7LPmP4CxpmAtou3IbVTS8S1DrvfVW991FxKqdvAAyaOLnv5uMJfpUtK42RZl ht7QKVkcfmOdj6g7JNa9hScyJ3kVBur9meytwVc971izPQT/bvE1JzP0ls1+bd3wZM6Z i/eA== X-Forwarded-Encrypted: i=1; AJvYcCVbdsF12ElJ17Mr/0RCofdZkmQz0HFzvAp9cZG9GWGC+r0bKR6PZ+dwa7zCflIFQAiQPXwEddrzu+Fi6Jo=@vger.kernel.org X-Gm-Message-State: AOJu0YwTNI/Rjtwar5jhsZZXLoNuNE5fyWsTO9mKNsSqIp0wrGSCUwud 6LhTYWNunGTMw/dIk5R4RHh+f45d0aRROgCPN3yQQC5/VdW/2b3C+WOUHIunGm6BMSgElHelBtC djbnwvg== 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-kernel@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