On 11/07/2012 10:41 PM, Greg KH wrote: > On Wed, Nov 07, 2012 at 08:27:17PM +0800, Alex Shi wrote: >>>> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c >>>> index 6345294..5f6a573 100644 >>>> --- a/drivers/base/cpu.c >>>> +++ b/drivers/base/cpu.c >>>> @@ -330,4 +330,6 @@ void __init cpu_dev_init(void) >>>> panic("Failed to register CPU subsystem"); >>>> >>>> cpu_dev_register_generic(); >>>> + >>>> + create_sysfs_sched_policy_group(cpu_subsys.dev_root); >>> >>> Are you sure you didn't just race with userspace, creating the sysfs >>> files after the device was created and announced to userspace? >> >> Sorry for don't fully get you. Is the sysfs announced to userspace >> just in 'mount -t sysfs sysfs /sys'? > > No, when the struct device is registered with the driver core. > >> The old powersaving interface: sched_smt_power_savings also >> created here. and cpu_dev_init was called early before do_initcalls >> which cpuidle/cpufreq sysfs were initialized. >> >> Do you mean this line need to init as core_initcall? > > No, you need to make this as an attribute group for the device, so the > driver core will create it automatically before it tells userspace that > the device is now present. > > Use the default attribute groups and you should be fine.
Thanks a lot for explanation! :) It seems a misunderstanding here. I just create a sysfs group, no device registered. The code followed the cpuidle's implementation: $ ls /sys/devices/system/cpu/cpuidle/ current_driver current_governor_ro Seems it's still better to move the group creation into sched/fair.c not here. > > Hope this helps, > > greg k-h > -- Thanks Alex -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/