Skip to content

Commit 042d4c7

Browse files
author
Paul E. McKenney
committed
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>
1 parent 6510223 commit 042d4c7

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

‎kernel/rcu/sync.c‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,7 @@ void rcu_sync_enter(struct rcu_sync *rsp)
125125
rsp->gp_state = GP_PENDING;
126126
spin_unlock_irq(&rsp->rss_lock);
127127

128-
BUG_ON(need_wait && need_sync);
129-
128+
WARN_ON_ONCE(need_wait && need_sync);
130129
if (need_sync) {
131130
gp_ops[rsp->gp_type].sync();
132131
rsp->gp_state = GP_PASSED;
@@ -139,7 +138,7 @@ void rcu_sync_enter(struct rcu_sync *rsp)
139138
* Nobody has yet been allowed the 'fast' path and thus we can
140139
* avoid doing any sync(). The callback will get 'dropped'.
141140
*/
142-
BUG_ON(rsp->gp_state != GP_PASSED);
141+
WARN_ON_ONCE(rsp->gp_state != GP_PASSED);
143142
}
144143
}
145144

@@ -166,8 +165,8 @@ static void rcu_sync_func(struct rcu_head *rhp)
166165
struct rcu_sync *rsp = container_of(rhp, struct rcu_sync, cb_head);
167166
unsigned long flags;
168167

169-
BUG_ON(rsp->gp_state != GP_PASSED);
170-
BUG_ON(rsp->cb_state == CB_IDLE);
168+
WARN_ON_ONCE(rsp->gp_state != GP_PASSED);
169+
WARN_ON_ONCE(rsp->cb_state == CB_IDLE);
171170

172171
spin_lock_irqsave(&rsp->rss_lock, flags);
173172
if (rsp->gp_count) {
@@ -225,7 +224,7 @@ void rcu_sync_dtor(struct rcu_sync *rsp)
225224
{
226225
int cb_state;
227226

228-
BUG_ON(rsp->gp_count);
227+
WARN_ON_ONCE(rsp->gp_count);
229228

230229
spin_lock_irq(&rsp->rss_lock);
231230
if (rsp->cb_state == CB_REPLAY)
@@ -235,6 +234,6 @@ void rcu_sync_dtor(struct rcu_sync *rsp)
235234

236235
if (cb_state != CB_IDLE) {
237236
gp_ops[rsp->gp_type].wait();
238-
BUG_ON(rsp->cb_state != CB_IDLE);
237+
WARN_ON_ONCE(rsp->cb_state != CB_IDLE);
239238
}
240239
}

0 commit comments

Comments
 (0)