mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] [PATCH/RESEND] driver core: remove polling for driver_probe_done(v4)
@ 2009-02-20 14:17 tom.leiming
  2009-02-20 15:33 ` Arjan van de Ven
  0 siblings, 1 reply; 5+ messages in thread
From: tom.leiming @ 2009-02-20 14:17 UTC (permalink / raw)
  To: kay.sievers, greg; +Cc: cornelia.huck, arjan, linux-kernel, Ming Lei

From: Ming Lei <tom.leiming@gmail.com>

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.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Acked-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Reviewed-by: Arjan van de Ven <arjan@linux.intel.com>
---
 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(-)

diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 62a31b9..fef201c 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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);
 }
 
 /**
diff --git a/include/linux/device.h b/include/linux/device.h
index f6d6270..4527064 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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 */
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 8d4ff5a..01be2cd 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -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();
 
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index 9bdddbc..bcea03b 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -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) {
-- 
1.6.0.GIT


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [PATCH/RESEND] driver core: remove polling for driver_probe_done(v4)
  2009-02-20 14:17 [PATCH] [PATCH/RESEND] driver core: remove polling for driver_probe_done(v4) tom.leiming
@ 2009-02-20 15:33 ` Arjan van de Ven
  2009-02-21  1:28   ` Ming Lei
  0 siblings, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2009-02-20 15:33 UTC (permalink / raw)
  To: tom.leiming; +Cc: kay.sievers, greg, cornelia.huck, linux-kernel, Ming Lei

On Fri, 20 Feb 2009 22:17:27 +0800
tom.leiming@gmail.com wrote:

> From: Ming Lei <tom.leiming@gmail.com>
> 
> 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.

you broke it i this revision though

> -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()!


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


-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [PATCH/RESEND] driver core: remove polling for  driver_probe_done(v4)
  2009-02-20 15:33 ` Arjan van de Ven
@ 2009-02-21  1:28   ` Ming Lei
  2009-02-21  4:29     ` Arjan van de Ven
  0 siblings, 1 reply; 5+ messages in thread
From: Ming Lei @ 2009-02-21  1:28 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: kay.sievers, greg, cornelia.huck, linux-kernel

2009/2/20 Arjan van de Ven <arjan@infradead.org>:
> On Fri, 20 Feb 2009 22:17:27 +0800
> tom.leiming@gmail.com wrote:
>
>> From: Ming Lei <tom.leiming@gmail.com>
>>
>> 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.
>
> you broke it i this revision though
>
>> -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 ?

>
>
>> -     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().

>
>
> --
> Arjan van de Ven        Intel Open Source Technology Centre
> For development, discussion and tips for power savings,
> visit http://www.lesswatts.org
>



-- 
Lei Ming

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [PATCH/RESEND] driver core: remove polling for  driver_probe_done(v4)
  2009-02-21  1:28   ` Ming Lei
@ 2009-02-21  4:29     ` Arjan van de Ven
  2009-02-21  8:21       ` Ming Lei
  0 siblings, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2009-02-21  4:29 UTC (permalink / raw)
  To: Ming Lei; +Cc: kay.sievers, greg, cornelia.huck, linux-kernel

On Sat, 21 Feb 2009 09:28:34 +0800
Ming Lei <tom.leiming@gmail.com> wrote:
> >
> > you broke it i this revision though
> >
> >> -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.

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)

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


-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] [PATCH/RESEND] driver core: remove polling for  driver_probe_done(v4)
  2009-02-21  4:29     ` Arjan van de Ven
@ 2009-02-21  8:21       ` Ming Lei
  0 siblings, 0 replies; 5+ messages in thread
From: Ming Lei @ 2009-02-21  8:21 UTC (permalink / raw)
  To: Arjan van de Ven; +Cc: kay.sievers, greg, cornelia.huck, linux-kernel

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

>
>
> --
> Arjan van de Ven        Intel Open Source Technology Centre
> For development, discussion and tips for power savings,
> visit http://www.lesswatts.org
>



-- 
Lei Ming

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-02-21  8:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-20 14:17 [PATCH] [PATCH/RESEND] driver core: remove polling for driver_probe_done(v4) tom.leiming
2009-02-20 15:33 ` Arjan van de Ven
2009-02-21  1:28   ` Ming Lei
2009-02-21  4:29     ` Arjan van de Ven
2009-02-21  8:21       ` Ming Lei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome