From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8C3E933F8C2; Tue, 21 Apr 2026 08:50:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776761405; cv=none; b=lOIGx6YXscpfqI0bLAOdsUshkLoHN1byaSH9z3pjDsR7p+jR1nZT7ZtPM8kLej4RadszpYD9vUwFVFDckxJlRp7tQAYkrsRk8mskvzxJsDa+ewGnqig3/6noJX949bsnLigGsUydoTNxoeR1DlazZJtsGYnSKScchMBVu4B/Coo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776761405; c=relaxed/simple; bh=HaTQPXvOEJyusO788jGddOJOEFqrCuHs2/f3+g1Am18=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=T2cuOIyS0I6Iac9j8mdgjq7OuJsnpFJaXsWPHLMIACAEkKMsDHbmuPJ3rNSEjRkXRsRtGjfZOvDtP0dBGJH1TdcmWW4GULNUSw1/qwaEWA/SfsIPVgWPA29H50DY7ISjnhdmdO5x7IaND3HFuhtNI4igdfDGoIQ5c3kNwdu3AZE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pR8Z523t; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pR8Z523t" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8BB7C2BCB5; Tue, 21 Apr 2026 08:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1776761405; bh=HaTQPXvOEJyusO788jGddOJOEFqrCuHs2/f3+g1Am18=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=pR8Z523tl/pYJTgna0TzpDJ97VzUhuDGpfMXUMlZSvJUP88/Uf6wwLL6TZpPWR05u fD93UYvGK1Z22WuxegmEtlR4ePNUVX6G2eE2ADwU3KwsnRkrgv6KuslEMDj4RRqwRM 14skmyaN7pOCw5z4aXywKO7WdmtNgjWIjQBE7KBokI+Z8nr8LT+UnHedRP0w1FkO7/ PdygA/+aEmRmgNTyEpaQ4QOWy0df653T3ZV/1poX6L5HiEPSJxYDfp5OljRX0SkdFT tqfeD8TETWZix6tWtCS922YGEo3mzAzhVFRtMGSFWkbCfLN9whd61bgc0fioeZwxZd WIVg9roArtZ/w== From: Thomas Gleixner To: Waiman Long , Tejun Heo , Johannes Weiner , Michal =?utf-8?Q?Koutn=C3=BD?= , Jonathan Corbet , Shuah Khan , Catalin Marinas , Will Deacon , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Long Li , Guenter Roeck , Frederic Weisbecker , "Paul E. McKenney" , Neeraj Upadhyay , Joel Fernandes , Josh Triplett , Boqun Feng , Uladzislau Rezki , Steven Rostedt , Mathieu Desnoyers , Lai Jiangshan , Zqiang , Anna-Maria Behnsen , Ingo Molnar , Chen Ridong , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Ben Segall , Mel Gorman , Valentin Schneider , K Prateek Nayak , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman Cc: cgroups@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-hyperv@vger.kernel.org, linux-hwmon@vger.kernel.org, rcu@vger.kernel.org, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, Costa Shulyupin , Qiliang Yuan , Waiman Long Subject: Re: [PATCH 04/23] tick/nohz: Allow runtime changes in full dynticks CPUs In-Reply-To: <20260421030351.281436-5-longman@redhat.com> References: <20260421030351.281436-1-longman@redhat.com> <20260421030351.281436-5-longman@redhat.com> Date: Tue, 21 Apr 2026 10:50:00 +0200 Message-ID: <87340od7ev.ffs@tglx> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Mon, Apr 20 2026 at 23:03, Waiman Long wrote: > Full dynticks can only be enabled if "nohz_full" boot option has been > been specified with or without parameter. Any change in the list of > nohz_full CPUs have to be reflected in tick_nohz_full_mask. Introduce > a new tick_nohz_full_update_cpus() helper that can be called to update > the tick_nohz_full_mask at run time. The housekeeping_update() function > is modified to call the new helper when the HK_TYPE_KERNEL_NOSIE cpumask > is going to be changed. > > We also need to enable CPU context tracking for those CPUs that We need nothing. Use passive voice for change logs as requested in documentation. > are in tick_nohz_full_mask. So remove __init from tick_nohz_init() > and ct_cpu_track_user() so that they be called later when an isolated > cpuset partition is being created. The __ro_after_init attribute is > taken away from context_tracking_key as well. > > Also add a new ct_cpu_untrack_user() function to reverse the action of > ct_cpu_track_user() in case we need to disable the nohz_full mode of > a CPU. > > With nohz_full enabled, the boot CPU (typically CPU 0) will be the > tick CPU which cannot be shut down easily. So the boot CPU should not > be used in an isolated cpuset partition. > > With runtime modification of nohz_full CPUs, tick_do_timer_cpu can become > TICK_DO_TIMER_NONE. So remove the two TICK_DO_TIMER_NONE WARN_ON_ONCE() > checks in tick-sched.c to avoid unnecessary warnings. in tick-sched.c? Describe the functions which contain that. > static inline void tick_nohz_task_switch(void) > diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c > index 925999de1a28..394e432630a3 100644 > --- a/kernel/context_tracking.c > +++ b/kernel/context_tracking.c > @@ -411,7 +411,7 @@ static __always_inline void ct_kernel_enter(bool user, int offset) { } > #define CREATE_TRACE_POINTS > #include > > -DEFINE_STATIC_KEY_FALSE_RO(context_tracking_key); > +DEFINE_STATIC_KEY_FALSE(context_tracking_key); > EXPORT_SYMBOL_GPL(context_tracking_key); > > static noinstr bool context_tracking_recursion_enter(void) > @@ -674,9 +674,9 @@ void user_exit_callable(void) > } > NOKPROBE_SYMBOL(user_exit_callable); > > -void __init ct_cpu_track_user(int cpu) > +void ct_cpu_track_user(int cpu) > { > - static __initdata bool initialized = false; > + static bool initialized; > > if (cpu == CONTEXT_TRACKING_FORCE_ENABLE) { > static_branch_inc(&context_tracking_key); > @@ -700,6 +700,15 @@ void __init ct_cpu_track_user(int cpu) > initialized = true; > } > > +void ct_cpu_untrack_user(int cpu) > +{ > + if (!per_cpu(context_tracking.active, cpu)) > + return; > + > + per_cpu(context_tracking.active, cpu) = false; > + static_branch_dec(&context_tracking_key); > +} > + Why is this in a patch which makes tick/nohz related changes? This is a preparatory change, so make it that way and do not bury it inside something else. > +/* Get the new set of run-time nohz CPU list & update accordingly */ > +void tick_nohz_full_update_cpus(struct cpumask *cpumask) > +{ > + int cpu; > + > + if (!tick_nohz_full_running) { > + pr_warn_once("Full dynticks cannot be enabled without the nohz_full kernel boot parameter!\n"); That's the result of this enforced enable hackery. Make this work properly. > + return; > + } > + > + /* > + * To properly enable/disable nohz_full dynticks for the affected CPUs, > + * the new nohz_full CPUs have to be copied to tick_nohz_full_mask and > + * ct_cpu_track_user/ct_cpu_untrack_user() will have to be called > + * for those CPUs that have their states changed. Those CPUs should be > + * in an offline state. > + */ > + for_each_cpu_andnot(cpu, cpumask, tick_nohz_full_mask) { > + WARN_ON_ONCE(cpu_online(cpu)); > + ct_cpu_track_user(cpu); > + cpumask_set_cpu(cpu, tick_nohz_full_mask); > + } > + > + for_each_cpu_andnot(cpu, tick_nohz_full_mask, cpumask) { > + WARN_ON_ONCE(cpu_online(cpu)); > + ct_cpu_untrack_user(cpu); > + cpumask_clear_cpu(cpu, tick_nohz_full_mask); > + } > +} So this writes to tick_nohz_full_mask while other CPUs can access it. That's just wrong and I'm not at all interested in the resulting KCSAN warnings. tick_nohz_full_mask needs to become a RCU protected pointer, which is updated once the new mask is established in a separately allocated one. Thanks, tglx