Skip to contentSkip to conversation

SMP race condition on startup with patch

DISCUSSION D.J. Barrow 2 participants 2 messages Apr 30, 2002

lore
Share & tools
lore
#0 lore raw

Hi All,

I found a smp race condition on startup
of the 2.4.18 kernel when I put a printk
in schedule.

See the comment below in
/init/main.c
/*
* We need to finalize in a non-__init function or
else race conditions
* between the root thread and the init thread may
cause start_kernel to
* be reaped by free_initmem before the root thread
has proceeded to
* cpu_idle.
*/
static void rest_init(void)

Note that init_idle the first thing called from
cpu_idle.
& it is freed from
free_initmem in the init function in main.c
which may be called before the cpu
gets into cpu_idle.

Here is the patch.

--- linux.orig/kernel/sched.c Fri Dec 21 17:42:04
2001
+++ linux/kernel/sched.c Tue Apr 30 12:22:02
2002
@@ -1299,7 +1299,7 @@

extern unsigned long wait_init_idle;

-void __init init_idle(void)
+void init_idle(void)

 {
        struct schedule_data * sched_data;
        sched_data =

&aligned_data[smp_processor_id()].schedule_data;

=====
D.J. Barrow Linux kernel developer
eMail: [email protected]
Home: +353-22-47196.
Work: +353-91-758353

__________________________________________________
Do You Yahoo!?
Yahoo! Health - your guide to health and wellness
http://health.yahoo.com

#1 lore raw
Quoted 3 lines

I found a smp race condition on startup
of the 2.4.18 kernel when I put a printk
in schedule.

Yep. Its already fixed in my tree if I remember rightly.

BTW - a useful tip for checking your port is to memset the __init pages to an illegal instruction value as you reclaim them.