[PATCH v5 3/5] perf evsel: Constify option arguments to config functions
From: Ian Rogers
Date: Tue Mar 17 2026 - 01:54:17 EST
The options are used to configure the evsel but are not themselves
configured. Make the arguments const to better capture this.
Signed-off-by: Ian Rogers <irogers@xxxxxxxxxx>
---
tools/perf/util/evsel.c | 20 ++++++++++----------
tools/perf/util/evsel.h | 8 ++++----
2 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c
index bd14d9bbc91f..54c8922a8e47 100644
--- a/tools/perf/util/evsel.c
+++ b/tools/perf/util/evsel.c
@@ -1015,8 +1015,8 @@ uint16_t evsel__e_machine(struct evsel *evsel, uint32_t *e_flags)
return perf_session__e_machine(session, e_flags);
}
-static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *opts,
- struct callchain_param *param)
+static void __evsel__config_callchain(struct evsel *evsel, const struct record_opts *opts,
+ const struct callchain_param *param)
{
bool function = evsel__is_function_event(evsel);
struct perf_event_attr *attr = &evsel->core.attr;
@@ -1080,14 +1080,14 @@ static void __evsel__config_callchain(struct evsel *evsel, struct record_opts *o
attr->defer_callchain = 1;
}
-void evsel__config_callchain(struct evsel *evsel, struct record_opts *opts,
- struct callchain_param *param)
+void evsel__config_callchain(struct evsel *evsel, const struct record_opts *opts,
+ const struct callchain_param *param)
{
if (param->enabled)
return __evsel__config_callchain(evsel, opts, param);
}
-static void evsel__reset_callgraph(struct evsel *evsel, struct callchain_param *param)
+static void evsel__reset_callgraph(struct evsel *evsel, const struct callchain_param *param)
{
struct perf_event_attr *attr = &evsel->core.attr;
@@ -1106,7 +1106,7 @@ static void evsel__reset_callgraph(struct evsel *evsel, struct callchain_param *
static void evsel__apply_ratio_to_prev(struct evsel *evsel,
struct perf_event_attr *attr,
- struct record_opts *opts,
+ const struct record_opts *opts,
const char *buf)
{
struct perf_event_attr *prev_attr = NULL;
@@ -1170,7 +1170,7 @@ static void evsel__apply_ratio_to_prev(struct evsel *evsel,
}
static void evsel__apply_config_terms(struct evsel *evsel,
- struct record_opts *opts, bool track)
+ const struct record_opts *opts, bool track)
{
struct evsel_config_term *term;
struct list_head *config_terms = &evsel->config_terms;
@@ -1445,7 +1445,7 @@ void __weak arch_evsel__apply_ratio_to_prev(struct evsel *evsel __maybe_unused,
{
}
-static void evsel__set_default_freq_period(struct record_opts *opts,
+static void evsel__set_default_freq_period(const struct record_opts *opts,
struct perf_event_attr *attr)
{
if (opts->freq) {
@@ -1490,8 +1490,8 @@ bool evsel__is_offcpu_event(struct evsel *evsel)
* enable/disable events specifically, as there's no
* initial traced exec call.
*/
-void evsel__config(struct evsel *evsel, struct record_opts *opts,
- struct callchain_param *callchain)
+void evsel__config(struct evsel *evsel, const struct record_opts *opts,
+ const struct callchain_param *callchain)
{
struct evsel *leader = evsel__leader(evsel);
struct perf_event_attr *attr = &evsel->core.attr;
diff --git a/tools/perf/util/evsel.h b/tools/perf/util/evsel.h
index 97f57fab28ce..339b5c08a33d 100644
--- a/tools/perf/util/evsel.h
+++ b/tools/perf/util/evsel.h
@@ -287,10 +287,10 @@ void evsel__set_priv_destructor(void (*destructor)(void *priv));
struct callchain_param;
-void evsel__config(struct evsel *evsel, struct record_opts *opts,
- struct callchain_param *callchain);
-void evsel__config_callchain(struct evsel *evsel, struct record_opts *opts,
- struct callchain_param *callchain);
+void evsel__config(struct evsel *evsel, const struct record_opts *opts,
+ const struct callchain_param *callchain);
+void evsel__config_callchain(struct evsel *evsel, const struct record_opts *opts,
+ const struct callchain_param *callchain);
int __evsel__sample_size(u64 sample_type);
void evsel__calc_id_pos(struct evsel *evsel);
--
2.53.0.851.ga537e3e6e9-goog