Re: [PATCH v2] perf tools: Add machine pointer to struct hists

From: Jiri Olsa
Date: Tue Jan 28 2020 - 05:03:05 EST


On Tue, Jan 28, 2020 at 09:42:13AM +0900, Namhyung Kim wrote:

SNIP

> +struct perf_session;
>
> static inline struct perf_cpu_map *evsel__cpus(struct evsel *evsel)
> {
> @@ -145,32 +146,43 @@ void perf_evsel__compute_deltas(struct evsel *evsel, int cpu, int thread,
> struct perf_counts_values *count);
>
> int perf_evsel__object_config(size_t object_size,
> - int (*init)(struct evsel *evsel),
> - void (*fini)(struct evsel *evsel));
> + int (*init)(struct evsel *evsel,
> + struct perf_session *session),
> + void (*fini)(struct evsel *evsel,
> + struct perf_session *session));
>
> -struct evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx);
> +struct evsel *perf_evsel__new_idx(struct perf_event_attr *attr, int idx,
> + struct perf_session *session);
>
> static inline struct evsel *evsel__new(struct perf_event_attr *attr)
> {
> - return perf_evsel__new_idx(attr, 0);
> + return perf_evsel__new_idx(attr, 0, NULL);
> }
>
> -struct evsel *perf_evsel__newtp_idx(const char *sys, const char *name, int idx);
> +static inline struct evsel *evsel__new2(struct perf_event_attr *attr,
> + struct perf_session *session)
> +{
> + return perf_evsel__new_idx(attr, 0, session);
> +}

I'm not sure about perf_session as an argument to get machine,
it seems ok but not for the case in perf_event__process_attr
where you call evsel__new and have no way to get perf_sesion
I think... and I think you need to set it up in there for
the pipe workflow to work with your new sort fields

maybe we could be find with just perf_env pointer there?
but perf_session makes more sense to me.. maybe we could
change event_attr_op to pass it as an argument..

jirka