Skip to content

Commit d8628f3

Browse files
urezkipaulmckrcu
authored andcommitted
kvfree_rcu: Fix comments according to current code
The kvfree_rcu() function now defers allocations in the common case due to the fact that there is no lockless access to the memory-allocator caches/pools. In addition, in CONFIG_PREEMPT_NONE=y and in CONFIG_PREEMPT_VOLUNTARY=y kernels, there is no reliable way to determine if spinlocks are held. As a result, allocation is deferred in the common case, and the two-argument form of kvfree_rcu() thus uses the "channel 3" queue through all the rcu_head structures. This channel is called referred to as the emergency case in comments, and these comments are now obsolete. This commit therefore updates these comments to reflect the new common-case nature of such emergencies. Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
1 parent 7fe1da3 commit d8628f3

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

kernel/rcu/tree.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3355,9 +3355,11 @@ static void kfree_rcu_work(struct work_struct *work)
33553355
}
33563356

33573357
/*
3358-
* Emergency case only. It can happen under low memory
3359-
* condition when an allocation gets failed, so the "bulk"
3360-
* path can not be temporary maintained.
3358+
* This is used when the "bulk" path can not be used for the
3359+
* double-argument of kvfree_rcu(). This happens when the
3360+
* page-cache is empty, which means that objects are instead
3361+
* queued on a linked list through their rcu_head structures.
3362+
* This list is named "Channel 3".
33613363
*/
33623364
for (; head; head = next) {
33633365
unsigned long offset = (unsigned long)head->func;
@@ -3403,16 +3405,17 @@ static inline bool queue_kfree_rcu_work(struct kfree_rcu_cpu *krcp)
34033405
if ((krcp->bkvhead[0] && !krwp->bkvhead_free[0]) ||
34043406
(krcp->bkvhead[1] && !krwp->bkvhead_free[1]) ||
34053407
(krcp->head && !krwp->head_free)) {
3406-
// Channel 1 corresponds to SLAB ptrs.
3407-
// Channel 2 corresponds to vmalloc ptrs.
3408+
// Channel 1 corresponds to the SLAB-pointer bulk path.
3409+
// Channel 2 corresponds to vmalloc-pointer bulk path.
34083410
for (j = 0; j < FREE_N_CHANNELS; j++) {
34093411
if (!krwp->bkvhead_free[j]) {
34103412
krwp->bkvhead_free[j] = krcp->bkvhead[j];
34113413
krcp->bkvhead[j] = NULL;
34123414
}
34133415
}
34143416

3415-
// Channel 3 corresponds to emergency path.
3417+
// Channel 3 corresponds to both SLAB and vmalloc
3418+
// objects queued on the linked list.
34163419
if (!krwp->head_free) {
34173420
krwp->head_free = krcp->head;
34183421
krcp->head = NULL;

0 commit comments

Comments
 (0)