sirq/hoghogeってなに?
2012/07/05
"sirq-XXX"とは?
コレ参考になる。筑波大学の講義か。http://www.coins.tsukuba.ac.jp/~yas/coins/os2-2011/2012-02-14/
要約すると??
優先度の高いtaskで、driverのbottom halfやprotocol stackの処理を行う。kernel threadで、SMPならcoreごとに名前が異なる。("ksoftirqd/0","ksoftirqd/1"とか)
ソースコードを追う
FILE: kernel/softirq.cstatic const char *softirq_names [] = { [HI_SOFTIRQ] = "high", [SCHED_SOFTIRQ] = "sched", [TIMER_SOFTIRQ] = "timer", [NET_TX_SOFTIRQ] = "net-tx", [NET_RX_SOFTIRQ] = "net-rx", [BLOCK_SOFTIRQ] = "block", [BLOCK_IOPOLL_SOFTIRQ]= "block-iopoll", [TASKLET_SOFTIRQ] = "tasklet", [HRTIMER_SOFTIRQ] = "hrtimer", [RCU_SOFTIRQ] = "rcu", }; static struct notifier_block __cpuinitdata cpu_nfb = { .notifier_call = cpu_callback }; static __init int spawn_ksoftirqd(void) { void *cpu = (void *)(long)smp_processor_id(); int err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); BUG_ON(err == NOTIFY_BAD); cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); register_cpu_notifier(&cpu_nfb); return 0; } early_initcall(spawn_ksoftirqd);展開すると以下イメージで処理される。
cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); for (i = 0; i < NR_SOFTIRQS; i++) { per_cpu(ksoftirqd, hotcpu)[i].nr = i; per_cpu(ksoftirqd, hotcpu)[i].cpu = hotcpu; per_cpu(ksoftirqd, hotcpu)[i].tsk = NULL; } for (i = 0; i < NR_SOFTIRQS; i++) { p = kthread_create(run_ksoftirqd, &per_cpu(ksoftirqd, hotcpu)[i], "sirq-%s/%d", softirq_names[i], hotcpu); if (IS_ERR(p)) { printk("ksoftirqd %d for %i failed\n", i, hotcpu); return NOTIFY_BAD; } kthread_bind(p, hotcpu); per_cpu(ksoftirqd, hotcpu)[i].tsk = p; } cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); for (i = 0; i < NR_SOFTIRQS; i++) { param.sched_priority = MAX_RT_PRIO-1; p = per_cpu(ksoftirqd, hotcpu)[i].tsk; sched_setscheduler(p, SCHED_FIFO, ¶m); per_cpu(ksoftirqd, hotcpu)[i].tsk = NULL; kthread_stop(p); } takeover_tasklets(hotcpu);