Repository navigation
Commit 9b81af9
rcu/tree: Defer kvfree_rcu() allocation to a clean context
[ Upstream commit 56292e8 ]
The current memmory-allocation interface causes the following difficulties
for kvfree_rcu():
a) If built with CONFIG_PROVE_RAW_LOCK_NESTING, the lockdep will
complain about violation of the nesting rules, as in "BUG: Invalid
wait context". This Kconfig option checks for proper raw_spinlock
vs. spinlock nesting, in particular, it is not legal to acquire a
spinlock_t while holding a raw_spinlock_t.
This is a problem because kfree_rcu() uses raw_spinlock_t whereas the
"page allocator" internally deals with spinlock_t to access to its
zones. The code also can be broken from higher level of view:
<snip>
raw_spin_lock(&some_lock);
kfree_rcu(some_pointer, some_field_offset);
<snip>
b) If built with CONFIG_PREEMPT_RT, spinlock_t is converted into
sleeplock. This means that invoking the page allocator from atomic
contexts results in "BUG: scheduling while atomic".
c) Please note that call_rcu() is already invoked from raw atomic context,
so it is only reasonable to expaect that kfree_rcu() and kvfree_rcu()
will also be called from atomic raw context.
This commit therefore defers page allocation to a clean context using the
combination of an hrtimer and a workqueue. The hrtimer stage is required
in order to avoid deadlocks with the scheduler. This deferred allocation
is required only when kvfree_rcu()'s per-CPU page cache is empty.
Link: https://lore.kernel.org/lkml/20200630164543.4mdcf6zb4zfclhln@linutronix.de/
Fixes: 3042f83 ("rcu: Support reclaim for head-less object")
Reported-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 5cacd18 commit 9b81af9
1 file changed
Lines changed: 66 additions & 43 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
180 | | - | |
| 180 | + | |
181 | 181 | | |
182 | 182 | | |
183 | 183 | | |
| |||
3087 | 3087 | | |
3088 | 3088 | | |
3089 | 3089 | | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
3090 | 3093 | | |
3091 | 3094 | | |
3092 | 3095 | | |
| |||
3103 | 3106 | | |
3104 | 3107 | | |
3105 | 3108 | | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
3106 | 3114 | | |
3107 | 3115 | | |
3108 | 3116 | | |
| |||
3220 | 3228 | | |
3221 | 3229 | | |
3222 | 3230 | | |
3223 | | - | |
| 3231 | + | |
3224 | 3232 | | |
3225 | 3233 | | |
3226 | | - | |
| 3234 | + | |
3227 | 3235 | | |
3228 | 3236 | | |
3229 | 3237 | | |
| |||
3350 | 3358 | | |
3351 | 3359 | | |
3352 | 3360 | | |
| 3361 | + | |
| 3362 | + | |
| 3363 | + | |
| 3364 | + | |
| 3365 | + | |
| 3366 | + | |
| 3367 | + | |
| 3368 | + | |
| 3369 | + | |
| 3370 | + | |
| 3371 | + | |
| 3372 | + | |
| 3373 | + | |
| 3374 | + | |
| 3375 | + | |
| 3376 | + | |
| 3377 | + | |
| 3378 | + | |
| 3379 | + | |
| 3380 | + | |
| 3381 | + | |
| 3382 | + | |
| 3383 | + | |
| 3384 | + | |
| 3385 | + | |
| 3386 | + | |
| 3387 | + | |
| 3388 | + | |
| 3389 | + | |
| 3390 | + | |
| 3391 | + | |
| 3392 | + | |
| 3393 | + | |
| 3394 | + | |
| 3395 | + | |
| 3396 | + | |
| 3397 | + | |
| 3398 | + | |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
| 3404 | + | |
| 3405 | + | |
| 3406 | + | |
| 3407 | + | |
| 3408 | + | |
| 3409 | + | |
| 3410 | + | |
| 3411 | + | |
3353 | 3412 | | |
3354 | 3413 | | |
3355 | 3414 | | |
| |||
3366 | 3425 | | |
3367 | 3426 | | |
3368 | 3427 | | |
3369 | | - | |
3370 | | - | |
3371 | | - | |
3372 | | - | |
3373 | | - | |
3374 | | - | |
3375 | | - | |
3376 | | - | |
3377 | | - | |
3378 | | - | |
3379 | | - | |
3380 | | - | |
3381 | | - | |
3382 | | - | |
3383 | | - | |
3384 | | - | |
3385 | | - | |
3386 | | - | |
3387 | | - | |
3388 | | - | |
3389 | | - | |
3390 | | - | |
3391 | | - | |
3392 | | - | |
3393 | 3428 | | |
3394 | | - | |
| 3429 | + | |
3395 | 3430 | | |
3396 | 3431 | | |
3397 | 3432 | | |
| |||
3455 | 3490 | | |
3456 | 3491 | | |
3457 | 3492 | | |
3458 | | - | |
3459 | | - | |
3460 | | - | |
3461 | | - | |
3462 | 3493 | | |
3463 | 3494 | | |
| 3495 | + | |
| 3496 | + | |
3464 | 3497 | | |
3465 | 3498 | | |
3466 | 3499 | | |
| |||
4452 | 4485 | | |
4453 | 4486 | | |
4454 | 4487 | | |
4455 | | - | |
4456 | 4488 | | |
4457 | 4489 | | |
4458 | 4490 | | |
4459 | 4491 | | |
4460 | 4492 | | |
4461 | 4493 | | |
4462 | | - | |
4463 | | - | |
4464 | | - | |
4465 | | - | |
4466 | | - | |
4467 | | - | |
4468 | | - | |
4469 | | - | |
4470 | | - | |
4471 | | - | |
4472 | 4494 | | |
| 4495 | + | |
4473 | 4496 | | |
4474 | 4497 | | |
4475 | 4498 | | |
| |||
0 commit comments