From: Peng Wang <peng_wang@linux.alibaba.com>
To: Waiman Long <longman@redhat.com>
Cc: Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>,
Ingo Molnar <mingo@kernel.org>, Thomas Gleixner <tglx@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Steven Rostedt <rostedt@goodmis.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>,
Peter Zijlstra <peterz@infradead.org>, Tejun Heo <tj@kernel.org>,
He Rongguang <herongguang@linux.alibaba.com>,
linux-kernel@vger.kernel.org, linux-api@vger.kernel.org,
driver-core@lists.linux.dev, linux-trace-kernel@vger.kernel.org,
cgroups@vger.kernel.org
Subject: Re: [RFC PATCH 2/2] cpu: Add sysfs control of full dynticks policy
Date: Fri, 16 Oct 2026 01:50:40 +0800 [thread overview]
Message-ID: <atEScHbaEEqOtzQw@MacBook-Pro.local> (raw)
In-Reply-To: <5f2b1519-6693-4d5c-afb7-4202a6d48365@redhat.com>
On Thu, Oct 15, 2026 at 12:07:14PM -0400, Waiman Long wrote:
>
> On 10/15/26 8:43 AM, Peng Wang wrote:
> > Expose nohz_full_allowed under /sys/devices/system/cpu/ as the subset of
> > nohz_full CPUs permitted to suppress their non-idle scheduler tick.
> >
> > Writes replace the entire list; reads report policy, not current tick
> > state. Reject invalid input before updating policy. Document asynchronous
> > revocation, offline CPU configuration and persistence across hotplug.
> > The existing nohz_full attribute continues to report membership.
> >
> > Co-developed-by: He Rongguang <herongguang@linux.alibaba.com>
> > Signed-off-by: He Rongguang <herongguang@linux.alibaba.com>
> > Signed-off-by: Peng Wang <peng_wang@linux.alibaba.com>
> > ---
> > .../ABI/testing/sysfs-devices-system-cpu | 40 ++++++++++++++++
> > drivers/base/cpu.c | 46 +++++++++++++++++++
> > 2 files changed, 86 insertions(+)
> >
> > diff --git a/Documentation/ABI/testing/sysfs-devices-system-cpu b/Documentation/ABI/testing/sysfs-devices-system-cpu
> > index 82d10d556cc89..edf3408fd84c8 100644
> > --- a/Documentation/ABI/testing/sysfs-devices-system-cpu
> > +++ b/Documentation/ABI/testing/sysfs-devices-system-cpu
> > @@ -767,6 +767,46 @@ Description: Preferred MTE tag checking mode
> > See also: Documentation/arch/arm64/memory-tagging-extension.rst
> > +What: /sys/devices/system/cpu/nohz_full_allowed
>
> I do have a problem with the name of this sysfs file. nohz_full is more than
> just the tick. The naming may introduce the wrong impression that all
> nohz_full behavior can be controlled. May be a name like "nohz_tick_allowed"
> which is much more specific will be better.
Hi Waiman,
Agreed, nohz_tick_allowed describes the scope more accurately.
If the control remains in sysfs, I'll use that name in the next version.
Thanks,
Peng
>
> Regards,
> Longman
>
> > +Date: October 2026
> > +Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > +Description:
> > + (RW) CPUs permitted to stop the scheduler tick while non-idle.
> > + Available with CONFIG_NO_HZ_FULL. The default is the complete
> > + nohz_full CPU list. Readback reports permission, not the current
> > + tick state: all the usual tick dependencies still apply.
> > +
> > + A write replaces the entire list, using CPU-list syntax (for
> > + example, "1-3,5"). An empty line revokes permission from all
> > + nohz_full CPUs. Invalid input is rejected without changing
> > + policy. A parsed list containing CPUs outside nohz_full fails
> > + with EINVAL. CPU numbers beyond the mask range and numeric
> > + overflows are rejected by the CPU-list parser with ERANGE and
> > + EOVERFLOW, respectively. Input must be shorter than PAGE_SIZE
> > + bytes, otherwise E2BIG is returned. Embedded NULs and newlines
> > + other than a trailing newline are rejected with EINVAL. Valid
> > + writes without an active nohz_full configuration fail with
> > + EOPNOTSUPP.
> > +
> > + Reads fail with EOVERFLOW if the formatted output reaches
> > + PAGE_SIZE - 1 bytes, rather than returning a potentially
> > + truncated CPU list.
> > +
> > + Revoking permission adds a per-CPU tick dependency. Online CPUs
> > + are notified through the existing asynchronous kick mechanism
> > + to restart a stopped non-idle tick. A successful write means
> > + the policy is updated and any needed notification is queued;
> > + it does not wait for tick restart. Changes to multiple CPUs
> > + are not simultaneous. Granting permission only removes this
> > + dependency and does not force the tick to stop.
> > +
> > + Offline CPUs may be configured without sending notifications.
> > + Policy persists across CPU offline/online. Idle tick suppression
> > + is unchanged; the policy applies when a CPU leaves idle.
> > +
> > + This interface does not change nohz_full membership, context
> > + tracking, RCU offloading, or housekeeping configuration.
> > +
> > What: /sys/devices/system/cpu/nohz_full
> > Date: Apr 2015
> > Contact: Linux kernel mailing list <linux-kernel@vger.kernel.org>
> > diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> > index 69e52fed42415..299ce61cef895 100644
> > --- a/drivers/base/cpu.c
> > +++ b/drivers/base/cpu.c
> > @@ -324,6 +324,51 @@ static ssize_t nohz_full_show(struct device *dev,
> > return sysfs_emit(buf, "\n");
> > }
> > static DEVICE_ATTR_RO(nohz_full);
> > +
> > +static ssize_t nohz_full_allowed_show(struct device *dev,
> > + struct device_attribute *attr, char *buf)
> > +{
> > + cpumask_var_t mask;
> > + ssize_t ret;
> > +
> > + if (!alloc_cpumask_var(&mask, GFP_KERNEL))
> > + return -ENOMEM;
> > +
> > + tick_nohz_full_get_allowed(mask);
> > + ret = sysfs_emit(buf, "%*pbl\n", cpumask_pr_args(mask));
> > +
> > + free_cpumask_var(mask);
> > +
> > + /* Never present a truncated CPU list as the complete policy. */
> > + return ret == PAGE_SIZE - 1 ? -EOVERFLOW : ret;
> > +}
> > +
> > +static ssize_t nohz_full_allowed_store(struct device *dev,
> > + struct device_attribute *attr,
> > + const char *buf, size_t count)
> > +{
> > + cpumask_var_t mask;
> > + int ret;
> > +
> > + /* kernfs may truncate an oversized write to PAGE_SIZE. */
> > + if (count >= PAGE_SIZE)
> > + return -E2BIG;
> > + if (memchr(buf, '\0', count) ||
> > + (count > 1 && memchr(buf, '\n', count - 1)))
> > + return -EINVAL;
> > +
> > + if (!alloc_cpumask_var(&mask, GFP_KERNEL))
> > + return -ENOMEM;
> > +
> > + ret = cpulist_parse(buf, mask);
> > + if (!ret)
> > + ret = tick_nohz_full_set_allowed(mask);
> > +
> > + free_cpumask_var(mask);
> > +
> > + return ret ? ret : count;
> > +}
> > +static DEVICE_ATTR_RW(nohz_full_allowed);
> > #endif
> > #ifdef CONFIG_CRASH_HOTPLUG
> > @@ -525,6 +570,7 @@ static struct attribute *cpu_root_attrs[] = {
> > &dev_attr_housekeeping.attr,
> > #ifdef CONFIG_NO_HZ_FULL
> > &dev_attr_nohz_full.attr,
> > + &dev_attr_nohz_full_allowed.attr,
> > #endif
> > #ifdef CONFIG_CRASH_HOTPLUG
> > &dev_attr_crash_hotplug.attr,
>
next prev parent reply other threads:[~2026-10-15 17:50 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 12:43 [RFC PATCH 0/2] tick/nohz: Add runtime control of non-idle tick suppression Peng Wang
2026-10-15 12:43 ` [RFC PATCH 1/2] tick/nohz: Add a policy dependency for full dynticks Peng Wang
2026-10-15 12:43 ` [RFC PATCH 2/2] cpu: Add sysfs control of full dynticks policy Peng Wang
2026-10-15 16:07 ` Waiman Long
2026-10-15 17:50 ` Peng Wang [this message]
2026-10-15 16:00 ` [RFC PATCH 0/2] tick/nohz: Add runtime control of non-idle tick suppression Waiman Long
2026-10-15 17:48 ` Peng Wang
2026-10-15 20:13 ` Waiman Long
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=atEScHbaEEqOtzQw@MacBook-Pro.local \
--to=peng_wang@linux.alibaba.com \
--cc=anna-maria@linutronix.de \
--cc=cgroups@vger.kernel.org \
--cc=dakr@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=frederic@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=herongguang@linux.alibaba.com \
--cc=linux-api@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=longman@redhat.com \
--cc=mathieu.desnoyers@efficios.com \
--cc=mhiramat@kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tglx@kernel.org \
--cc=tj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.