Skip to contentSkip to conversation

v6.5-rc4-rt2

ANNOUNCE Sebastian Andrzej Siewior 1 participant 1 message Aug 4, 2023

Subsystems (7)
x86 Sound ASoC Arm MediaTek +3 more subsystems
lore
Share & tools
lore
#0 lore raw

Dear RT folks!

I'm pleased to announce the v6.5-rc4-rt2 patch set.

Changes since v6.5-rc4-rt1:

- Don't tell a CPU to push tasks for RT balancing if there are no tasks that can be pushed.

- Preempt the timer softirq if it is PI boosted. This is to see how it works and to start discussion with upstream how to proceed with the underlying issue.

- Remove a mutex in x86'microcode and ASoC's mt8186 code which were causing "unused variable" warning during RT build.

- Update a comment in ptrace code while reposting the relevant patch.

Known issues
None

The delta patch against v6.5-rc4-rt1 is appended below and can be found here:

     https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.5/incr/patch-6.5-rc4-rt1-rt2.patch.xz

You can get this release via the git tree at:

    https://git.kernel.org/pub/scm/linux/kernel/git/rt/linux-rt-devel.git v6.5-rc4-rt2

The RT patch against v6.5-rc4 can be found here:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.5/older/patch-6.5-rc4-rt2.patch.xz

The split quilt queue is available at:

    https://cdn.kernel.org/pub/linux/kernel/projects/rt/6.5/older/patches-6.5-rc4-rt2.tar.xz

Sebastian

arch/x86/kernel/cpu/common.c +1 -2
index 0ba1067f4e5f1..de49b9cd8077a 100644
@@ -2276,8 +2276,7 @@ void store_cpu_caps(struct cpuinfo_x86 *curr_info)
  * @prev_info:	CPU capabilities stored before an update.
  *
  * The microcode loader calls this upon late microcode load to recheck features,
- * only when microcode has been updated. Caller holds microcode_mutex and CPU
- * hotplug lock.
+ * only when microcode has been updated. Caller holds and CPU hotplug lock.
  *
  * Return: None
  */
arch/x86/kernel/cpu/microcode/core.c +0 -6
index 3afcf3de0dd49..2f9d35744bc41 100644
@@ -54,15 +54,12 @@ LIST_HEAD(microcode_cache);
  *
  * All non cpu-hotplug-callback call sites use:
  *
- * - microcode_mutex to synchronize with each other;
  * - cpus_read_lock/unlock() to synchronize with
  *   the cpu-hotplug-callback call sites.
  *
  * We guarantee that only a single cpu is being
  * updated at any particular moment of time.
  */
-static DEFINE_MUTEX(microcode_mutex);
-
 struct ucode_cpu_info		ucode_cpu_info[NR_CPUS];
 
 struct cpu_info_ctx {
@@ -488,10 +485,7 @@ static ssize_t reload_store(struct device *dev,
 	if (tmp_ret != UCODE_NEW)
 		goto put;
 
-	mutex_lock(&microcode_mutex);
 	ret = microcode_reload_late();
-	mutex_unlock(&microcode_mutex);
-
 put:
 	cpus_read_unlock();
 
include/linux/bottom_half.h +2 -0
index fc53e0ad56d90..448bbef474564 100644
@@ -35,8 +35,10 @@ static inline void local_bh_enable(void)
 
 #ifdef CONFIG_PREEMPT_RT
 extern bool local_bh_blocked(void);
+extern void softirq_preempt(void);
 #else
 static inline bool local_bh_blocked(void) { return false; }
+static inline void softirq_preempt(void) { }
 #endif
 
 #endif /* _LINUX_BH_H */
include/linux/sched.h +1 -0
index 973172547c125..7b235881a0ad0 100644
@@ -1892,6 +1892,7 @@ static inline int dl_task_check_affinity(struct task_struct *p, const struct cpu
 }
 #endif
 
+extern bool task_is_pi_boosted(const struct task_struct *p);
 extern int yield_to(struct task_struct *p, bool preempt);
 extern void set_user_nice(struct task_struct *p, long nice);
 extern int task_prio(const struct task_struct *p);
kernel/sched/core.c +15 -0
index 6991e1982f8d9..2276b5d882380 100644
@@ -8965,6 +8965,21 @@ static inline void preempt_dynamic_init(void) { }
 
 #endif /* #ifdef CONFIG_PREEMPT_DYNAMIC */
 
+/*
+ * task_is_pi_boosted - Check if task has been PI boosted.
+ * @p:	Task to check.
+ *
+ * Return true if task is subject to priority inheritance.
+ */
+bool task_is_pi_boosted(const struct task_struct *p)
+{
+	int prio = p->prio;
+
+	if (!rt_prio(prio))
+		return false;
+	return prio != p->normal_prio;
+}
+
 /**
  * yield - yield the current processor to other threads.
  *
kernel/sched/rt.c +4 -1
index 00e0e50741153..338cd150973ff 100644
@@ -2247,8 +2247,11 @@ static int rto_next_cpu(struct root_domain *rd)
 
 		rd->rto_cpu = cpu;
 
-		if (cpu < nr_cpu_ids)
+		if (cpu < nr_cpu_ids) {
+			if (!has_pushable_tasks(cpu_rq(cpu)))
+				continue;
 			return cpu;
+		}
 
 		rd->rto_cpu = -1;
 
kernel/signal.c +6 -2
index d41eafca39687..6c9af878bd6ed 100644
@@ -2334,8 +2334,12 @@ static int ptrace_stop(int exit_code, int why, unsigned long message,
 	 * between unlock and schedule() and so improving the performance since
 	 * the ptracer has no reason to sleep.
 	 *
-	 * This optimisation is not doable on PREEMPT_RT due to the spinlock_t
-	 * within the preempt-disable section.
+	 * On PREEMPT_RT locking tasklist_lock does not disable preemption.
+	 * Therefore the task can be preempted (after
+	 * do_notify_parent_cldstop()) before unlocking tasklist_lock so there
+	 * is no benefit in doing this. The optimisation is harmful on
+	 * PEEMPT_RT because the spinlock_t (in cgroup_enter_frozen()) must not
+	 * be acquired with disabled preemption.
 	 */
 	if (!IS_ENABLED(CONFIG_PREEMPT_RT))
 		preempt_disable();
kernel/softirq.c +13 -0
index 623985f188336..334232227c43c 100644
@@ -247,6 +247,19 @@ void __local_bh_enable_ip(unsigned long ip, unsigned int cnt)
 }
 EXPORT_SYMBOL(__local_bh_enable_ip);
 
+void softirq_preempt(void)
+{
+	if (WARN_ON_ONCE(!preemptible()))
+		return;
+
+	if (WARN_ON_ONCE(__this_cpu_read(softirq_ctrl.cnt) != SOFTIRQ_OFFSET))
+		return;
+
+	__local_bh_enable(SOFTIRQ_OFFSET, true);
+	/* preemption point */
+	__local_bh_disable_ip(_RET_IP_, SOFTIRQ_OFFSET);
+}
+
 /*
  * Invoked from ksoftirqd_run() outside of the interrupt disabled section
  * to acquire the per CPU local lock for reentrancy protection.
kernel/time/timer.c +8 -1
index 7cad6fe3c035c..b3fbe97d1e342 100644
@@ -1470,9 +1470,16 @@ static inline void timer_base_unlock_expiry(struct timer_base *base)
  */
 static void timer_sync_wait_running(struct timer_base *base)
 {
-	if (atomic_read(&base->timer_waiters)) {
+	bool need_preempt;
+
+	need_preempt = task_is_pi_boosted(current);
+	if (need_preempt || atomic_read(&base->timer_waiters)) {
 		raw_spin_unlock_irq(&base->lock);
 		spin_unlock(&base->expiry_lock);
+
+		if (need_preempt)
+			softirq_preempt();
+
 		spin_lock(&base->expiry_lock);
 		raw_spin_lock_irq(&base->lock);
 	}
localversion-rt +1 -1
index 6f206be67cd28..c3054d08a1129 100644
@@ -1 +1 @@
--rt1
+-rt2
sound/soc/mediatek/mt8186/mt8186-afe-clk.c +0 -2
index 539e3a023bc4e..70ec101890d36 100644
@@ -13,8 +13,6 @@
 #include "mt8186-afe-clk.h"
 #include "mt8186-audsys-clk.h"
 
-static DEFINE_MUTEX(mutex_request_dram);
-
 static const char *aud_clks[CLK_NUM] = {
 	[CLK_AFE] = "aud_afe_clk",
 	[CLK_DAC] = "aud_dac_clk",