Skip to contentSkip to conversation

driver core: remove polling for driver_probe_done(v4)

PATCH In review [email protected] 2 participants 5 messages Feb 20, 2009 – Feb 21, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver core: remove polling for driver_probe_done(v4)

From: Ming Lei <[email protected]>

This patch adds a function : driver_wait_probe_done, which waits on condition of probing done to replace polling for driver_probe_done in fs initialization.

There is no better way to avoid polling for driver_probe_done _and_ existence of the root device, so we does not replace the driver_probe_done with driver_wait_probe_done in such special case.

Removing polling in fs initialization may lead to a faster boot.

This patch is against the latest linux-next tree.

---
 drivers/base/dd.c      |   15 ++++++---------
 include/linux/device.h |    2 +-
 init/do_mounts.c       |    2 +-
 init/do_mounts_md.c    |    2 +-
 4 files changed, 9 insertions(+), 12 deletions(-)
drivers/base/dd.c +6 -9
index 62a31b9..fef201c 100644
@@ -170,18 +170,15 @@ int driver_probe_done(void)
 }
 
 /**
- * wait_for_device_probe
- * Wait for device probing to be completed.
+ * driver_wait_probe_done
+ * Wait until the probe sequence is finished.
  *
- * Note: this function polls at 100 msec intervals.
  */
-int wait_for_device_probe(void)
+void driver_wait_probe_done(void)
 {
-	/* wait for the known devices to complete their probing */
-	while (driver_probe_done() != 0)
-		msleep(100);
-	async_synchronize_full();
-	return 0;
+	pr_debug("%s: probe_count = %d\n", __func__,
+		 atomic_read(&probe_count));
+	wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);
 }
 
 /**
include/linux/device.h +1 -1
index f6d6270..4527064 100644
@@ -148,7 +148,7 @@ 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 int wait_for_device_probe(void);
+extern void driver_wait_probe_done(void);
 
 
 /* sysfs interface for exporting driver attributes */
init/do_mounts.c +1 -1
index 8d4ff5a..01be2cd 100644
@@ -377,7 +377,7 @@ void __init prepare_namespace(void)
 	 * For example, it is not atypical to wait 5 seconds here
 	 * for the touchpad of a laptop to initialize.
 	 */
-	wait_for_device_probe();
+	driver_wait_probe_done();
 
 	md_run_setup();
 
init/do_mounts_md.c +1 -1
index 9bdddbc..bcea03b 100644
@@ -282,7 +282,7 @@ 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");
 
-	wait_for_device_probe();
+	driver_wait_probe_done();
 
 	fd = sys_open("/dev/md0", 0, 0);
 	if (fd >= 0) {
Signature · 1 line
1.6.0.GIT
#1 lore raw
Quoted 11 lines · On Fri, 20 Feb 2009 22:17:27 +0800 [email protected] wrote:

From: Ming Lei <[email protected]>

This patch adds a function : driver_wait_probe_done, which waits on condition of probing done to replace polling for driver_probe_done in fs initialization.

There is no better way to avoid polling for driver_probe_done _and_ existence of the root device, so we does not replace the driver_probe_done with driver_wait_probe_done in such special case.

Quoted 4 lines

Removing polling in fs initialization may lead to a faster boot.

This patch is against the latest linux-next tree.

you broke it i this revision though

drivers/base/dd.c int driver_probe_done(void) · line 181

Quoted 11 lines
drivers/base/dd.c +4 -6
-int wait_for_device_probe(void)
+void driver_wait_probe_done(void)
 {
-	/* wait for the known devices to complete their probing */
-	while (driver_probe_done() != 0)
-		msleep(100);
-	async_synchronize_full();
-	return 0;
+	pr_debug("%s: probe_count = %d\n", __func__,
+		 atomic_read(&probe_count));
+	wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);

You lost the async_synchronize_full()!

Review

Quoted 2 lines
(quoted diff) +1 -1
-	wait_for_device_probe();
+	driver_wait_probe_done();

I also don't understand why you rename the function.. wait_for_device_probe() is not a bad name ;) Sounds like a gratuitous change to me.

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
author
#2 lore raw

2009/2/20 Arjan van de Ven <[email protected]>:

Quoted 21 lines
Quoted 11 lines · On Fri, 20 Feb 2009 22:17:27 +0800 [email protected] wrote:

From: Ming Lei <[email protected]>

This patch adds a function : driver_wait_probe_done, which waits on condition of probing done to replace polling for driver_probe_done in fs initialization.

There is no better way to avoid polling for driver_probe_done _and_ existence of the root device, so we does not replace the driver_probe_done with driver_wait_probe_done in such special case.

Quoted 4 lines

Removing polling in fs initialization may lead to a faster boot.

This patch is against the latest linux-next tree.

you broke it i this revision though

Quoted 14 lines

drivers/base/dd.c int driver_probe_done(void) · line 181

Quoted 11 lines
drivers/base/dd.c +4 -6
-int wait_for_device_probe(void)
+void driver_wait_probe_done(void)
 {
-     /* wait for the known devices to complete their probing */
-     while (driver_probe_done() != 0)
-             msleep(100);
-     async_synchronize_full();
-     return 0;
+     pr_debug("%s: probe_count = %d\n", __func__,
+              atomic_read(&probe_count));
+     wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);

You lost the async_synchronize_full()!

I patch patch-v2.6.29-rc5-next-20090220.gz against v2.6.29-rc5 directly to build
the linux-next tree(it is quicker for me),so I don't know why you add async_synchronize_full()
in driver core and seems it doesn't matter with driver core.

Would you mind that I resend a patch,which does async_synchronize_full() after driver_wait_probe_done() in do_mounts.c or do_mounts_md.c ?

Quoted 8 lines

Review

Quoted 4 lines
(quoted diff) +1 -1
-     wait_for_device_probe();
+     driver_wait_probe_done();

I also don't understand why you rename the function.. wait_for_device_probe() is not a bad name ;) Sounds like a gratuitous change to me.

OK, I will use wait_for_device_probe().

Quoted 7 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
#3 lore raw
Quoted 18 lines · On Sat, 21 Feb 2009 09:28:34 +0800 Ming Lei <[email protected]> wrote:
Quoted 17 lines

you broke it i this revision though

drivers/base/dd.c int driver_probe_done(void) · line 181

Quoted 11 lines
drivers/base/dd.c +4 -6
-int wait_for_device_probe(void)
+void driver_wait_probe_done(void)
 {
-     /* wait for the known devices to complete their probing */
-     while (driver_probe_done() != 0)
-             msleep(100);
-     async_synchronize_full();
-     return 0;
+     pr_debug("%s: probe_count = %d\n", __func__,
+              atomic_read(&probe_count));
+     wait_event(probe_waitqueue, atomic_read(&probe_count) == 0);

You lost the async_synchronize_full()!

Quoted 5 lines

I patch patch-v2.6.29-rc5-next-20090220.gz against v2.6.29-rc5 directly to build
the linux-next tree(it is quicker for me),so I don't know why you add async_synchronize_full()
in driver core and seems it doesn't matter with driver core.

I do not add it; you removed it!
(it is needed to synchronize both the pending probes AND the asynchronous work; that is the point of the consolidation patches to do all of this in one place)

Quoted 4 lines

Would you mind that I resend a patch,which does async_synchronize_full() after driver_wait_probe_done() in do_mounts.c or do_mounts_md.c ?

that is not the right solution. The patch that introduced wait_for_device_probe() was there to make sure it all happens in one central location. To then decentralize this 2nd function call to all locations that call the function does not make sense to me.....

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
author
#4 lore raw
Quoted 4 lines

that is not the right solution. The patch that introduced wait_for_device_probe() was there to make sure it all happens in one central location. To then decentralize this 2nd function call to all locations that call the function does not make sense to me.....

OK, I'll resend a patch, which add async_synchronize_full() in wait_for_device_probe().

Thanks!

Quoted 7 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