lkml.org 
[lkml]   [2010]   [May]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC][PATCH v2 08/11] sysfs: introduce new interface sysfs_get_kobject
From
Date
On Wed, 2010-05-19 at 04:08 +0800, Greg KH wrote:
> On Wed, May 19, 2010 at 01:48:43AM +0000, Lin Ming wrote:
> > Need this interface in the later sysfs pmu lookup.
> >
> > struct kobject *sysfs_get_kobject(struct file *file);
> > Return the relative kobject of the sysfs file.
>
> Ick, no. Why would you ever have the file, yet not have the kobject
> already? Something is really wrong if this is needed. Or strange. Or
> maybe both :)

Let me show you the scenario.

/sys/devices/system/cpu/event_source/
`-- id

/sys/devices/system/cpu/events/
|-- L1-dcache-load-misses
| |-- event_source -> ../../event_source

$perf top -e L1-dcache-load-misses

Lookup the pmu used to handle L1-dcache-load-misses as below,

1. pmu_sys_fd =
open("/sys/devices/system/cpu/events/L1-dcache-load-misses/event_source/id", ...)

2. pmu_sys_file = fget_light(pmu_sys_fd, ....)

3. pmu_kobject = sysfs_get_kobject(pmu_sys_file)

4. pmu_kobject is embedded in struct pmu, pmu = container_of(kobj,
struct pmu, kobj);

>
> thanks,
>
> greg k-h



\
 
 \ /
  Last update: 2010-05-19 04:59    [W:0.039 / U:39.660 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site