* [PATCH] driver core: remove polling for driver_probe_done
@ 2009-01-29 15:15 tom.leiming
2009-01-29 15:25 ` Arjan van de Ven
2009-01-29 15:29 ` Arjan van de Ven
0 siblings, 2 replies; 5+ messages in thread
From: tom.leiming @ 2009-01-29 15:15 UTC (permalink / raw)
To: kay.sievers, greg; +Cc: linux-kernel, Ming Lei
From: Ming Lei <tom.leiming@gmail.com>
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.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
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(-)
diff --git a/drivers/base/dd.c b/drivers/base/dd.c
index 9b721d3..ee998ca 100644
--- a/drivers/base/dd.c
+++ b/drivers/base/dd.c
@@ -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);
}
/**
diff --git a/include/linux/device.h b/include/linux/device.h
index 45e5b19..20b50c4 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -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 */
diff --git a/init/do_mounts.c b/init/do_mounts.c
index 708105e..ce46c38 100644
--- a/init/do_mounts.c
+++ b/init/do_mounts.c
@@ -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;
diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
index ff95e31..e9a4e54 100644
--- a/init/do_mounts_md.c
+++ b/init/do_mounts_md.c
@@ -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);
--
1.6.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver core: remove polling for driver_probe_done
2009-01-29 15:15 [PATCH] driver core: remove polling for driver_probe_done tom.leiming
@ 2009-01-29 15:25 ` Arjan van de Ven
2009-01-29 15:35 ` Ming Lei
2009-01-29 15:29 ` Arjan van de Ven
1 sibling, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2009-01-29 15:25 UTC (permalink / raw)
To: tom.leiming; +Cc: kay.sievers, greg, linux-kernel, Ming Lei
On Thu, 29 Jan 2009 23:15:10 +0800
tom.leiming@gmail.com wrote:
> From: Ming Lei <tom.leiming@gmail.com>
>
> 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.
>
I do not see where you add the wake_up() for waking up the wait queue...
.... are you sure this is going to work ?
--
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] driver core: remove polling for driver_probe_done
2009-01-29 15:15 [PATCH] driver core: remove polling for driver_probe_done tom.leiming
2009-01-29 15:25 ` Arjan van de Ven
@ 2009-01-29 15:29 ` Arjan van de Ven
2009-01-29 15:46 ` Ming Lei
1 sibling, 1 reply; 5+ messages in thread
From: Arjan van de Ven @ 2009-01-29 15:29 UTC (permalink / raw)
To: tom.leiming; +Cc: kay.sievers, greg, linux-kernel, Ming Lei
> @@ -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!
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] driver core: remove polling for driver_probe_done
2009-01-29 15:25 ` Arjan van de Ven
@ 2009-01-29 15:35 ` Ming Lei
0 siblings, 0 replies; 5+ messages in thread
From: Ming Lei @ 2009-01-29 15:35 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: kay.sievers, greg, linux-kernel
2009/1/29 Arjan van de Ven <arjan@infradead.org>:
> On Thu, 29 Jan 2009 23:15:10 +0800
> tom.leiming@gmail.com wrote:
>
>> From: Ming Lei <tom.leiming@gmail.com>
>>
>> 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.
>>
>
> 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;
}
>
> --
> 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] driver core: remove polling for driver_probe_done
2009-01-29 15:29 ` Arjan van de Ven
@ 2009-01-29 15:46 ` Ming Lei
0 siblings, 0 replies; 5+ messages in thread
From: Ming Lei @ 2009-01-29 15:46 UTC (permalink / raw)
To: Arjan van de Ven; +Cc: kay.sievers, greg, linux-kernel
2009/1/29 Arjan van de Ven <arjan@infradead.org>:
>> @@ -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!
Yes, you are right. I will consider how to fix the problem.
Thanks.
>
--
Lei Ming
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-01-29 15:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-29 15:15 [PATCH] driver core: remove polling for driver_probe_done tom.leiming
2009-01-29 15:25 ` Arjan van de Ven
2009-01-29 15:35 ` Ming Lei
2009-01-29 15:29 ` Arjan van de Ven
2009-01-29 15:46 ` Ming Lei
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®