Skip to content

Commit 4d29194

Browse files
joelagnelpaulmckrcu
authored andcommitted
rcu/tree: Skip entry into the page allocator for PREEMPT_RT
To keep the kfree_rcu() code working in purely atomic sections on RT, such as non-threaded IRQ handlers and raw spinlock sections, avoid calling into the page allocator which uses sleeping locks on RT. In fact, even if the caller is preemptible, the kfree_rcu() code is not, as the krcp->lock is a raw spinlock. Calling into the page allocator is optional and avoiding it should be Ok, especially with the page pre-allocation support in future patches. Such pre-allocation would further avoid the a need for a dynamically allocated page in the first place. Cc: Sebastian Andrzej Siewior <[email protected]> Reviewed-by: Uladzislau Rezki <[email protected]> Co-developed-by: Uladzislau Rezki <[email protected]> Signed-off-by: Uladzislau Rezki <[email protected]> Signed-off-by: Joel Fernandes (Google) <[email protected]> Signed-off-by: Uladzislau Rezki (Sony) <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
1 parent 8ac88f7 commit 4d29194

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

kernel/rcu/tree.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3202,6 +3202,18 @@ kfree_call_rcu_add_ptr_to_bulk(struct kfree_rcu_cpu *krcp,
32023202
if (!bnode) {
32033203
WARN_ON_ONCE(sizeof(struct kfree_rcu_bulk_data) > PAGE_SIZE);
32043204

3205+
/*
3206+
* To keep this path working on raw non-preemptible
3207+
* sections, prevent the optional entry into the
3208+
* allocator as it uses sleeping locks. In fact, even
3209+
* if the caller of kfree_rcu() is preemptible, this
3210+
* path still is not, as krcp->lock is a raw spinlock.
3211+
* With additional page pre-allocation in the works,
3212+
* hitting this return is going to be much less likely.
3213+
*/
3214+
if (IS_ENABLED(CONFIG_PREEMPT_RT))
3215+
return false;
3216+
32053217
bnode = (struct kfree_rcu_bulk_data *)
32063218
__get_free_page(GFP_NOWAIT | __GFP_NOWARN);
32073219
}

0 commit comments

Comments
 (0)