Skip to content

Commit 9627456

Browse files
urezkipaulmckrcu
authored andcommitted
rcu/kvfree: Use READ_ONCE() when access to krcp->head
The need_offload_krc() function is now lock-free, which gives the compiler freedom to load old values from plain C-language loads from the kfree_rcu_cpu struture's ->head pointer. This commit therefore applied READ_ONCE() to these loads. Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent cc37d52 commit 9627456

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

kernel/rcu/tree.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3165,7 +3165,7 @@ need_offload_krc(struct kfree_rcu_cpu *krcp)
31653165
if (!list_empty(&krcp->bulk_head[i]))
31663166
return true;
31673167

3168-
return !!krcp->head;
3168+
return !!READ_ONCE(krcp->head);
31693169
}
31703170

31713171
static void
@@ -3206,7 +3206,7 @@ static void kfree_rcu_monitor(struct work_struct *work)
32063206
// in that case the monitor work is rearmed.
32073207
if ((!list_empty(&krcp->bulk_head[0]) && list_empty(&krwp->bulk_head_free[0])) ||
32083208
(!list_empty(&krcp->bulk_head[1]) && list_empty(&krwp->bulk_head_free[1])) ||
3209-
(krcp->head && !krwp->head_free)) {
3209+
(READ_ONCE(krcp->head) && !krwp->head_free)) {
32103210

32113211
// Channel 1 corresponds to the SLAB-pointer bulk path.
32123212
// Channel 2 corresponds to vmalloc-pointer bulk path.

0 commit comments

Comments
 (0)