Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rcu: Eliminate BUG_ON() for kernel/rcu/tree_plugin.h

The tree_plugin.h file has a number of calls to BUG_ON(), which panics
the kernel, which is not a good strategy for devices (like embedded)
that don't have a way to capture console output. This commit therefore
converts these BUG_ON() calls to WARN_ON_ONCE() and WARN_ONCE().

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
[ paulmck: Fix typo: s/rcuo/rcub/. ]

+6 -3
+6 -3
kernel/rcu/tree_plugin.h
··· 1464 1464 1465 1465 for_each_possible_cpu(cpu) 1466 1466 per_cpu(rcu_cpu_has_work, cpu) = 0; 1467 - BUG_ON(smpboot_register_percpu_thread(&rcu_cpu_thread_spec)); 1467 + if (WARN_ONCE(smpboot_register_percpu_thread(&rcu_cpu_thread_spec), "%s: Could not start rcub kthread, OOM is now expected behavior\n", __func__)) 1468 + return; 1468 1469 rcu_for_each_leaf_node(rnp) 1469 1470 (void)rcu_spawn_one_boost_kthread(rnp); 1470 1471 } ··· 2323 2322 tail = rdp->nocb_follower_tail; 2324 2323 rdp->nocb_follower_tail = &rdp->nocb_follower_head; 2325 2324 raw_spin_unlock_irqrestore(&rdp->nocb_lock, flags); 2326 - BUG_ON(!list); 2325 + if (WARN_ON_ONCE(!list)) 2326 + continue; 2327 2327 trace_rcu_nocb_wake(rcu_state.name, rdp->cpu, TPS("WokeNonEmpty")); 2328 2328 2329 2329 /* Each pass through the following loop invokes a callback. */ ··· 2497 2495 /* Spawn the kthread for this CPU. */ 2498 2496 t = kthread_run(rcu_nocb_kthread, rdp_spawn, 2499 2497 "rcuo%c/%d", rcu_state.abbr, cpu); 2500 - BUG_ON(IS_ERR(t)); 2498 + if (WARN_ONCE(IS_ERR(t), "%s: Could not start rcuo kthread, OOM is now expected behavior\n", __func__)) 2499 + return; 2501 2500 WRITE_ONCE(rdp_spawn->nocb_kthread, t); 2502 2501 } 2503 2502