Skip to contentSkip to conversation

softirq.c improvments

PATCH D.J. Barrow 1 participant 1 message May 29, 2002 Scheduler

lore
Share & tools
lore
#0 lore raw

Hi,

Here is a new version of the softirq patch I posted on 14 May, I found a bug in intel where softirqs were being started when cpu_idle was the only process on the machine really early in bootup.

My old patch didn't like this & could get caught in an infinite softirq loop.

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

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com

include/linux/sched.h +13 -0
diff -u -r linux.orig/include/linux/sched.h linux.new/include/linux/sched.h
@@ -927,6 +927,19 @@
 	return res;
 }
 
+#ifdef CONFIG_SMP
+
+#define idle_task(cpu) (init_tasks[cpu_number_map(cpu)])
+#define can_schedule(p,cpu) \
+	((p)->cpus_runnable & (p)->cpus_allowed & (1 << cpu))
+
+#else
+
+#define idle_task(cpu) (&init_task)
+#define can_schedule(p,cpu) (1)
+
+#endif
+
 #endif /* __KERNEL__ */
 
 #endif

Only in linux.new/include/linux: sched.h.orig

kernel/sched.c +0 -11
diff -u -r linux.orig/kernel/sched.c linux.new/kernel/sched.c
@@ -112,18 +112,7 @@
 struct kernel_stat kstat;
 extern struct task_struct *child_reaper;
 
-#ifdef CONFIG_SMP
 
-#define idle_task(cpu) (init_tasks[cpu_number_map(cpu)])
-#define can_schedule(p,cpu) \
-	((p)->cpus_runnable & (p)->cpus_allowed & (1 << cpu))
-
-#else
-
-#define idle_task(cpu) (&init_task)
-#define can_schedule(p,cpu) (1)
-
-#endif
 
 void scheduling_functions_start_here(void) { }
 
kernel/softirq.c +5 -2
diff -u -r linux.orig/kernel/softirq.c linux.new/kernel/softirq.c
@@ -60,11 +60,11 @@
 
 asmlinkage void do_softirq()
 {
+        extern struct task_struct *child_reaper;
 	int cpu = smp_processor_id();
 	__u32 pending;
 	long flags;
 	__u32 mask;
-
 	if (in_interrupt())
 		return;
 
@@ -95,7 +95,10 @@
 		local_irq_disable();
 
 		pending = softirq_pending(cpu);
-		if (pending & mask) {
+                /* If child reaper!=init_task we have finished the initial bootstrap & haven't received an early softirq */
+                /* when the idle_task is the only task running */
+		if ((pending && current==idle_task(cpu) && !current->need_resched && child_reaper != &init_task )
+		    || (pending & mask) ) {
 			mask &= ~pending;
 			goto restart;
 		}