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

rcu: Eliminate BUG_ON() for sync.c

The sync.c 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
changes these BUG_ON() calls to WARN_ON_ONCE(), but does so quite naively.

Reported-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>

+6 -7
+6 -7
kernel/rcu/sync.c
··· 125 125 rsp->gp_state = GP_PENDING; 126 126 spin_unlock_irq(&rsp->rss_lock); 127 127 128 - BUG_ON(need_wait && need_sync); 129 - 128 + WARN_ON_ONCE(need_wait && need_sync); 130 129 if (need_sync) { 131 130 gp_ops[rsp->gp_type].sync(); 132 131 rsp->gp_state = GP_PASSED; ··· 138 139 * Nobody has yet been allowed the 'fast' path and thus we can 139 140 * avoid doing any sync(). The callback will get 'dropped'. 140 141 */ 141 - BUG_ON(rsp->gp_state != GP_PASSED); 142 + WARN_ON_ONCE(rsp->gp_state != GP_PASSED); 142 143 } 143 144 } 144 145 ··· 165 166 struct rcu_sync *rsp = container_of(rhp, struct rcu_sync, cb_head); 166 167 unsigned long flags; 167 168 168 - BUG_ON(rsp->gp_state != GP_PASSED); 169 - BUG_ON(rsp->cb_state == CB_IDLE); 169 + WARN_ON_ONCE(rsp->gp_state != GP_PASSED); 170 + WARN_ON_ONCE(rsp->cb_state == CB_IDLE); 170 171 171 172 spin_lock_irqsave(&rsp->rss_lock, flags); 172 173 if (rsp->gp_count) { ··· 224 225 { 225 226 int cb_state; 226 227 227 - BUG_ON(rsp->gp_count); 228 + WARN_ON_ONCE(rsp->gp_count); 228 229 229 230 spin_lock_irq(&rsp->rss_lock); 230 231 if (rsp->cb_state == CB_REPLAY) ··· 234 235 235 236 if (cb_state != CB_IDLE) { 236 237 gp_ops[rsp->gp_type].wait(); 237 - BUG_ON(rsp->cb_state != CB_IDLE); 238 + WARN_ON_ONCE(rsp->cb_state != CB_IDLE); 238 239 } 239 240 }