Skip to contentSkip to conversation

+ drivers-wait-for-threaded-probes-between-initcall-levels.patch added to -mm tree

DISCUSSION Cornelia Huck 2 participants 2 messages Oct 26, 2006 – Oct 27, 2006 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 9 lines · On Wed, 25 Oct 2006 19:12:01 -0700, [email protected] wrote:

Subject: drivers: wait for threaded probes between initcall levels
From: Andrew Morton <[email protected]>

The multithreaded-probing code has a problem: after one initcall level (eg, core_initcall) has been processed, we will then start processing the next level (postcore_initcall) while the kernel threads which are handling core_initcall are still executing. This breaks the guarantees which the layered initcalls previously gave us.

Quoted 8 lines

IOW, we want to be multithreaded _within_ an initcall level, but not between different levels.

Fix that up by causing the probing code to wait for all outstanding probes at one level to complete before we start processing the next level.

Makes a lot of sense. I guess we could also get rid of driver_probe_done() in prepare_namespace() with this patch...

Quoted 16 lines
(quoted diff) +16 -0
+#ifdef CONFIG_PCI_MULTITHREAD_PROBE
+static int __init wait_for_probes(void)
+{
+	DEFINE_WAIT(wait);
+
+	if (!atomic_read(&probe_count))
+		return 0;
+	printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__,
+			atomic_read(&probe_count));
+	while (atomic_read(&probe_count)) {
+		prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE);
+		if (atomic_read(&probe_count))
+			schedule();
+	}
+	finish_wait(&probe_waitqueue, &wait);
+	return 0;

Review

Quoted 10 lines
(quoted diff) +10 -0
+}
+
+core_initcall_sync(wait_for_probes);
+postcore_initcall_sync(wait_for_probes);
+arch_initcall_sync(wait_for_probes);
+subsys_initcall_sync(wait_for_probes);
+fs_initcall_sync(wait_for_probes);
+device_initcall_sync(wait_for_probes);
+late_initcall_sync(wait_for_probes);
+#endif

...if we get rid of this #ifdef.

Signature · 3 lines
Cornelia Huck
Linux for zSeries Developer
Tel.: +49-7031-16-4837, Mail: [email protected]
#2 lore raw
Quoted 45 lines · Cornelia Huck
Quoted 9 lines · On Wed, 25 Oct 2006 19:12:01 -0700, [email protected] wrote:

Subject: drivers: wait for threaded probes between initcall levels
From: Andrew Morton <[email protected]>

The multithreaded-probing code has a problem: after one initcall level (eg, core_initcall) has been processed, we will then start processing the next level (postcore_initcall) while the kernel threads which are handling core_initcall are still executing. This breaks the guarantees which the layered initcalls previously gave us.

Quoted 8 lines

IOW, we want to be multithreaded _within_ an initcall level, but not between different levels.

Fix that up by causing the probing code to wait for all outstanding probes at one level to complete before we start processing the next level.

Makes a lot of sense. I guess we could also get rid of driver_probe_done() in prepare_namespace() with this patch...

Quoted 20 lines
(quoted diff) +20 -0
+#ifdef CONFIG_PCI_MULTITHREAD_PROBE
+static int __init wait_for_probes(void)
+{
+	DEFINE_WAIT(wait);
+
+	if (!atomic_read(&probe_count))
+		return 0;
+	printk(KERN_INFO "%s: waiting for %d threads\n", __FUNCTION__,
+			atomic_read(&probe_count));
+	while (atomic_read(&probe_count)) {
+		prepare_to_wait(&probe_waitqueue, &wait, TASK_UNINTERRUPTIBLE);
+		if (atomic_read(&probe_count))
+			schedule();
+	}
+	finish_wait(&probe_waitqueue, &wait);
+	return 0;
+}
+
+core_initcall_sync(wait_for_probes);
+postcore_initcall_sync(wait_for_probes);
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+arch_initcall_sync(wait_for_probes);
+subsys_initcall_sync(wait_for_probes);
+fs_initcall_sync(wait_for_probes);
+device_initcall_sync(wait_for_probes);
+late_initcall_sync(wait_for_probes);
+#endif

...if we get rid of this #ifdef.

Yeah, let me play with this a bit, along with your proposed change, I think it can be cleaned up to be a little more cleaner.

thanks,

greg k-h