From: kfraser@dhcp93.uk.xensource.com Date: Fri, 30 Jun 2006 12:25:43 +0000 (+0100) Subject: [XEN] Various softirq cleanups. Main one is to always X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15912^2~15 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=ae9bfcdc;p=xen.git [XEN] Various softirq cleanups. Main one is to always call smp_processor_id() after any softirq, as rescheduling may cause us to move to another processor on ia64 (spotted by Isaku Yamahata). Also get rid of many direct callers of do_softirq() by creating new function process_pending_timers(). Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index b4ad1a7a81..3b8abf4893 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -67,16 +67,11 @@ static void default_idle(void) void idle_loop(void) { - int cpu = smp_processor_id(); - for ( ; ; ) { page_scrub_schedule_work(); - default_idle(); - - if ( softirq_pending(cpu) ) - do_softirq(); + do_softirq(); } } diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index f75c01f7b2..a78ed07d26 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -1197,8 +1197,7 @@ int __devinit __cpu_up(unsigned int cpu) cpu_set(cpu, smp_commenced_mask); while (!cpu_isset(cpu, cpu_online_map)) { mb(); - if (softirq_pending(0)) - do_softirq(); + process_pending_timers(); } return 0; } diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 9a20eaf874..fc5cc76ac3 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -388,7 +388,6 @@ void scrub_heap_pages(void) { void *p; unsigned long pfn; - int cpu = smp_processor_id(); printk("Scrubbing Free RAM: "); @@ -398,8 +397,7 @@ void scrub_heap_pages(void) if ( (pfn % ((100*1024*1024)/PAGE_SIZE)) == 0 ) printk("."); - if ( unlikely(softirq_pending(cpu)) ) - do_softirq(); + process_pending_timers(); /* Quick lock-free check. */ if ( allocated_in_map(pfn) ) diff --git a/xen/common/softirq.c b/xen/common/softirq.c index f8a2c3780c..fb220694fe 100644 --- a/xen/common/softirq.c +++ b/xen/common/softirq.c @@ -23,17 +23,23 @@ static softirq_handler softirq_handlers[NR_SOFTIRQS]; asmlinkage void do_softirq(void) { - unsigned int i, cpu = smp_processor_id(); + unsigned int i, cpu; unsigned long pending; - pending = softirq_pending(cpu); - ASSERT(pending != 0); + for ( ; ; ) + { + /* + * Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move + * us to another processor. + */ + cpu = smp_processor_id(); + if ( (pending = softirq_pending(cpu)) == 0 ) + break; - do { i = find_first_set_bit(pending); clear_bit(i, &softirq_pending(cpu)); (*softirq_handlers[i])(); - } while ( (pending = softirq_pending(cpu)) != 0 ); + } } void open_softirq(int nr, softirq_handler handler) diff --git a/xen/common/timer.c b/xen/common/timer.c index 10985fdd8b..eb5636b51f 100644 --- a/xen/common/timer.c +++ b/xen/common/timer.c @@ -327,6 +327,15 @@ static void timer_softirq_action(void) } +void process_pending_timers(void) +{ + unsigned int cpu = smp_processor_id(); + ASSERT(!in_irq() && local_irq_is_enabled()); + if ( test_and_clear_bit(TIMER_SOFTIRQ, &softirq_pending(cpu)) ) + timer_softirq_action(); +} + + static void dump_timerq(unsigned char key) { struct timer *t; diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 2765d4e2e0..3bc2659d83 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -528,8 +528,7 @@ void console_endboot(void) printk("%d... ", 3-i); for ( j = 0; j < 100; j++ ) { - if ( softirq_pending(smp_processor_id()) ) - do_softirq(); + process_pending_timers(); mdelay(10); } } diff --git a/xen/include/xen/timer.h b/xen/include/xen/timer.h index f0c9b7e8a5..495e81c4c3 100644 --- a/xen/include/xen/timer.h +++ b/xen/include/xen/timer.h @@ -88,6 +88,12 @@ extern void migrate_timer(struct timer *timer, unsigned int new_cpu); */ extern void kill_timer(struct timer *timer); +/* + * Process pending timers on this CPU. This should be called periodically + * when performing work that prevents softirqs from running in a timely manner. + */ +extern void process_pending_timers(void); + /* * Bootstrap initialisation. Must be called before any other timer function. */