From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796380337; b=jUerfLYVU2g6VxpkXYqi6lSp8aJ0HShjWfigDNQLc9E9SBam4jz2N+jlw6o22SdPtIDH +SOD/+vmZHVBXIBYe/xiBy6ubgIx6TqA7ehkuPGQBftMKdEumHpa7h5J8rN6mMdNxljsW P6AYaRsc/yffj5U4+QhPVFVD1gbSdLev73tPlDBEyF9odUMLwfF2B6l2wrMWk3PdWEXLJ YF/+DmUhyfES8b5epV3kFgbj/AxU8m6tNcxAqCwYV/vvG8+liJeN4YxI8DP6tO/gVRgL0 Gs3QCjIYdBjD7xmSVbXjMZjj4amQxMGum0VJyZcuvNMCPiuwB1aCeUOiJAAOsEBIkDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796380337; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=S26d78IIILt5UfX80RuoyKTNwrl2tUCPto9jn83w0iM=; b=fxTfuFLzzb3Hiwgz9EQQOpi8iuLEfifd6zaSN3mxRzadiGwHNNVhA1qrQj3GwH9mETAt Y5+HKp4+jUUBuWTNHIcWhkQN4nTkWS4Dbzvaj+ZTxtX2TY+/4AmFSS48TWfFLT1pLd0ML MNqpYEHtKgtjgx77VSf9Mk2FIzcepN4Gy//EILuutqoNcEJcybIApDhtnY3kco36AYpgX Znsdj1ZEa8jFX62Jd5tPouyt2LxKjwDFk4YBEza8EGovitcogqknGqo4p83ZTRplxh/hE 6WmHBuZdqdNvggXgmqdueYP127yWXybTGHjko5AFSKfI/XpSmkRo6/Yp4WakIB00vHg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yWRsDtzM; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EFD0606A32F; Fri, 4 Dec 2026 10:32:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=yWRsDtzM Received: by smtp.kernel.org (Postfix) with ESMTPSA id F26E51F000C2; Fri, 4 Dec 2026 10:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796380337; bh=S26d78IIILt5UfX80RuoyKTNwrl2tUCPto9jn83w0iM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=yWRsDtzMHx6BMGjAo0na00FfA6IsBeT7DtU+CHTRc+XMi1mKPTI+AhWsKHAksMHZp jVxRvtW11Nv20d0PZAYF7NkgPPZLxQ/VDpB39eZoxGeo+5nbYryfmVt61ys8te7D5l rVvcYji7WTpdV13vlVtEWb+JJc3BFqoNcnYg4e0o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Waiman Long , Frederic Weisbecker , Ridong Chen , Guopeng Zhang , Tejun Heo , Sasha Levin Subject: [PATCH 7.3 231/742] tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent Date: Fri, 4 Dec 2026 19:01:35 +0900 Message-ID: <20261204100641.209380551@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100635.034361255@linuxfoundation.org> References: <20261204100635.034361255@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Waiman Long [ Upstream commit 884e88175b95a03ea9f4dc8c89acca5d5b33cbd2 ] When the nohz_full boot parameter is first set, the cpu list parameter is passed directly to tick_nohz_full_setup() to set up tick_nohz_full_mask cpumask. Then the HK_TYPE_KERNEL_NOISE cpumask will be set up as the inverse of given cpu list parameter. Some of the timer code and RCU uses tick_nohz_full_mask directly while other timer code, scheduler and other subsystems use the HK_TYPE_KERNEL_NOISE cpumask. With CONFIG_PM_SLEEP_SMP && !CONFIG_PM_SLEEP_SMP_NONZERO_CPU config options, the boot CPU will be cleared from tick_nohz_full_mask if set while the corresponding HK_TYPE_KERNEL_NOISE cpumask isn't touched. The nohz_full entry in kernel-parameters.txt does state that the boot CPU will be forced outside the range to maintain the timekeeping. So it makes sense that the HK_TYPE_KERNEL_NOISE should be modified accordingly. Fix this inconsistency problem by adding a new cpumask_set_cpu() init function to be called by tick_nohz_init() when the boot CPU is cleared from tick_nohz_full_mask. In the special case that "nohz_full=0" and CPU 0 is cleared in tick_nohz_init(), tick_nohz_full_running will be set to false. However, housekeeping_enabled(HK_TYPE_KERNEL_NOISE) will stil be true with housekeeping_cpumask(HK_TYPE_KERNEL_NOISE) equal to cpu_possible_mask. So some unneeded code paths will be activated, but no harm will be done other than wasting some CPU cycles. Another problem that needs further thought but is not handled in this patch is when arch_irq_work_has_interrupt() turns out to be false. When this happens, tick_nohz_full_mask will be cleared and tick_nohz_full_running will be set back to false in tick_nohz_init(). PM_SLEEP_SMP_NONZERO_CPU depends on ARCH_SUSPEND_NONZERO_CPU which can only be set for the PowerPC architecture. Moreover CONFIG_PM_SLEEP_SMP is on by default, it means most kernels will not allow CPU 0 to be set in the tick_nohz_full_mask and hence should be set in HK_TYPE_KERNEL_NOISE cpumask. Fixes: 6f1982fedd59 ("sched/isolation: Handle the nohz_full= parameter") Signed-off-by: Waiman Long Reviewed-by: Frederic Weisbecker Reviewed-by: Ridong Chen Acked-by: Guopeng Zhang Tested-by: Guopeng Zhang Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- include/linux/sched/isolation.h | 2 ++ kernel/sched/isolation.c | 11 +++++++++++ kernel/time/tick-sched.c | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/include/linux/sched/isolation.h b/include/linux/sched/isolation.h index cf0fd03dd7a24..ae5109450ac92 100644 --- a/include/linux/sched/isolation.h +++ b/include/linux/sched/isolation.h @@ -44,6 +44,7 @@ extern bool housekeeping_enabled(enum hk_type type); extern void housekeeping_affine(struct task_struct *t, enum hk_type type); extern bool housekeeping_test_cpu(int cpu, enum hk_type type); extern int housekeeping_update(struct cpumask *isol_mask); +extern void __init housekeeping_set_cpu(int cpu, enum hk_type type); extern void __init housekeeping_init(void); #else @@ -72,6 +73,7 @@ static inline bool housekeeping_test_cpu(int cpu, enum hk_type type) } static inline int housekeeping_update(struct cpumask *isol_mask) { return 0; } +static inline void housekeeping_set_cpu(int cpu, enum hk_type type) { } static inline void housekeeping_init(void) { } #endif /* CONFIG_CPU_ISOLATION */ diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c index 156025ef81b75..c0c8b8862cbdc 100644 --- a/kernel/sched/isolation.c +++ b/kernel/sched/isolation.c @@ -120,6 +120,17 @@ bool housekeeping_test_cpu(int cpu, enum hk_type type) } EXPORT_SYMBOL_GPL(housekeeping_test_cpu); +void __init housekeeping_set_cpu(int cpu, enum hk_type type) +{ + /* Only CPU setting of HK_TYPE_KERNEL_NOISE is currently supported */ + if (type != HK_TYPE_KERNEL_NOISE) + return; + + if (static_branch_unlikely(&housekeeping_overridden) && + READ_ONCE(housekeeping.flags) & BIT(type)) + cpumask_set_cpu(cpu, housekeeping_cpumask_dereference(type)); +} + int housekeeping_update(struct cpumask *isol_mask) { struct cpumask *trial, *old = NULL; diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 6546e196645f2..81180573a4c51 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -683,6 +684,11 @@ void __init tick_nohz_init(void) pr_warn("NO_HZ: Clearing %d from nohz_full range " "for timekeeping\n", cpu); cpumask_clear_cpu(cpu, tick_nohz_full_mask); + housekeeping_set_cpu(cpu, HK_TYPE_KERNEL_NOISE); + if (cpumask_empty(tick_nohz_full_mask)) { + tick_nohz_full_running = false; + return; + } } } -- 2.53.0