Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795494509; b=wnsgQNZGs7naIpZzlLyZazlrPX4EhouXXNvcPxQ0esNrZx9QYQIqwp4uji5PPp4Xy0Lf aA9UdhWVSaMcERz6n/yrNJAxtGSNTKB4mv+JRv7ZCyMjEwMRU4Us/jEwFzLmJt3F0Xmvw 0WwytietD0RqIUpTJXcbH5FcbG/YQId0gtllyaWxvuJ2qUEkVa07E0hQF2Mi7I5gIujCn mFtE2xUBgpgJozR2Sl7IinpwWxmE5ydyb/a3wt7R7M2f3hnFS//COnqGuBsbkHHRCROY+ HL+HUc86THOH3H0OBBKEFdfF7JCO6WNB1XTae3WlS1Lp0keKO4WAbsYC42U6Eo7QhNA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795494509; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:X-Scanned-By; bh=B5Nbip6TzYi7GMeSs8uz5LlNsZqZbiwKYLK2KGz0yaE=; b=LLOeLnmWu5NpnAuqCzmN2Lhx9ihBuGdwDlFW+YI4K6UZtQTjtCd7EsZ4YkUPXhueX2bW dujjUT9zHE90yIyuD921TbMA0TAN1r6fg8aiWZpk2IGrc8THp8GjnuSdFM2Drd8kke/lZ 8w9ei6WzwN0rA0T7qUaRRTqkk03/hrC6qwwLnrMt/5ZjajjjBZ2YIxZgLpMPiVAwzwi08 0iH1VM8HrujI8ubhi1+UMTNZdygOX0KswtI6W7RADEUQTk4io1w5k0A3moLfPZRCAztFP ppZK9gQDm/6zU/kHZmkC4IZS5F60iJxwO8rLYn4LapY8m9h2qgapFGHXKpMw94HEmug== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ddx81BVA; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 10310606A322 for ; Tue, 24 Nov 2026 04:28:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 10310606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ddx81BVA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1795494508; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=B5Nbip6TzYi7GMeSs8uz5LlNsZqZbiwKYLK2KGz0yaE=; b=ddx81BVAmA+vvMqr0uOmCBCiSeOiOCq759E3hlvsWwCM/+vQR2m3ZP2CI9TrPTuEL14uwh IXo6Q+jtgdE3pWvXCTDjcfQluaApNZr5xbluM0ouoAWS0r/rFFjh6HfUPs1lAqg1I0n/3C vZ0LSJ8s7PVXD/laT6zpoN2cDdxKhqc= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-g94d1F3YMbmZc3nWerwmGQ-1; Tue, 24 Nov 2026 04:28:23 +0000 X-MC-Unique: g94d1F3YMbmZc3nWerwmGQ-1 X-Mimecast-MFC-AGG-ID: g94d1F3YMbmZc3nWerwmGQ_1795494500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 79D711955DE1; Tue, 24 Nov 2026 04:28:19 +0000 (UTC) Received: from llong-thinkpadp16vgen1.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id ABF3818004F7; Tue, 24 Nov 2026 04:28:14 +0000 (UTC) From: Waiman Long To: Tejun Heo , Johannes Weiner , =?UTF-8?q?Michal=20Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Randy Dunlap , Ridong Chen , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Guopeng Zhang , Mathieu Desnoyers , Waiman Long , Guopeng Zhang Subject: [PATCH-next v3 1/3] tick/sched: Make tick_nohz_full_mask and HK_TYPE_KERNEL_NOISE cpumask consistent Date: Mon, 23 Nov 2026 23:28:00 -0500 Message-ID: <20261124042802.532633-2-longman@redhat.com> In-Reply-To: <20261124042802.532633-1-longman@redhat.com> References: <20261124042802.532633-1-longman@redhat.com> X-Mailing-List: linux-doc@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 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 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 --- 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 cf0fd03dd7a2..ae5109450ac9 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 156025ef81b7..c0c8b8862cbd 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 255488366d7c..99ca2982e29d 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.56.1