Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F177446427
D61361.1794419108.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None
D61361.1794419108.diff
View Options
diff --git a/FreeBSD/share/man/man9/callout.9 b/FreeBSD/share/man/man9/callout.9
--- a/FreeBSD/share/man/man9/callout.9
+++ b/FreeBSD/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 9, 2026
.Dt CALLOUT 9
.Os
.Sh NAME
@@ -455,8 +455,15 @@
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_roundrobin
+sysctl is set to a non-zero value,
+callouts initialized after SMP startup are distributed among CPUs
+using round-robin CPU selection.
+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/FreeBSD/sys/kern/kern_timeout.c b/FreeBSD/sys/kern/kern_timeout.c
--- a/FreeBSD/sys/kern/kern_timeout.c
+++ b/FreeBSD/sys/kern/kern_timeout.c
@@ -67,6 +67,7 @@
#include <machine/_inttypes.h>
#endif
+#include <machine/atomic.h>
#ifdef SMP
#include <machine/cpu.h>
#endif
@@ -110,6 +111,12 @@
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_roundrobin;
+SYSCTL_BOOL(_kern, OID_AUTO, callout_roundrobin, CTLFLAG_RWTUN,
+ &callout_roundrobin, 0,
+ "Distribute initial callout CPU assignments after SMP startup");
+static u_int callout_next_cpu;
+
#ifdef RSS
static int pin_default_swi = 1;
static int pin_pcpu_swi = 1;
@@ -1348,6 +1355,21 @@
return (cancelled);
}
+static int
+callout_init_cpu(void)
+{
+ u_int cpu;
+
+ /* Boot callouts must not wait for AP startup. */
+ if (!callout_roundrobin || !smp_started)
+ return (cc_default_cpu);
+
+ cpu = atomic_fetchadd_int(&callout_next_cpu, 1) % (mp_maxid + 1);
+ if (CPU_ABSENT(cpu))
+ cpu = CPU_NEXT(cpu);
+ return (cpu);
+}
+
void
callout_init(struct callout *c, int mpsafe)
{
@@ -1359,7 +1381,7 @@
c->c_lock = &Giant.lock_object;
c->c_iflags = 0;
}
- c->c_cpu = cc_default_cpu;
+ c->c_cpu = callout_init_cpu();
}
void
@@ -1379,7 +1401,7 @@
*c = (struct callout ){
.c_lock = lock,
.c_iflags = flags,
- .c_cpu = cc_default_cpu,
+ .c_cpu = callout_init_cpu(),
};
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Nov 11, 5:45 PM (20 h, 22 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41647445
Default Alt Text
D61361.1794419108.diff (2 KB)
Attached To
Mode
D61361: callout: optionally round-robin default callout CPU, instead of always using 0
Attached
Detach File
Event Timeline