Commit 9a5418b
sched/core: Use kfree_rcu() in do_set_cpus_allowed()
Commit 851a723 ("sched: Always clear user_cpus_ptr in
do_set_cpus_allowed()") may call kfree() if user_cpus_ptr was previously
set. Unfortunately, some of the callers of do_set_cpus_allowed()
may have pi_lock held when calling it. So the following splats may be
printed especially when running with a PREEMPT_RT kernel:
WARNING: possible circular locking dependency detected
BUG: sleeping function called from invalid context
To avoid these problems, kfree_rcu() is used instead. An internal
cpumask_rcuhead union is created for the sole purpose of facilitating
the use of kfree_rcu() to free the cpumask.
Since user_cpus_ptr is not being used in non-SMP configs, the newly
introduced alloc_user_cpus_ptr() helper will return NULL in this case
and sched_setaffinity() is modified to handle this special case.
Fixes: 851a723 ("sched: Always clear user_cpus_ptr in do_set_cpus_allowed()")
Suggested-by: Peter Zijlstra <[email protected]>
Signed-off-by: Waiman Long <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
Reviewed-by: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/[email protected]1 parent 87ca4f9 commit 9a5418b
1 file changed
+29
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2604 | 2604 | | |
2605 | 2605 | | |
2606 | 2606 | | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
2607 | 2611 | | |
2608 | 2612 | | |
2609 | | - | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
2610 | 2630 | | |
2611 | 2631 | | |
2612 | 2632 | | |
| |||
2629 | 2649 | | |
2630 | 2650 | | |
2631 | 2651 | | |
2632 | | - | |
| 2652 | + | |
2633 | 2653 | | |
2634 | 2654 | | |
2635 | 2655 | | |
| |||
3605 | 3625 | | |
3606 | 3626 | | |
3607 | 3627 | | |
| 3628 | + | |
| 3629 | + | |
| 3630 | + | |
| 3631 | + | |
| 3632 | + | |
3608 | 3633 | | |
3609 | 3634 | | |
3610 | 3635 | | |
| |||
8265 | 8290 | | |
8266 | 8291 | | |
8267 | 8292 | | |
8268 | | - | |
8269 | | - | |
| 8293 | + | |
| 8294 | + | |
8270 | 8295 | | |
8271 | 8296 | | |
8272 | 8297 | | |
| |||
0 commit comments