]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
rcu/tree: Call setschedule() gp ktread to SCHED_FIFO outside of atomic region
authorJuri Lelli <juri.lelli@redhat.com>
Fri, 19 Jul 2019 13:59:59 +0000 (15:59 +0200)
committerIngo Molnar <mingo@kernel.org>
Thu, 25 Jul 2019 13:55:03 +0000 (15:55 +0200)
sched_setscheduler() needs to acquire cpuset_rwsem, but it is currently
called from an invalid (atomic) context by rcu_spawn_gp_kthread().

Fix that by simply moving sched_setscheduler_nocheck() call outside of
the atomic region, as it doesn't actually require to be guarded by
rcu_node lock.

Suggested-by: Peter Zijlstra <peterz@infradead.org>
Tested-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Signed-off-by: Juri Lelli <juri.lelli@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: bristot@redhat.com
Cc: claudio@evidence.eu.com
Cc: lizefan@huawei.com
Cc: longman@redhat.com
Cc: luca.abeni@santannapisa.it
Cc: mathieu.poirier@linaro.org
Cc: rostedt@goodmis.org
Cc: tj@kernel.org
Cc: tommaso.cucinotta@santannapisa.it
Link: https://lkml.kernel.org/r/20190719140000.31694-8-juri.lelli@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
kernel/rcu/tree.c

index a14e5fbbea467ecd6cbadd390f5382bd320b07f3..eb764c24bc4d492f50cf20c856f0b07a2549f702 100644 (file)
@@ -3234,13 +3234,13 @@ static int __init rcu_spawn_gp_kthread(void)
        t = kthread_create(rcu_gp_kthread, NULL, "%s", rcu_state.name);
        if (WARN_ONCE(IS_ERR(t), "%s: Could not start grace-period kthread, OOM is now expected behavior\n", __func__))
                return 0;
+       if (kthread_prio)
+               sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
        rnp = rcu_get_root();
        raw_spin_lock_irqsave_rcu_node(rnp, flags);
        rcu_state.gp_kthread = t;
-       if (kthread_prio) {
+       if (kthread_prio)
                sp.sched_priority = kthread_prio;
-               sched_setscheduler_nocheck(t, SCHED_FIFO, &sp);
-       }
        raw_spin_unlock_irqrestore_rcu_node(rnp, flags);
        wake_up_process(t);
        rcu_spawn_nocb_kthreads();