From nobody Fri Nov 13 17:54:40 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4jR4dr3dhLz710GL for ; Fri, 13 Nov 2026 17:54:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4jR4dr33Vyz4HDZ for ; Fri, 13 Nov 2026 17:54:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794592480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wrWj3eZep3FflqXIMErJeyX7MDhImDrYCQ0FNDRtxAQ=; b=m6hmA25iSrpOdfOPuhvtxrQUkspJt5TAIE2C2eEVAEyoqXPPw8nCRCGp0Fb8Rvv8zkgNzO je6Ma5ZJMgh5VjGj2Aier5KbuX5Wyf1ei175Shs+yHvEWpWghsVMY9VbQhltrMS0SzDya4 8bcKxj7TKo9Hkv4O7reztMkG5PORYgL321rWh3Yf0PphZR5VIZGng6fUx7b2ztsKbtOhEe vE3hLAwsbL0yKGxaXer7sc3kRWTNQsSO8vkwI/OSApf69XJ+VqDVfEa+07QLj5h7QlBjrL g6FKTJrJ449Q+WxXzjxACj8lXGj8z1IO/VjrmQgESehxAIjV61AWyHVJRhL3DQ== ARC-Seal: i=1; a=rsa-sha256; d=freebsd.org; s=dkim; cv=none; t=1794592480; b=gyeD5xGYvagjBpkQ+fpCrF+yCkQMmrt2JnjtC68n92BnY6iiIkIgQ5tboB4h4XZ77K3ss+ AxjNPs0vw/1F35Sig7KpH7OQPnz504YlJvtU+m3k/NYw+BUw4vyYRUB4Ikv1Eastk6yqVd 30ArzjcF++ZzEeVtiSFO/HPtEY8za8oirCcVslifBD46IbWah6uiD3k8o3r9gh8mdxBX4L zTL3Wkpnq1nKLNGxEWkNd3YVr4Ik99BbVBndG5enxAAgugUp5E2+OufFITTlR1vF43Ya2l gAC0pffr7sIyyhv+jCZLfUuULXy2AG68Oat9Wh/Ff5cBuBDAmF29xs8BMHE0AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1794592480; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=wrWj3eZep3FflqXIMErJeyX7MDhImDrYCQ0FNDRtxAQ=; b=pJhd1w0BrAMTl0VxmKcfxFVDbYVXmB1a+9q0R/R2UbhbeJNV3yqDrAS9jQUhT+B4AkqO7R 5xWQ/bW8fUA8mbn/6VUhG+WUQQ8vQ5sfOV4wneCztmoZ0rYseIFDmnoomGXr9I1zjsFklz oV6ZFiaRRGEpLyNtl/9kUBI5o235xN7zlFTKyCHf3nr9RVn7JTr/oAOMoIjHiGxsEz+Gol RCR5YbVQL+cDADvzkm/iop46H4DxewuT6vnrWyRDQoVu8gq3hmrERQwQPbGP0ArUhQYqZa +Ag6nv3FxD1DCAqXe5qfCH98guAnGhzNDAYVFTSBPA8yxOO9o5rgVBXjv9dFhg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4jR4dr2PWVzm90 for ; Fri, 13 Nov 2026 17:54:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 1b014 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Fri, 13 Nov 2026 17:54:40 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Gallatin Subject: git: 67f3eac87e41 - main - callout: optionally spread callouts to all CPUs List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all X-BeenThere: dev-commits-src-all@freebsd.org List-Id: Commit messages for all branches of the src repository List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: gallatin X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 67f3eac87e41339ce7244e5234f142626972ee82 Auto-Submitted: auto-generated Date: Fri, 13 Nov 2026 17:54:40 +0000 Message-Id: <6af74ee0.1b014.5dd56af9@gitrepo.freebsd.org> The branch main has been updated by gallatin: URL: https://cgit.FreeBSD.org/src/commit/?id=67f3eac87e41339ce7244e5234f142626972ee82 commit 67f3eac87e41339ce7244e5234f142626972ee82 Author: Andrew Gallatin AuthorDate: 2026-11-13 17:12:02 +0000 Commit: Andrew Gallatin CommitDate: 2026-11-13 17:54:35 +0000 callout: optionally spread callouts to all CPUs By default, if the caller has not used one of the _on() or _cpucpu() variants of the callout API, the system assigns the callout to CPU0. Having most callouts running on CPU0 can be problematic in terms of the amount of CPU time spent executing callouts can have an unfair impact to CPU0, and a critical callout (like lacp_tick) is certain to land on the same CPU as everything else, so it is more likely to be delayed. This change introduces a change to callout_init* where if kern.callout_spread is non-zero, callouts initialized after SMP startup are distributed among CPUs. This is left as disabled by default, as it may reveal any latent synchronization bugs that were previously hidden, e.g., two callout handlers which were always accidentally serialized against each other before may now run concurrently. It also may cause a slight increase in power consumption for mobile users. Reviewed by: markj, (+ mjg who reviewed the first version and suggested the simpler mechanism used in this commit) Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D61361 --- share/man/man9/callout.9 | 10 ++++++++-- sys/kern/kern_timeout.c | 9 +++++++-- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/share/man/man9/callout.9 b/share/man/man9/callout.9 index d90d896a81e1..fe5f538d0abd 100644 --- a/share/man/man9/callout.9 +++ b/share/man/man9/callout.9 @@ -27,7 +27,7 @@ .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE .\" POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 18, 2026 +.Dd November 13, 2026 .Dt CALLOUT 9 .Os .Sh NAME @@ -455,8 +455,14 @@ functions can be used. The callout subsystem provides a softclock thread for each CPU in the system. Callouts are assigned to a single CPU and are executed by the softclock thread for that CPU. -Initially, +By default, callouts are assigned to CPU 0. +If the +.Va kern.callout_spread +sysctl is set to a non-zero value, +callouts initialized after SMP startup are distributed among CPUs. +This sysctl is also a loader tunable and defaults to zero. +Changing it does not reassign existing callouts. The .Fn callout_reset_on , .Fn callout_reset_sbt_on , diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 05856921df1d..effa20a34ce3 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -110,6 +110,11 @@ static int ncallout; SYSCTL_INT(_kern, OID_AUTO, ncallout, CTLFLAG_RDTUN | CTLFLAG_NOFETCH, &ncallout, 0, "Number of entries in callwheel and size of timeout() preallocation"); +static bool __read_mostly callout_spread; +SYSCTL_BOOL(_kern, OID_AUTO, callout_spread, CTLFLAG_RWTUN, + &callout_spread, 0, + "Distribute initial callout CPU assignments after SMP startup"); + #ifdef RSS static int pin_default_swi = 1; static int pin_pcpu_swi = 1; @@ -1357,7 +1362,7 @@ callout_init(struct callout *c, int mpsafe) c->c_lock = &Giant.lock_object; c->c_iflags = 0; } - c->c_cpu = cc_default_cpu; + c->c_cpu = callout_spread ? curcpu : cc_default_cpu; } void @@ -1377,7 +1382,7 @@ _callout_init_lock(struct callout *c, struct lock_object *lock, int flags) *c = (struct callout ){ .c_lock = lock, .c_iflags = flags, - .c_cpu = cc_default_cpu, + .c_cpu = callout_spread ? curcpu : cc_default_cpu, }; }