From patchwork Fri Aug 4 16:22:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 131301 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp38173vqr; Fri, 4 Aug 2023 11:57:18 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsriEzoS7oCPZSX1GzgPT+C91Hefzt3l6whxDFnvfh4GRY6sgQWDSZdJOHYtfMAwmYsgdx X-Received: by 2002:a17:906:7494:b0:988:71c8:9f3a with SMTP id e20-20020a170906749400b0098871c89f3amr533111ejl.16.1691175438264; Fri, 04 Aug 2023 11:57:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691175438; cv=none; d=google.com; s=arc-20160816; b=mghXpbMpeRhZTMzbH1mLRrIO99O3UjwBYAOBI7Oii8jrVcB/5gT04IIlyvi5sr/yWf dJs5T0JltzpGE0DTsmC5DLMnCchLmjsphOxFeNuRfJxrQk1K3xaRVn6m5tmteAyuA1BJ 0TDKx8Og++SmEOHGXbA/+5WkvC12uAEmxh4SkfU0FSm/7+Q3IkNgXTtxXsbJfzPbz+Ay 8elEC8IFcHiqycxtr1hb0ERBiPSiRjh5QD7kXJBfspsFgx1DC+ArhIRm6lqAhdBnhXvB IgOsyl6pV9arp1aEIA7RObzKKavvu3TFifxO2lai6a+jZxKXO9yGiF8QJb/bD0UaFykA FQ/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:dkim-signature:dkim-signature:date; bh=iySTVOckX9+4B55Jdn4fzCaqPXIiAN5/63bxAu4lyw4=; fh=cMXQV+gx/62cjI5+te06T7fjZIQk/rXQAWZPyVBb96s=; b=R1PvhBxjshA3qnN0QwsaMy/4ENMmsg0erWlVFP0pyhv+3Yt2AdwtD1Xe1xjTUjy9oc u6Bunves7PKYai26BmMrfu4FgrQxtvqoH2PA6HseA2i1S17F+zM96ctopUikcS3vYLWG e85hiitMTv/j7fiobKHenRA++r8sc5MHyIWv4j0fR8s32nia9s5X/d4upo8PBHrX6WNw HTew9Q379c4b9dgBQrRkMD/WJM0lJHCyQbHlip0tF95MM6P0qW8yCBCnawNbUZEEo+Z4 e/2OU3kSFDXUfn1Laz7vWsQBJI5kP4p3vImrZpaK+cOiIuRRjUARPD+cGFdA/xcuCcXz yO9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ythTYkDp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="zy/PdL6Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r5-20020a170906280500b0099381745ba0si1948810ejc.156.2023.08.04.11.56.55; Fri, 04 Aug 2023 11:57:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ythTYkDp; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="zy/PdL6Q"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229915AbjHDQW6 (ORCPT + 99 others); Fri, 4 Aug 2023 12:22:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbjHDQWv (ORCPT ); Fri, 4 Aug 2023 12:22:51 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC6A3B2; Fri, 4 Aug 2023 09:22:49 -0700 (PDT) Date: Fri, 4 Aug 2023 18:22:46 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1691166167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=iySTVOckX9+4B55Jdn4fzCaqPXIiAN5/63bxAu4lyw4=; b=ythTYkDpds9hd67Ha1URqBnnVwFpvK16gbl1DEvs5CCE1Oqt3333BMliHMF74WJTHQk9m7 O2X2G9yqEZW86UgR8JcfXgFHdhIxjGMBNoGAGc6LtwPYOiSMfPdghfHwzz1mEiesuvwZU5 C9/EqSyr/glp1XoBQSSLM1JorQW/BDvgcc1Q/NEBQCiqilmLW0PXCpzX4+aH7mL4CxA1Qs ISWbenaM4zmdbtOReFI/y59WUXgD344C0BAtWBmEgouwdaN17iG7JK9hb/VHcFSG2JMgWC Slh5b+OiBM8Ue0irBU4xmirwbFqRm5VI3a2YXI68hlwl8UlERNGBNZrQnEOphw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1691166167; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=iySTVOckX9+4B55Jdn4fzCaqPXIiAN5/63bxAu4lyw4=; b=zy/PdL6QpRcolOXixY1i95ogR7Q+5jPzUIXaw2Uk0ITaSQcQAfep4tsbydynTpaVNWLbFN V6HjYG9s74gbEZAw== From: Sebastian Andrzej Siewior To: Thomas Gleixner Cc: LKML , linux-rt-users@vger.kernel.org, Steven Rostedt Subject: [ANNOUNCE] v6.5-rc4-rt2 Message-ID: <20230804162246.CUJllMTk@linutronix.de> MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773325975959038416 X-GMAIL-MSGID: 1773325975959038416 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 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 0ba1067f4e5f1..de49b9cd8077a 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c @@ -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 */ diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 3afcf3de0dd49..2f9d35744bc41 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c @@ -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(µcode_mutex); ret = microcode_reload_late(); - mutex_unlock(µcode_mutex); - put: cpus_read_unlock(); diff --git a/include/linux/bottom_half.h b/include/linux/bottom_half.h index fc53e0ad56d90..448bbef474564 100644 --- a/include/linux/bottom_half.h +++ b/include/linux/bottom_half.h @@ -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 */ diff --git a/include/linux/sched.h b/include/linux/sched.h index 973172547c125..7b235881a0ad0 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -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); diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 6991e1982f8d9..2276b5d882380 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -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. * diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index 00e0e50741153..338cd150973ff 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c @@ -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; diff --git a/kernel/signal.c b/kernel/signal.c index d41eafca39687..6c9af878bd6ed 100644 --- a/kernel/signal.c +++ b/kernel/signal.c @@ -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(); diff --git a/kernel/softirq.c b/kernel/softirq.c index 623985f188336..334232227c43c 100644 --- a/kernel/softirq.c +++ b/kernel/softirq.c @@ -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. diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 7cad6fe3c035c..b3fbe97d1e342 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -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); } diff --git a/localversion-rt b/localversion-rt index 6f206be67cd28..c3054d08a1129 100644 --- a/localversion-rt +++ b/localversion-rt @@ -1 +1 @@ --rt1 +-rt2 diff --git a/sound/soc/mediatek/mt8186/mt8186-afe-clk.c b/sound/soc/mediatek/mt8186/mt8186-afe-clk.c index 539e3a023bc4e..70ec101890d36 100644 --- a/sound/soc/mediatek/mt8186/mt8186-afe-clk.c +++ b/sound/soc/mediatek/mt8186/mt8186-afe-clk.c @@ -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",