From: "Liang, Kan" <kan.liang@linux.intel.com>
To: Leo Yan <leo.yan@linaro.org>
Cc: acme@kernel.org, irogers@google.com, peterz@infradead.org,
mingo@redhat.com, namhyung@kernel.org, jolsa@kernel.org,
adrian.hunter@intel.com, john.g.garry@oracle.com,
will@kernel.org, james.clark@arm.com, mike.leach@linaro.org,
yuhaixin.yhx@linux.alibaba.com, renyu.zj@linux.alibaba.com,
tmricht@linux.ibm.com, ravi.bangoria@amd.com,
linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH V2 3/5] perf mem: Clean up perf_mem_events__name()
Date: Mon, 11 Dec 2023 13:39:36 -0500 [thread overview]
Message-ID: <3b67c2de-741d-4d5e-8c8f-87b8b9e08825@linux.intel.com> (raw)
In-Reply-To: <20231209054809.GB2116834@leoy-yangtze.lan>
On 2023-12-09 12:48 a.m., Leo Yan wrote:
> On Thu, Dec 07, 2023 at 11:23:36AM -0800, kan.liang@linux.intel.com wrote:
>> From: Kan Liang <kan.liang@linux.intel.com>
>>
>> Introduce a generic perf_mem_events__name(). Remove the ARCH-specific
>> one.
>
> Now memory event naming is arch dependent, this is because every arch
> has different memory PMU names, and it appends specific configurations
> (e.g. aarch64 appends 'ts_enable=1,...,min_latency=%u', and x86_64
> appends 'ldlat=%u', etc). This is not friendly for extension, e.g. it's
> impossible for users to specify any extra attributes for memory events.
>
> This patch tries to consolidate in a central place for generating memory
> event names, its approach is to add more flags to meet special usage
> cases, which means the code gets more complex (and more difficult for
> later's maintenance).
>
> I think we need to distinguish the event naming into two levels: in
> util/mem-events.c, we can consider it as a common layer, and we maintain
> common options in it, e.g. 'latency', 'all-user', 'all-kernel',
> 'timestamp', 'physical_address', etc. In every arch's mem-events.c
> file, it converts the common options to arch specific configurations.
>
> In the end, this can avoid to add more and more flags into the
> structure perf_mem_event.
The purpose of this cleanup patch set is to remove the unnecessary
__weak functions, and try to make the code more generic.
The two flags has already covered all the current usage.
For now, it's good enough.
I agree that if there are more flags, it should not be a perfect
solution. But we don't have the third flag right now. Could we clean up
it later e.g., when introducing the third flag?
I just don't want to make the patch bigger and bigger. Also, I don't
think we usually implement something just for future possibilities.
>
> Anyway, I also have a question for this patch itself, please see below
> inline comment.
>
> [...]
>
>> diff --git a/tools/perf/arch/arm64/util/mem-events.c b/tools/perf/arch/arm64/util/mem-events.c
>> index 2602e8688727..eb2ef84f0fc8 100644
>> --- a/tools/perf/arch/arm64/util/mem-events.c
>> +++ b/tools/perf/arch/arm64/util/mem-events.c
>> @@ -2,28 +2,10 @@
>> #include "map_symbol.h"
>> #include "mem-events.h"
>>
>> -#define E(t, n, s) { .tag = t, .name = n, .sysfs_name = s }
>> +#define E(t, n, s, l, a) { .tag = t, .name = n, .sysfs_name = s, .ldlat = l, .aux_event = a }
>>
>> struct perf_mem_event perf_mem_events_arm[PERF_MEM_EVENTS__MAX] = {
>> - E("spe-load", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/", "arm_spe_0"),
>> - E("spe-store", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/", "arm_spe_0"),
>> - E("spe-ldst", "arm_spe_0/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/", "arm_spe_0"),
>> + E("spe-load", "%s/ts_enable=1,pa_enable=1,load_filter=1,store_filter=0,min_latency=%u/", "arm_spe_0", true, 0),
>> + E("spe-store", "%s/ts_enable=1,pa_enable=1,load_filter=0,store_filter=1/", "arm_spe_0", false, 0),
>> + E("spe-ldst", "%s/ts_enable=1,pa_enable=1,load_filter=1,store_filter=1,min_latency=%u/", "arm_spe_0", true, 0),
>
> Arm SPE is AUX event, should set '1' to the field '.aux_event'.
It actually means whether an extra event is required with a mem_loads
event. I guess for ARM the answer is no.
>
> I am a bit suspect if we really need the field '.aux_event', the
> '.aux_event' field is only used for generating event string.
No, it stores the event encoding for the extra event.
ARM doesn't need it, so it's 0.
>
> So in the below function perf_pmu__mem_events_name(), I prefer to call
> an arch specific function, e.g. arch_memory_event_name(event_id, cfg),
> the parameter 'event_id' passes memory event ID for load, store, and
> load-store, and the parameter 'cfg' which is a pointer to the common
> memory options (as mentioned above for latency, all-user or all-kernel
> mode, timestamp tracing, etc).
If I understand correctly, I think we try to avoid the __weak function
for the perf tool. If there will be more parameters later, a mask may be
used for the parameters. But, again, I think it should be an improvement
for later.
Thanks,
Kan
>
> In the end, the common layer just passes the common options to low
> level arch's layer and get a event string for recording.
>
> Thanks,
> Leo
next prev parent reply other threads:[~2023-12-11 18:39 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 19:23 [PATCH V2 0/5] Clean up perf mem kan.liang
2023-12-07 19:23 ` [PATCH V2 1/5] perf mem: Add mem_events into the supported perf_pmu kan.liang
2023-12-08 10:29 ` Leo Yan
2023-12-08 18:14 ` Liang, Kan
2023-12-09 6:34 ` Leo Yan
2023-12-11 19:01 ` Liang, Kan
2023-12-13 14:24 ` Leo Yan
2023-12-13 16:19 ` Liang, Kan
2023-12-07 19:23 ` [PATCH V2 2/5] perf mem: Clean up perf_mem_events__ptr() kan.liang
2023-12-09 4:31 ` Leo Yan
2023-12-11 18:09 ` Liang, Kan
2023-12-07 19:23 ` [PATCH V2 3/5] perf mem: Clean up perf_mem_events__name() kan.liang
2023-12-08 0:01 ` Ian Rogers
2023-12-09 5:48 ` Leo Yan
2023-12-11 18:39 ` Liang, Kan [this message]
2023-12-13 13:33 ` Leo Yan
2023-12-13 16:17 ` Liang, Kan
2023-12-13 17:33 ` Ian Rogers
2023-12-18 3:21 ` Leo Yan
2023-12-07 19:23 ` [PATCH V2 4/5] perf mem: Clean up perf_mem_event__supported() kan.liang
2023-12-09 6:17 ` Leo Yan
2023-12-11 18:44 ` Liang, Kan
2023-12-13 13:51 ` Leo Yan
2023-12-13 13:55 ` Ravi Bangoria
2023-12-07 19:23 ` [PATCH V2 5/5] perf mem: Clean up is_mem_loads_aux_event() kan.liang
2023-12-09 6:27 ` Leo Yan
2023-12-11 18:45 ` Liang, Kan
2023-12-07 20:31 ` [PATCH V2 0/5] Clean up perf mem Arnaldo Carvalho de Melo
2023-12-13 9:51 ` Athira Rajeev
2023-12-13 19:54 ` Liang, Kan
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=3b67c2de-741d-4d5e-8c8f-87b8b9e08825@linux.intel.com \
--to=kan.liang@linux.intel.com \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=irogers@google.com \
--cc=james.clark@arm.com \
--cc=john.g.garry@oracle.com \
--cc=jolsa@kernel.org \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mike.leach@linaro.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=renyu.zj@linux.alibaba.com \
--cc=tmricht@linux.ibm.com \
--cc=will@kernel.org \
--cc=yuhaixin.yhx@linux.alibaba.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