Qs: purpose? tasks? implications? multi-CPU vs
single CPU? any implications for performance? what scenario highly
recommended it? 200 /* 201 * Create/destroy watchdog threads as CPUs come and go: 202 */ 203 static int __cpuinit 204 cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) 205 { 206 int hotcpu = (unsigned long)hcpu; 207 struct task_struct *p; 208 209 switch (action) { 210 case CPU_UP_PREPARE: 211 case CPU_UP_PREPARE_FROZEN: 212 BUG_ON(per_cpu(watchdog_task, hotcpu)); 213 p = kthread_create(watchdog, hcpu, "watchdog/%d", hotcpu); 214 if (IS_ERR(p)) { 215 printk(KERN_ERR "watchdog for %i failed\n", hotcpu); 216 return NOTIFY_BAD; 217 } 218 per_cpu(touch_timestamp, hotcpu) = 0; 219 per_cpu(watchdog_task, hotcpu) = p; 220 kthread_bind(p, hotcpu); 221 break; 222 case CPU_ONLINE: 223 case CPU_ONLINE_FROZEN: 224 wake_up_process(per_cpu(watchdog_task, hotcpu)); 225 break; 226 #ifdef CONFIG_HOTPLUG_CPU 227 case CPU_UP_CANCELED: 228 case CPU_UP_CANCELED_FROZEN: 229 if (!per_cpu(watchdog_task, hotcpu)) 230 break; 231 /* Unbind so it can run. Fall thru. */ 232 kthread_bind(per_cpu(watchdog_task, hotcpu), 233 cpumask_any(cpu_online_mask)); 234 case CPU_DEAD: 235 case CPU_DEAD_FROZEN: 236 p = per_cpu(watchdog_task, hotcpu); 237 per_cpu(watchdog_task, hotcpu) = NULL; 238 kthread_stop(p); 239 break; 240 #endif /* CONFIG_HOTPLUG_CPU */ 241 } 242 return NOTIFY_OK; 243 } 255 } 256 __setup("nosoftlockup", nosoftlockup_setup); 257 258 static int __init spawn_softlockup_task(void) 259 { 260 void *cpu = (void *)(long)smp_processor_id(); 261 int err; 262 263 if (nosoftlockup) 264 return 0; 265 266 err = cpu_callback(&cpu_nfb, CPU_UP_PREPARE, cpu); 267 if (err == NOTIFY_BAD) { 268 BUG(); 269 return 1; 270 } 271 cpu_callback(&cpu_nfb, CPU_ONLINE, cpu); 272 register_cpu_notifier(&cpu_nfb); 273 274 atomic_notifier_chain_register(&panic_notifier_list, &panic_block); 275 276 return 0; 277 } 278 early_initcall(spawn_softlockup_task); |