linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Ian Rogers <irogers@google.com>
Cc: Weilin Wang <weilin.wang@intel.com>,
	Perry Taylor <perry.taylor@intel.com>,
	Caleb Biggers <caleb.biggers@intel.com>,
	Leo Yan <leo.yan@linaro.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>, Namhyung Kim <namhyung@kernel.org>,
	Sandipan Das <sandipan.das@amd.com>,
	Kajol Jain <kjain@linux.ibm.com>,
	Zhengjun Xing <zhengjun.xing@linux.intel.com>,
	Ravi Bangoria <ravi.bangoria@amd.com>,
	Xin Gao <gaoxin@cdjrlc.com>, Rob Herring <robh@kernel.org>,
	linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
	Stephane Eranian <eranian@google.com>
Subject: Re: [PATCH v1 1/9] perf pmu: Add documentation
Date: Mon, 14 Nov 2022 10:26:48 -0500	[thread overview]
Message-ID: <3464d5c2-0438-18ba-fbea-ab95ca5f22b4@linux.intel.com> (raw)
In-Reply-To: <CAP-5=fUTDtGDJ3ONW5iKaeszDRwezzZCJCW59yvXQ4tEYyHsdg@mail.gmail.com>



On 2022-11-14 9:09 a.m., Ian Rogers wrote:
> On Mon, Nov 14, 2022 at 5:40 AM Liang, Kan <kan.liang@linux.intel.com> wrote:
>>
>>
>>
>> On 2022-11-14 2:51 a.m., Ian Rogers wrote:
>>> Add documentation to struct perf_pmu and the associated structs of
>>> perf_pmu_alias and perf_pmu_format.
>>>
>>> Signed-off-by: Ian Rogers <irogers@google.com>
>>> ---
>>>  tools/perf/util/pmu.c |  14 ++++++
>>>  tools/perf/util/pmu.h | 105 +++++++++++++++++++++++++++++++++++++++---
>>>  2 files changed, 113 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
>>> index 6a86e6af0903..a8f9f47c6ed9 100644
>>> --- a/tools/perf/util/pmu.c
>>> +++ b/tools/perf/util/pmu.c
>>> @@ -31,10 +31,24 @@
>>>
>>>  struct perf_pmu perf_pmu__fake;
>>>
>>> +/**
>>> + * Values from a format file read from <sysfs>/devices/cpu/format/ held in
>>> + * struct perf_pmu. For example, the contents of
>>> + * <sysfs>/devices/cpu/format/event may be "config:0-7" and will be represented
>>> + * here as name="event", value=PERF_PMU_FORMAT_VALUE_CONFIG and bits 0 to 7 will
>>> + * be set.
>>> + */
>>>  struct perf_pmu_format {
>>> +     /** The modifier/file name. */
>>>       char *name;
>>> +     /**
>>> +      * Which config value the format relates to. Supported values are from
>>> +      * PERF_PMU_FORMAT_VALUE_CONFIG to PERF_PMU_FORMAT_VALUE_CONFIG_END.
>>> +      */
>>>       int value;
>>> +     /** Which config bits are set by this format value. */
>>>       DECLARE_BITMAP(bits, PERF_PMU_FORMAT_BITS);
>>> +     /** Element on list within struct perf_pmu. */
>>>       struct list_head list;
>>>  };
>>>
>>> diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
>>> index 68e15c38ae71..29571c0f9d15 100644
>>> --- a/tools/perf/util/pmu.h
>>> +++ b/tools/perf/util/pmu.h
>>> @@ -34,30 +34,91 @@ struct perf_pmu_caps {
>>>  };
>>>
>>>  struct perf_pmu {
>>> +     /** The name of the PMU such as "cpu". */
>>>       char *name;
>>> +     /**
>>> +      * Optional alternate name for the PMU determined in architecture
>>> +      * specific code.
>>> +      */
>>>       char *alias_name;
>>> +     /**
>>> +      * Optional PMU identifier read from
>>> +      * <sysfs>/bus/event_source/devices/<name>/identifier.
>>> +      */
>>>       char *id;
>>> +     /**
>>> +      * Perf event attributed type value, read from
>>> +      * <sysfs>/bus/event_source/devices/<name>/type.
>>> +      */
>>>       __u32 type;
>>> +     /**
>>> +      * Can the PMU name be selected as if it were an event?
>>> +      */
>>>       bool selectable;
>>> +     /**
>>> +      * Is the PMU not within the CPU core? Determined by the presence of
>>> +      * <sysfs>/bus/event_source/devices/<name>/cpumask.
>>> +      */
>>>       bool is_uncore;
>>> +     /** Is the PMU name either cpu_core or cpu_atom. */
>>
>> I don't think we want to limit the hybrid names only to cpu_core or
>> cpu_atom. Maybe something as below?
>> /* Is a hybrid CPU PMU, e.g., cpu_core, cpu_atom. */
> 
> Currently the hybrid code only works for cpu_core or cpu_atom, a
> limitation of its implementation. 

I don't think so. See perf_pmu__hybrid_mounted(). If a PMU is named as
"cpu_", we treat it as a hybrid CPU PMU. The cpu_core or cpu_atom should
only be hard coded to specially handle some model-specific cases, e.g.,
mem-loads-aux event.

Thanks,
Kan

> As pointed out in a later patch,
> this bool isn't being used when it could be and I think we can work to
> remove it. It would be possible to remove all uses of this with
> perf_pmu__is_hybrid. As such I think it may be useful to mark the
> hybrid variables in struct perf_pmu as deprecated while we work to
> replace their use with more generic just any PMU code.
> 
> Thanks,
> Ian
> 
>> Thanks,
>> Kan
>>
>>>       bool is_hybrid;
>>> +     /**
>>> +      * Are events auxiliary events? Determined in architecture specific
>>> +      * code.
>>> +      */
>>>       bool auxtrace;
>>> +     /**
>>> +      * Number of levels of :ppp precision supported by the PMU, read from
>>> +      * <sysfs>/bus/event_source/devices/<name>/caps/max_precise.
>>> +      */
>>>       int max_precise;
>>> +     /**
>>> +      * Optional default perf_event_attr determined in architecture specific
>>> +      * code.
>>> +      */
>>>       struct perf_event_attr *default_config;
>>> +     /**
>>> +      * Empty or the contents of either of:
>>> +      * <sysfs>/bus/event_source/devices/<name>/cpumask.
>>> +      * <sysfs>/bus/event_source/devices/<cpu>/cpus.
>>> +      */
>>>       struct perf_cpu_map *cpus;
>>> -     struct list_head format;  /* HEAD struct perf_pmu_format -> list */
>>> -     struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
>>> +     /**
>>> +      * Holds the contents of files read from
>>> +      * <sysfs>/bus/event_source/devices/<name>/format/. The contents specify
>>> +      * which event parameter changes what config, config1 or config2 bits.
>>> +      */
>>> +     struct list_head format;
>>> +     /**
>>> +      * List of struct perf_pmu_alias. Each alias corresponds to an event
>>> +      * read from <sysfs>/bus/event_source/devices/<name>/events/ or from
>>> +      * json events in pmu-events.c.
>>> +      */
>>> +     struct list_head aliases;
>>> +     /** Has the list caps been initialized? */
>>>       bool caps_initialized;
>>> +     /** The length of the list caps. */
>>>       u32 nr_caps;
>>> -     struct list_head caps;    /* HEAD struct perf_pmu_caps -> list */
>>> -     struct list_head list;    /* ELEM */
>>> +     /**
>>> +      * Holds the contents of files read from
>>> +      * <sysfs>/bus/event_source/devices/<name>/caps/. The contents are pairs
>>> +      * of the filename with the value of its contents, for example,
>>> +      * max_precise (see above) may have a value of 3.
>>> +      */
>>> +     struct list_head caps;
>>> +     /** Element on pmus list in pmu.c. */
>>> +     struct list_head list;
>>> +     /** Element on perf_pmu__hybrid_pmus. */
>>>       struct list_head hybrid_list;
>>>
>>> +     /** Features to inhibit when events on this PMU are opened. */
>>>       struct {
>>> +             /** Disables perf_event_attr exclude_guest and exclude_host. */
>>>               bool exclude_guest;
>>>       } missing_features;
>>>  };
>>>
>>> +/** A special global PMU used for testing. */
>>>  extern struct perf_pmu perf_pmu__fake;
>>>
>>>  struct perf_pmu_info {
>>> @@ -71,21 +132,53 @@ struct perf_pmu_info {
>>>
>>>  #define UNIT_MAX_LEN 31 /* max length for event unit name */
>>>
>>> +/**
>>> + * An event either read from sysfs or builtin in pmu-events.c, created by
>>> + * parsing the pmu-events json files.
>>> + */
>>>  struct perf_pmu_alias {
>>>       char *name;
>>> +     /** Optional short description of the event. */
>>>       char *desc;
>>> +     /** Optional long description. */
>>>       char *long_desc;
>>> +     /**
>>> +      * Optional topic such as cache or pipeline, particularly for json
>>> +      * events.
>>> +      */
>>>       char *topic;
>>> +     /** Comma separated parameter list. */
>>>       char *str;
>>> -     struct list_head terms; /* HEAD struct parse_events_term -> list */
>>> -     struct list_head list;  /* ELEM */
>>> +     /** Owned list of the original parsed parameters. */
>>> +     struct list_head terms;
>>> +     /** List element of struct perf_pmu aliases. */
>>> +     struct list_head list;
>>> +     /** Units for the event, such as bytes or cache lines. */
>>>       char unit[UNIT_MAX_LEN+1];
>>> +     /** Value to scale read counter values by. */
>>>       double scale;
>>> +     /**
>>> +      * Does the file
>>> +      * <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.per-pkg or
>>> +      * equivalent json value exist and have the value 1.
>>> +      */
>>>       bool per_pkg;
>>> +     /**
>>> +      * Does the file
>>> +      * <sysfs>/bus/event_source/devices/<pmu_name>/events/<name>.snapshot
>>> +      * exist and have the value 1.
>>> +      */
>>>       bool snapshot;
>>> +     /** Is the event hidden and so not shown in perf list by default. */
>>>       bool deprecated;
>>> +     /**
>>> +      * A metric expression associated with an event. Doing this makes little
>>> +      * sense due to scale and unit applying to both.
>>> +      */
>>>       char *metric_expr;
>>> +     /** A name for the metric. unit applying to both. */
>>>       char *metric_name;
>>> +     /** The name copied from struct perf_pmu. */
>>>       char *pmu_name;
>>>  };
>>>

  reply	other threads:[~2022-11-14 15:27 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14  7:51 [PATCH v1 0/9] Restructure perf list and add json output Ian Rogers
2022-11-14  7:51 ` [PATCH v1 1/9] perf pmu: Add documentation Ian Rogers
2022-11-14  8:55   ` Adrian Hunter
2022-11-14 14:10     ` Ian Rogers
2022-11-14 13:40   ` Liang, Kan
2022-11-14 14:09     ` Ian Rogers
2022-11-14 15:26       ` Liang, Kan [this message]
2022-11-14 17:04         ` Ian Rogers
2022-11-14 18:49           ` Liang, Kan
2022-11-14  7:51 ` [PATCH v1 2/9] tools lib api fs tracing_path: Add scandir alphasort Ian Rogers
2022-11-14  7:51 ` [PATCH v1 3/9] perf tracepoint: Sort events in iterator Ian Rogers
2022-11-14  7:51 ` [PATCH v1 4/9] perf list: Generalize limiting to a PMU name Ian Rogers
2022-11-14  8:51   ` Xing Zhengjun
2022-11-14 13:58     ` Ian Rogers
2022-11-14 13:57   ` Liang, Kan
2022-11-14 14:02     ` Ian Rogers
2022-11-14 14:53       ` Liang, Kan
2022-11-14 17:10         ` Ian Rogers
2022-11-14 19:00           ` Liang, Kan
2022-11-14  7:51 ` [PATCH v1 5/9] perf list: Simplify cache event printing Ian Rogers
2022-11-14  7:51 ` [PATCH v1 6/9] perf list: Simplify symbol " Ian Rogers
2022-11-14  7:51 ` [PATCH v1 7/9] perf pmu: Restructure print_pmu_events Ian Rogers
2022-11-14  7:51 ` [PATCH v1 8/9] perf list: Reorganize to use callbacks Ian Rogers
2022-11-14  7:51 ` [PATCH v1 9/9] perf list: Add json output option Ian Rogers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3464d5c2-0438-18ba-fbea-ab95ca5f22b4@linux.intel.com \
    --to=kan.liang@linux.intel.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=caleb.biggers@intel.com \
    --cc=eranian@google.com \
    --cc=gaoxin@cdjrlc.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=kjain@linux.ibm.com \
    --cc=leo.yan@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=perry.taylor@intel.com \
    --cc=peterz@infradead.org \
    --cc=ravi.bangoria@amd.com \
    --cc=robh@kernel.org \
    --cc=sandipan.das@amd.com \
    --cc=weilin.wang@intel.com \
    --cc=zhengjun.xing@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).