Skip to content

Commit

Permalink
perf cpumap: Synthetic events and const/static
Browse files Browse the repository at this point in the history
Make the cpumap arguments const to make it clearer they are in rather
than out arguments. Make two functions static and remove external
declarations.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Athira Jajeev <atrajeev@linux.vnet.ibm.com>
Cc: Colin Ian King <colin.king@intel.com>
Cc: Dave Marchevsky <davemarchevsky@fb.com>
Cc: German Gomez <german.gomez@arm.com>
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Kees Kook <keescook@chromium.org>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Riccardo Mancini <rickyman7@gmail.com>
Cc: Song Liu <songliubraving@fb.com>
Cc: Stephane Eranian <eranian@google.com>
Link: https://lore.kernel.org/r/20220614143353.1559597-3-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
  • Loading branch information
Ian Rogers authored and Arnaldo Carvalho de Melo committed Aug 19, 2022
1 parent e989bc3 commit 35ae6f0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
4 changes: 0 additions & 4 deletions tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,10 +463,6 @@ size_t perf_event__fprintf(union perf_event *event, struct machine *machine, FIL
int kallsyms__get_function_start(const char *kallsyms_filename,
const char *symbol_name, u64 *addr);

void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max);
void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map,
u16 type, int max);

void event_attr_init(struct perf_event_attr *attr);

int perf_event_paranoid(void);
Expand Down
20 changes: 11 additions & 9 deletions tools/perf/util/synthetic-events.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ int perf_event__synthesize_thread_map2(struct perf_tool *tool,
}

static void synthesize_cpus(struct cpu_map_entries *cpus,
struct perf_cpu_map *map)
const struct perf_cpu_map *map)
{
int i, map_nr = perf_cpu_map__nr(map);

Expand All @@ -1196,7 +1196,7 @@ static void synthesize_cpus(struct cpu_map_entries *cpus,
}

static void synthesize_mask(struct perf_record_record_cpu_map *mask,
struct perf_cpu_map *map, int max)
const struct perf_cpu_map *map, int max)
{
int i;

Expand All @@ -1207,12 +1207,12 @@ static void synthesize_mask(struct perf_record_record_cpu_map *mask,
set_bit(perf_cpu_map__cpu(map, i).cpu, mask->mask);
}

static size_t cpus_size(struct perf_cpu_map *map)
static size_t cpus_size(const struct perf_cpu_map *map)
{
return sizeof(struct cpu_map_entries) + perf_cpu_map__nr(map) * sizeof(u16);
}

static size_t mask_size(struct perf_cpu_map *map, int *max)
static size_t mask_size(const struct perf_cpu_map *map, int *max)
{
int i;

Expand All @@ -1229,7 +1229,8 @@ static size_t mask_size(struct perf_cpu_map *map, int *max)
return sizeof(struct perf_record_record_cpu_map) + BITS_TO_LONGS(*max) * sizeof(long);
}

void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int *max)
static void *cpu_map_data__alloc(const struct perf_cpu_map *map, size_t *size,
u16 *type, int *max)
{
size_t size_cpus, size_mask;
bool is_dummy = perf_cpu_map__empty(map);
Expand Down Expand Up @@ -1263,8 +1264,9 @@ void *cpu_map_data__alloc(struct perf_cpu_map *map, size_t *size, u16 *type, int
return zalloc(*size);
}

void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf_cpu_map *map,
u16 type, int max)
static void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data,
const struct perf_cpu_map *map,
u16 type, int max)
{
data->type = type;

Expand All @@ -1279,7 +1281,7 @@ void cpu_map_data__synthesize(struct perf_record_cpu_map_data *data, struct perf
}
}

static struct perf_record_cpu_map *cpu_map_event__new(struct perf_cpu_map *map)
static struct perf_record_cpu_map *cpu_map_event__new(const struct perf_cpu_map *map)
{
size_t size = sizeof(struct perf_record_cpu_map);
struct perf_record_cpu_map *event;
Expand All @@ -1299,7 +1301,7 @@ static struct perf_record_cpu_map *cpu_map_event__new(struct perf_cpu_map *map)
}

int perf_event__synthesize_cpu_map(struct perf_tool *tool,
struct perf_cpu_map *map,
const struct perf_cpu_map *map,
perf_event__handler_t process,
struct machine *machine)
{
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/synthetic-events.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ typedef int (*perf_event__handler_t)(struct perf_tool *tool, union perf_event *e
int perf_event__synthesize_attrs(struct perf_tool *tool, struct evlist *evlist, perf_event__handler_t process);
int perf_event__synthesize_attr(struct perf_tool *tool, struct perf_event_attr *attr, u32 ids, u64 *id, perf_event__handler_t process);
int perf_event__synthesize_build_id(struct perf_tool *tool, struct dso *pos, u16 misc, perf_event__handler_t process, struct machine *machine);
int perf_event__synthesize_cpu_map(struct perf_tool *tool, struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
int perf_event__synthesize_cpu_map(struct perf_tool *tool, const struct perf_cpu_map *cpus, perf_event__handler_t process, struct machine *machine);
int perf_event__synthesize_event_update_cpus(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
int perf_event__synthesize_event_update_name(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
int perf_event__synthesize_event_update_scale(struct perf_tool *tool, struct evsel *evsel, perf_event__handler_t process);
Expand Down

0 comments on commit 35ae6f0

Please sign in to comment.