[PATCH v2 02/12] perf evsel: Support sparse fields in evsel__set_config_if_unset()
James Clark
james.clark at linaro.org
Mon Dec 8 06:22:05 PST 2025
Sparse config fields are technically supported although currently
unused. field_prep() only works for contiguous bitfields so replace it
with pmu_format_value().
Signed-off-by: James Clark <james.clark at linaro.org>
---
tools/perf/util/pmu.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 956ea273c2c7..2c26c8d76bed 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -144,6 +144,8 @@ struct perf_pmu_format {
};
static int pmu_aliases_parse(struct perf_pmu *pmu);
+static void pmu_format_value(unsigned long *format, __u64 value, __u64 *v,
+ bool zero);
static struct perf_pmu_format *perf_pmu__new_format(struct list_head *list, char *name)
{
@@ -1381,7 +1383,6 @@ bool evsel__is_aux_event(const struct evsel *evsel)
* the bit pattern. It is shifted into position by this function, so to set
* something to true, pass 1 for val rather than a pre shifted value.
*/
-#define field_prep(_mask, _val) (((_val) << (ffsll(_mask) - 1)) & (_mask))
void evsel__set_config_if_unset(struct perf_pmu *pmu, struct evsel *evsel,
const char *config_name, u64 val)
{
@@ -1398,8 +1399,7 @@ void evsel__set_config_if_unset(struct perf_pmu *pmu, struct evsel *evsel,
return;
/* Otherwise replace it */
- evsel->core.attr.config &= ~bits;
- evsel->core.attr.config |= field_prep(bits, val);
+ pmu_format_value(&bits, val, &evsel->core.attr.config, /*zero=*/true);
}
static struct perf_pmu_format *
--
2.34.1
More information about the linux-arm-kernel
mailing list