Re: [PATCH v9 17/20] RISC-V: perf: Add legacy event encodings via sysfs
| Newsgroups | org.kernel.vger.linux-perf-users,org.kernel.vger.linux-devicetree |
|---|---|
| Message-ID | <[email protected]> |
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Medium] The macro RVPMU_EVENT_ATTR_RESOLVE performs single-level stringification, preventing macro expansion of event configuration values. -- --- Patch [17]: [PATCH v9 17/20] RISC-V: perf: Add legacy event encodings via sysfs --- commit b1ff3421691bcc5997cb4d931f9fdffb9eef0d1c Author: Atish Patra <[email protected]> RISC-V: perf: Add legacy event encodings via sysfs This commit defines sysfs entries for legacy events to expose event encoding and counter maps to tools like perf. > diff --git a/drivers/perf/riscv_pmu_sbi.c b/drivers/perf/riscv_pmu_sbi.c > index ee0c077859273..5eb49db8bc7c1 100644 > --- a/drivers/perf/riscv_pmu_sbi.c > +++ b/drivers/perf/riscv_pmu_sbi.c > @@ -130,7 +130,20 @@ static struct attribute_group riscv_cdeleg_pmu_format_group = { > .attrs = riscv_cdeleg_pmu_formats_attr, > }; > > +#define RVPMU_EVENT_ATTR_RESOLVE(m) #m [Severity: Medium] Does this single-level stringification handle macro arguments correctly? If a platform driver defines event mappings and passes standard kernel macros for the config or mask arguments to RVPMU_EVENT_CMASK_ATTR, this definition will stringify them verbatim without evaluation. For example, passing a macro like RISCV_PMU_CYCLE_FIXED_CTR_MASK would emit the literal string "event=RISCV_PMU_CYCLE_FIXED_CTR_MASK" instead of its numeric value. This breaks the perf tool's ability to parse the event encoding, rendering the PMU events unusable. Would it be better to use __stringify() from linux/stringify.h so that both literal numbers and macros evaluate correctly? > +#define RVPMU_EVENT_CMASK_ATTR(_name, _var, config, mask) \ > + PMU_EVENT_ATTR_STRING(_name, rvpmu_event_attr_##_var, \ > + "event=" RVPMU_EVENT_ATTR_RESOLVE(config) \ > + ",counterid_mask=" RVPMU_EVENT_ATTR_RESOLVE(mask)) > + [ ... ] -- Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=17