driver core: remove polling for driver_probe_done
Subsystems (2)
PATCH 1/1 driver core: remove polling for driver_probe_done
From: Ming Lei <[email protected]>
This patch renames driver_probe_done to driver_probe_wait_done, and make it wait on condition variable of probe done to remove polling for it in fs initialization.
Removing polling in fs initialization may lead to a faster boot.
--- drivers/base/dd.c | 12 +++++------- include/linux/device.h | 2 +- init/do_mounts.c | 10 +++++----- init/do_mounts_md.c | 5 +++-- 4 files changed, 14 insertions(+), 15 deletions(-)
drivers/base/dd.c +5 -7
@@ -153,18 +153,16 @@ done: }/** -* driver_probe_done -* Determine if the probe sequence is finished or not. +* driver_probe_wait_done +* wait the probe sequence to be finished. * -* Should somehow figure out how to use a semaphore, not an atomic variable... */ -int driver_probe_done (void ) +void driver_probe_wait_done (void ) {pr_debug ("%s: probe_count = %d\n" , __func__,atomic_read (&probe_count)); -if (atomic_read (&probe_count)) -return -EBUSY ; -return 0 ; + +wait_event (probe_waitqueue,atomic_read (&probe_count) ==0 ); }/**
include/linux/device.h +1 -1
@@ -146,7 +146,7 @@ extern struct device_driver *get_driver(struct device_driver *drv);extern void put_driver (struct device_driver *drv);extern struct device_driver *driver_find (const char *name,struct bus_type *bus); -extern int driver_probe_done (void ); +extern void driver_probe_wait_done (void );/* sysfs interface for exporting driver attributes */
init/do_mounts.c +5 -5
@@ -371,8 +371,8 @@ void __init prepare_namespace(void) }/* wait for the known devices to complete their probing */ -while (driver_probe_done () !=0 ) -msleep (100 ); +driver_probe_wait_done (); +async_synchronize_full ();md_run_setup ();
@@ -396,9 +396,9 @@ void __init prepare_namespace(void)if ((ROOT_DEV ==0 ) && root_wait) {printk (KERN_INFO "Waiting for root device %s...\n" , saved_root_name); -while (driver_probe_done () !=0 || - (ROOT_DEV =name_to_dev_t (saved_root_name)) ==0 ) -msleep (100 ); +ROOT_DEV =name_to_dev_t (saved_root_name); +if (ROOT_DEV ) +driver_probe_wait_done (); } is_floppy =MAJOR (ROOT_DEV ) ==FLOPPY_MAJOR ;
init/do_mounts_md.c +3 -2
@@ -281,8 +281,9 @@ static void __init autodetect_raid(void)*/ printk (KERN_INFO "md: Waiting for all devices to be available before autodetect\n" );printk (KERN_INFO "md: If you don't use raid, use raid=noautodetect\n" ); -while (driver_probe_done () <0 ) -msleep (100 ); + +driver_probe_wait_done (); + fd =sys_open ("/dev/md0" ,0 ,0 );if (fd >=0 ) {sys_ioctl (fd,RAID_AUTORUN , raid_autopart);
Signature · 1 line
1.6.0
Quoted 6 lines · On Thu, 29 Jan 2009 23:15:10 +0800 [email protected] wrote:
From: Ming Lei <[email protected]>
This patch renames
driver_probe_donetodriver_probe_wait_done, and make it wait on condition variable of probe done to remove polling for it in fs initialization.
I do not see where you add the wake_up() for waking up the wait queue... .... are you sure this is going to work ?
Signature · 3 lines
Arjan van de Ven Intel Open Source Technology Centre For development, discussion and tips for power savings, visit http://www.lesswatts.org
2009/1/29 Arjan van de Ven <[email protected]>:
Quoted 5 lines
Quoted 2 lines · On Thu, 29 Jan 2009 23:15:10 +0800 [email protected] wrote:
From: Ming Lei <[email protected]>
Quoted 7 lines
Quoted 4 lines
This patch renames
driver_probe_donetodriver_probe_wait_done, and make it wait on condition variable of probe done to remove polling for it in fs initialization.I do not see where you add the
wake_up()for waking up the wait queue... .... are you sure this is going to work ?
really_probe always wake up the queue of probe_waitqueue, but no one pend on it. This patch adds the waitting on the queue.
static int really_probe(struct device *dev, struct device_driver *drv) {
...
done:
atomic_dec(&probe_count);
wake_up(&probe_waitqueue);
return ret;}
Quoted 6 lines
--
Arjan van de Ven Intel Open Source Technology Centre
For development, discussion and tips for power savings, visit http://www.lesswatts.org
Signature · 1 line
Lei Ming
init/do_mounts.c void __init prepare_namespace(void) · line 404
Quoted 13 lines
init/do_mounts.c +3
-3@@ -396,9 +396,9 @@ void __init prepare_namespace(void)if ((ROOT_DEV ==0 ) && root_wait) {printk (KERN_INFO "Waiting for root device %s...\n" , saved_root_name); -while (driver_probe_done () !=0 || - (ROOT_DEV =name_to_dev_t (saved_root_name)) == 0) -msleep (100 ); +ROOT_DEV =name_to_dev_t (saved_root_name); +if (ROOT_DEV ) +driver_probe_wait_done (); }
Hi,
another comment:
this is not equivalent
you turned "wait until all probing is done OR until the device exists" into "wait until all probing is done"... which might be several seconds longer!
2009/1/29 Arjan van de Ven <[email protected]>:
Quoted 16 lines
init/do_mounts.c void __init prepare_namespace(void) · line 404
Quoted 13 lines
init/do_mounts.c +3
-3@@ -396,9 +396,9 @@ void __init prepare_namespace(void)if ((ROOT_DEV ==0 ) && root_wait) {printk (KERN_INFO "Waiting for root device %s...\n" , saved_root_name); -while (driver_probe_done () !=0 || - (ROOT_DEV =name_to_dev_t (saved_root_name)) == 0) -msleep (100 ); +ROOT_DEV =name_to_dev_t (saved_root_name); +if (ROOT_DEV ) +driver_probe_wait_done (); }Hi,
Quoted 7 lines
another comment:
this is not equivalent
you turned "wait until all probing is done OR until the device exists" into "wait until all probing is done"... which might be several seconds longer!
Yes, you are right. I will consider how to fix the problem. Thanks.
Quoted 1 line
Signature · 1 line
Lei Ming