Patch "rcu/tasks: Handle new PF_IDLE semantics" has been added to the 6.6-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    rcu/tasks: Handle new PF_IDLE semantics

to the 6.6-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rcu-tasks-handle-new-pf_idle-semantics.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e96491a39a50bcd1320f955f0bb8160c5702379d
Author: Frederic Weisbecker <frederic@xxxxxxxxxx>
Date:   Fri Oct 27 16:40:48 2023 +0200

    rcu/tasks: Handle new PF_IDLE semantics
    
    [ Upstream commit 9715ed501b585d47444865071674c961c0cc0020 ]
    
    The commit:
    
            cff9b2332ab7 ("kernel/sched: Modify initial boot task idle setup")
    
    has changed the semantics of what is to be considered an idle task in
    such a way that CPU boot code preceding the actual idle loop is excluded
    from it.
    
    This has however introduced new potential RCU-tasks stalls when either:
    
    1) Grace period is started before init/0 had a chance to set PF_IDLE,
       keeping it stuck in the holdout list until idle ever schedules.
    
    2) Grace period is started when some possible CPUs have never been
       online, keeping their idle tasks stuck in the holdout list until the
       CPU ever boots up.
    
    3) Similar to 1) but with secondary CPUs: Grace period is started
       concurrently with secondary CPU booting, putting its idle task in
       the holdout list because PF_IDLE isn't yet observed on it. It stays
       then stuck in the holdout list until that CPU ever schedules. The
       effect is mitigated here by the hotplug AP thread that must run to
       bring the CPU up.
    
    Fix this with handling the new semantics of PF_IDLE, keeping in mind
    that it may or may not be set on an idle task. Take advantage of that to
    strengthen the coverage of an RCU-tasks quiescent state within an idle
    task, excluding the CPU boot code from it. Only the code running within
    the idle loop is now a quiescent state, along with offline CPUs.
    
    Fixes: cff9b2332ab7 ("kernel/sched: Modify initial boot task idle setup")
    Suggested-by: Joel Fernandes <joel@xxxxxxxxxxxxxxxxx>
    Suggested-by: Paul E . McKenney" <paulmck@xxxxxxxxxx>
    Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
    Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/kernel/rcu/tasks.h b/kernel/rcu/tasks.h
index 8d65f7d576a34..b5dc1e5d78c83 100644
--- a/kernel/rcu/tasks.h
+++ b/kernel/rcu/tasks.h
@@ -892,10 +892,36 @@ static void rcu_tasks_pregp_step(struct list_head *hop)
 	synchronize_rcu();
 }
 
+/* Check for quiescent states since the pregp's synchronize_rcu() */
+static bool rcu_tasks_is_holdout(struct task_struct *t)
+{
+	int cpu;
+
+	/* Has the task been seen voluntarily sleeping? */
+	if (!READ_ONCE(t->on_rq))
+		return false;
+
+	/*
+	 * Idle tasks (or idle injection) within the idle loop are RCU-tasks
+	 * quiescent states. But CPU boot code performed by the idle task
+	 * isn't a quiescent state.
+	 */
+	if (is_idle_task(t))
+		return false;
+
+	cpu = task_cpu(t);
+
+	/* Idle tasks on offline CPUs are RCU-tasks quiescent states. */
+	if (t == idle_task(cpu) && !rcu_cpu_online(cpu))
+		return false;
+
+	return true;
+}
+
 /* Per-task initial processing. */
 static void rcu_tasks_pertask(struct task_struct *t, struct list_head *hop)
 {
-	if (t != current && READ_ONCE(t->on_rq) && !is_idle_task(t)) {
+	if (t != current && rcu_tasks_is_holdout(t)) {
 		get_task_struct(t);
 		t->rcu_tasks_nvcsw = READ_ONCE(t->nvcsw);
 		WRITE_ONCE(t->rcu_tasks_holdout, true);
@@ -944,7 +970,7 @@ static void check_holdout_task(struct task_struct *t,
 
 	if (!READ_ONCE(t->rcu_tasks_holdout) ||
 	    t->rcu_tasks_nvcsw != READ_ONCE(t->nvcsw) ||
-	    !READ_ONCE(t->on_rq) ||
+	    !rcu_tasks_is_holdout(t) ||
 	    (IS_ENABLED(CONFIG_NO_HZ_FULL) &&
 	     !is_idle_task(t) && t->rcu_tasks_idle_cpu >= 0)) {
 		WRITE_ONCE(t->rcu_tasks_holdout, false);




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux