Re: [RFC][PATCH 3/9] perf: export registerred pmus via sysfs

From: Lin Ming
Date: Thu May 13 2010 - 04:30:03 EST


On Tue, 2010-05-11 at 17:18 +0800, Ingo Molnar wrote:
> * Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> > The new PMUs will use a dynamic range that starts at PERF_TYPE_MAX.
>
> I dont think we should use a dynamic range of event sources - it's a
> completely useless indirection that has no meaning to humans.
>
> As far as machine interfaces go a much cleaner approach would be to allow an
> open fd to a sysfs file to be passed to sys_perf_event_open() - this would
> identify the event source. This needs a small extension of the ABI but we
> could thus get rid of the 'type' enumeration altogether and express _all_
> event sources via fds to sysfs files.

I still don't understand this sys_fd -> pmu lookup, would you please
explain it more detail?

struct pmu {
kobject kobj;
...
};

What I can imagine is,

1. In userspace, sys_fd =
open("/sys/devices/system/cpu/event_source", ..), then sys_fd is passed
to sys_perf_event_open()

2. In kernel, sys_file = <find the sys file structure with sys_fd>

3. kobject = <retrieve the kobject from sys_file>

4. pmu = container_of(kobject, struct pmu, kobj)

If my understanding is correct, then step 3 above seems strange. It's
not the typical usage of sys file.

Thanks,
Lin Ming

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/