.6 的linux kernel最多可以使用32中softirq,见代码:
- softirq.c
- /*表示softirq最多可以有32种类型,实际上linux只使用了六种,见文件interrupt.h*/
- static struct softirq_action softirq_vec[32] __cacheline_aligned_in_smp;
- interrupt.h
- enum
- {
- HI_SOFTIRQ=0, /*用于高优先级的tasklet*/
- TIMER_SOFTIRQ, /*用于定时器的下半部*/
- NET_TX_SOFTIRQ,/*用于网络层发包*/
- NET_RX_SOFTIRQ, /*用于网络层收报*/
- SCSI_SOFTIRQ, /*用于scsi设备*/
- TASKLET_SOFTIRQ /*用于低优先级的tasklet*/
- };
- do_IRQ() --> irq_exit() --> invoke_softirq() --> do_softirq() --> __do_softirq()
- do {
- if (pending & 1) {
- h->action(h);
- rcu_bh_qsctr_inc(cpu);
- }
- h++;
- pending >>= 1;
- } while (pending);
- softirq.c
- void __init softirq_init(void)
- {
- open_softirq(TASKLET_SOFTIRQ, tasklet_action, NULL);
- open_softirq(HI_SOFTIRQ, tasklet_hi_action, NULL);
- }
- static void tasklet_action(struct softirq_action *a)
- {
- struct tasklet_struct *list;
- local_irq_disable();
- list = __get_cpu_var(tasklet_vec).list;
- __get_cpu_var(tasklet_vec).list = NULL;
- local_irq_enable();
- while (list) {
- struct tasklet_struct *t = list;
- list = list->next;
- if (tasklet_trylock(t)) {
- if (!atomic_read(&t->count)) {
- if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
- BUG();
- t->func(t->data);
- tasklet_unlock(t);
- continue;
- }
- tasklet_unlock(t);
- }
- local_irq_disable();
- t->next = __get_cpu_var(tasklet_vec).list;
- __get_cpu_var(tasklet_vec).list = t;
- __raise_softirq_irqoff(TASKLET_SOFTIRQ);
- local_irq_enable();
- }
- }
- do {
- if (pending & 1) {
- h->action(h);
- rcu_bh_qsctr_inc(cpu);
- }
- h++;
- pending >>= 1;
- } while (pending);