Skip to content

Commit 54aacfe

Browse files
author
Kent Overstreet
committed
bcachefs: Fix rcu_pending for PREEMPT_RT
PREEMPT_RT redefines how standard spinlocks work, so local_irq_save() + spin_lock() is no longer equivalent to spin_lock_irqsave(). Fortunately, we don't strictly need to do it that way. Signed-off-by: Kent Overstreet <[email protected]>
1 parent 082c744 commit 54aacfe

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

fs/bcachefs/rcu_pending.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ static inline void kfree_bulk(size_t nr, void ** p)
182182
while (nr--)
183183
kfree(*p);
184184
}
185-
186-
#define local_irq_save(flags) \
187-
do { \
188-
flags = 0; \
189-
} while (0)
190185
#endif
191186

192187
static noinline void __process_finished_items(struct rcu_pending *pending,
@@ -429,9 +424,15 @@ __rcu_pending_enqueue(struct rcu_pending *pending, struct rcu_head *head,
429424

430425
BUG_ON((ptr != NULL) != (pending->process == RCU_PENDING_KVFREE_FN));
431426

432-
local_irq_save(flags);
433-
p = this_cpu_ptr(pending->p);
434-
spin_lock(&p->lock);
427+
/* We could technically be scheduled before taking the lock and end up
428+
* using a different cpu's rcu_pending_pcpu: that's ok, it needs a lock
429+
* anyways
430+
*
431+
* And we have to do it this way to avoid breaking PREEMPT_RT, which
432+
* redefines how spinlocks work:
433+
*/
434+
p = raw_cpu_ptr(pending->p);
435+
spin_lock_irqsave(&p->lock, flags);
435436
rcu_gp_poll_state_t seq = __get_state_synchronize_rcu(pending->srcu);
436437
restart:
437438
if (may_sleep &&
@@ -520,9 +521,8 @@ __rcu_pending_enqueue(struct rcu_pending *pending, struct rcu_head *head,
520521
goto free_node;
521522
}
522523

523-
local_irq_save(flags);
524-
p = this_cpu_ptr(pending->p);
525-
spin_lock(&p->lock);
524+
p = raw_cpu_ptr(pending->p);
525+
spin_lock_irqsave(&p->lock, flags);
526526
goto restart;
527527
}
528528

0 commit comments

Comments
 (0)