debuggers.hg

view xen/common/softirq.c @ 22906:700ac6445812

Now add KDB to the non-kdb tree
author Mukesh Rathor
date Thu Feb 03 15:42:41 2011 -0800 (2011-02-03)
parents 0b88ccf6332d
children
line source
1 /******************************************************************************
2 * common/softirq.c
3 *
4 * Softirqs in Xen are only executed in an outermost activation (e.g., never
5 * within an interrupt activation). This simplifies some things and generally
6 * seems a good thing.
7 *
8 * Copyright (c) 2003, K A Fraser
9 * Copyright (c) 1992, Linus Torvalds
10 */
12 #include <xen/config.h>
13 #include <xen/init.h>
14 #include <xen/mm.h>
15 #include <xen/preempt.h>
16 #include <xen/sched.h>
17 #include <xen/rcupdate.h>
18 #include <xen/softirq.h>
20 #ifndef __ARCH_IRQ_STAT
21 irq_cpustat_t irq_stat[NR_CPUS];
22 #endif
24 static softirq_handler softirq_handlers[NR_SOFTIRQS];
26 static void __do_softirq(unsigned long ignore_mask)
27 {
28 unsigned int i, cpu;
29 unsigned long pending;
31 for ( ; ; )
32 {
33 /*
34 * Initialise @cpu on every iteration: SCHEDULE_SOFTIRQ may move
35 * us to another processor.
36 */
37 cpu = smp_processor_id();
39 if ( rcu_pending(cpu) )
40 rcu_check_callbacks(cpu);
42 if ( ((pending = (softirq_pending(cpu) & ~ignore_mask)) == 0)
43 || cpu_is_offline(cpu) )
44 break;
46 i = find_first_set_bit(pending);
47 clear_bit(i, &softirq_pending(cpu));
48 (*softirq_handlers[i])();
49 }
50 }
52 void process_pending_softirqs(void)
53 {
54 ASSERT(!in_irq() && local_irq_is_enabled());
55 /* Do not enter scheduler as it can preempt the calling context. */
56 __do_softirq(1ul<<SCHEDULE_SOFTIRQ);
57 }
59 asmlinkage void do_softirq(void)
60 {
61 ASSERT(!in_atomic());
62 __do_softirq(0);
63 }
65 void open_softirq(int nr, softirq_handler handler)
66 {
67 ASSERT(nr < NR_SOFTIRQS);
68 softirq_handlers[nr] = handler;
69 }
71 void cpumask_raise_softirq(cpumask_t mask, unsigned int nr)
72 {
73 int cpu;
75 for_each_cpu_mask(cpu, mask)
76 if ( test_and_set_bit(nr, &softirq_pending(cpu)) )
77 cpu_clear(cpu, mask);
79 smp_send_event_check_mask(&mask);
80 }
82 void cpu_raise_softirq(unsigned int cpu, unsigned int nr)
83 {
84 if ( !test_and_set_bit(nr, &softirq_pending(cpu))
85 && (cpu != smp_processor_id()) )
86 smp_send_event_check_cpu(cpu);
87 }
89 void raise_softirq(unsigned int nr)
90 {
91 set_bit(nr, &softirq_pending(smp_processor_id()));
92 }
94 void __init softirq_init(void)
95 {
96 }
98 /*
99 * Local variables:
100 * mode: C
101 * c-set-style: "BSD"
102 * c-basic-offset: 4
103 * tab-width: 4
104 * indent-tabs-mode: nil
105 * End:
106 */