diff mbox series

[ANNOUNCE] v5.19-rc7-rt7

Message ID Ytgsp00o2dfGRn9v@linutronix.de
State New
Headers show
Series [ANNOUNCE] v5.19-rc7-rt7 | expand

Commit Message

Sebastian Andrzej Siewior July 20, 2022, 4:26 p.m. UTC
Dear RT folks!

I'm pleased to announce the v5.19-rc7-rt7 patch set. 

Changes since v5.19-rc7-rt6:

  - Slightly update the ptrace patch (for wait_task_inactive(). There is
    no change in functionality, just the code has been reordered.

Known issues
     - Valentin Schneider reported a few splats on ARM64, see
          https://lkml.kernel.org/r/20210810134127.1394269-1-valentin.schneider@arm.com

The delta patch against v5.19-rc7-rt6 is appended below and can be found here:
 
     https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.19/incr/patch-5.19-rc7-rt6-rt7.patch.xz

You can get this release via the git tree at:

    git://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v5.19-rc7-rt7

The RT patch against v5.19-rc7 can be found here:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.19/older/patch-5.19-rc7-rt7.patch.xz

The split quilt queue is available at:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/5.19/older/patches-5.19-rc7-rt7.tar.xz

Sebastian
diff mbox series

Patch

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1d4660a1915b3..377e7d4139d87 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3299,6 +3299,40 @@  int migrate_swap(struct task_struct *cur, struct task_struct *p,
 }
 #endif /* CONFIG_NUMA_BALANCING */
 
+#ifdef CONFIG_PREEMPT_RT
+static __always_inline bool state_mismatch(struct task_struct *p, unsigned int match_state)
+{
+	unsigned long flags;
+	bool mismatch;
+
+	raw_spin_lock_irqsave(&p->pi_lock, flags);
+	mismatch = READ_ONCE(p->__state) != match_state &&
+		READ_ONCE(p->saved_state) != match_state;
+	raw_spin_unlock_irqrestore(&p->pi_lock, flags);
+	return mismatch;
+}
+static __always_inline bool state_match(struct task_struct *p, unsigned int match_state,
+					bool *wait)
+{
+	if (READ_ONCE(p->__state) == match_state)
+		return true;
+	if (READ_ONCE(p->saved_state) != match_state)
+		return false;
+	*wait = true;
+	return true;
+}
+#else
+static __always_inline bool state_mismatch(struct task_struct *p, unsigned int match_state)
+{
+	return READ_ONCE(p->__state) != match_state;
+}
+static __always_inline bool state_match(struct task_struct *p, unsigned int match_state,
+					bool *wait)
+{
+	return READ_ONCE(p->__state) == match_state;
+}
+#endif
+
 /*
  * wait_task_inactive - wait for a thread to unschedule.
  *
@@ -3317,12 +3351,10 @@  int migrate_swap(struct task_struct *cur, struct task_struct *p,
  */
 unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state)
 {
-	int running, queued;
+	bool running, wait;
 	struct rq_flags rf;
 	unsigned long ncsw;
 	struct rq *rq;
-	bool saved_state_match;
-	bool update_ncsw;
 
 	for (;;) {
 		/*
@@ -3345,24 +3377,8 @@  unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 		 * is actually now running somewhere else!
 		 */
 		while (task_running(rq, p)) {
-
-			if (match_state) {
-				bool mismatch = false;
-#ifndef CONFIG_PREEMPT_RT
-				if (READ_ONCE(p->__state != match_state)
-					mismatch = true;
-#else
-				unsigned long flags;
-
-				raw_spin_lock_irqsave(&p->pi_lock, flags);
-				if (READ_ONCE(p->__state) != match_state &&
-				    READ_ONCE(p->saved_state) != match_state)
-					mismatch = true;
-				raw_spin_unlock_irqrestore(&p->pi_lock, flags);
-#endif
-				if (mismatch)
-					return 0;
-			}
+			if (match_state && state_mismatch(p, match_state))
+				return 0;
 			cpu_relax();
 		}
 
@@ -3374,24 +3390,12 @@  unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 		rq = task_rq_lock(p, &rf);
 		trace_sched_wait_task(p);
 		running = task_running(rq, p);
-		queued = task_on_rq_queued(p);
+		wait = task_on_rq_queued(p);
 		ncsw = 0;
-		update_ncsw = false;
-		saved_state_match = false;
 
-		if (!match_state) {
-			update_ncsw = true;
-		} else if (READ_ONCE(p->__state) == match_state) {
-			update_ncsw = true;
-#ifdef CONFIG_PREEMPT_RT
-		} else if (READ_ONCE(p->saved_state) == match_state) {
-			update_ncsw = true;
-			saved_state_match = true;
-#endif
-		}
-
-		if (update_ncsw)
+		if (!match_state || state_match(p, match_state, &wait))
 			ncsw = p->nvcsw | LONG_MIN; /* sets MSB */
+
 		task_rq_unlock(rq, p, &rf);
 
 		/*
@@ -3420,7 +3424,7 @@  unsigned long wait_task_inactive(struct task_struct *p, unsigned int match_state
 		 * running right now), it's preempted, and we should
 		 * yield - it could be a while.
 		 */
-		if (unlikely(queued) || saved_state_match) {
+		if (unlikely(wait)) {
 			ktime_t to = NSEC_PER_SEC / HZ;
 
 			set_current_state(TASK_UNINTERRUPTIBLE);
diff --git a/localversion-rt b/localversion-rt
index 8fc605d806670..045478966e9f1 100644
--- a/localversion-rt
+++ b/localversion-rt
@@ -1 +1 @@ 
--rt6
+-rt7