From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.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 A6F411891A8 for ; Sat, 21 Dec 2024 19:27:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734809223; cv=none; b=sRa6Ev5i0ICzsmR8ma3sYKazAlgJNJEHC5ytmJmxvxtVzwVF1FUQrjlXgPb98LMQxNkhVAd3xR1fR7NEc2nyCnDt7Ol+W0QzWXiF0S1Ij6F5EL14lJ9nauuMwU1noow0KE0FAs92pOJctriyQxEC4jTDLgWotFEW2TPVpI67KlU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734809223; c=relaxed/simple; bh=z0BXIU+cy5J4APMsTNwNrDiG3aEgH1lNySzfDNpVA+Q=; h=Date:In-Reply-To:Message-Id:Mime-Version:References:Subject:From: To:Cc:Content-Type; b=jNeXKz2UWSER9Sbu4NmMGdyGRZ/mj0EexxOfpM7eJXu0UgyoVaH3FDxpApb28kBKQ0WTTmtYFImPNiVT0S7ILgKYGTn3TWJvX6UBOiZ95StImfkCHYiU9XJixrXU+j6sholpPdk9Jf4gXMC0MnpfKr13mHuUm8iyF5Mzc80SbX0= 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=XqQEcoTX; arc=none smtp.client-ip=209.85.128.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="XqQEcoTX" Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-6efa5bf51d1so33617057b3.3 for ; Sat, 21 Dec 2024 11:27:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1734809221; x=1735414021; 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=To5Q6DXsmBuoVyAB+Coe+PRFSr7U5wanl+AgsMSjmUE=; b=XqQEcoTXhp/9f8BVzb08Zaz31FZtXl0B2dVcGvtpqPj3XXUpFhnaKskf8QWJYRx5mT Z5+m+UpQj8UYHyJDVb/No5a+xJSDNLCVIFq1WNU5fq6vwfAaDIOPbql8+nI4Cj4ZbWaJ pncvT6YvWS0AHIpQbRdp6t+KrWrmhJHGvnl7Pj8EQMhxUtdVyWgJ0msojFGteiNrPy1o 36qHHkse74BsVKTQtMSWcx2geJvZHegcwDxa6g0q4vcwDNS4ZEdxxGCQ9S44wrw0jYXD myXPCqt9ALDvW2W4t0ODZSURkDw6A/0wjzp0iopboq4votGQIbqyhQPT3x/09CPXS6Fm 08OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734809221; x=1735414021; 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=To5Q6DXsmBuoVyAB+Coe+PRFSr7U5wanl+AgsMSjmUE=; b=NQ7vbsXn/uPC38ihzPEMF32Nx28TovO0v0pFzT25KyzLwg1BX/+LrModw1phA8qv6l tA5uMn2fo8QFc4I9cvb8qIl9yYQjdHSySlPXb7PmLIxsMXFCXL1Zdzi0Ybup2/TpXZ9q vPFEZcFirQ68LAwuo/UWR45DJaFgqCzVF8TiwQO/c/dXxTx3r79R95iM8gmRxjG4NWcE rB3pnw74TI+1CV+PcQJ93F42I8bQkjDPb+NLf/sa0jbiCwZ/QAdrXNJBZSmrSK6AzUPK SSPpkR+Fz0Ad84tDkVfWfqtN8I+3ayySbQr6qKlGi9Qqo2EfEtQAXMs+af6FpB/o0aOL oRTA== X-Forwarded-Encrypted: i=1; AJvYcCXz6XKQ/I+VEm6Uey75kh1Lp8+RC1irg6D9tvPr62VoE1GRa7jGe8uM1rYrlgfomMDLDPAF/bsC2ehKNAcS5W8h@vger.kernel.org X-Gm-Message-State: AOJu0YxgNHm+Dfe/WHhp1tOBS3adXoHoWEQtjyghcOuF2kJU7Bu2BuGq 0Wes0SUl23xevrk9mOI7hockUsYpy0RMqyqYBujDEtsdXtiFgPFmD1j7VUqbx4J6xlAuU3YLO5w zlQb/cg== X-Google-Smtp-Source: AGHT+IFhFbpXLuh09c3OfbDr6j+ZeLOL/XrOzEbPkiGL/D7Eikc8Jn90QIx8Q+lGeqhu14rEJvLMbRvQzmio X-Received: from irogers.svl.corp.google.com ([2620:15c:2c5:11:a2bc:ec03:1143:41ab]) (user=irogers job=sendgmr) by 2002:a25:2705:0:b0:e39:8506:c03d with SMTP id 3f1490d57ef6-e538c3cb14bmr16811276.9.1734809220613; Sat, 21 Dec 2024 11:27:00 -0800 (PST) Date: Sat, 21 Dec 2024 11:26:51 -0800 In-Reply-To: <20241221192654.94344-1-irogers@google.com> Message-Id: <20241221192654.94344-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: <20241221192654.94344-1-irogers@google.com> X-Mailer: git-send-email 2.47.1.613.gc27f4b7a9f-goog Subject: [PATCH v3 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 6ae5d110994a..109c4f188dec 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 5ad352c94d00..cfa2660a06e8 100644 --- a/tools/perf/util/evsel.h +++ b/tools/perf/util/evsel.h @@ -235,6 +235,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