From 78cfa762ebf2afc821e49e41c7bc72cc9044c233 Mon Sep 17 00:00:00 2001 From: Mark Johnston Date: Wed, 26 Apr 2023 10:09:09 -0400 Subject: [PATCH] callout: Move per-CPU callout state into the dpcpu region This eliminates some static bloat in amd64 kernels and reduces the penalty of increasing MAXCPU. The structures now also maintain NUMA affinity. No functional change intended. PR: 269572 Reviewed by: mjg, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39807 --- sys/kern/kern_timeout.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/kern/kern_timeout.c b/sys/kern/kern_timeout.c index 05497f3d46d7..374e8f2b172a 100644 --- a/sys/kern/kern_timeout.c +++ b/sys/kern/kern_timeout.c @@ -195,9 +195,9 @@ struct callout_cpu { #define cc_migration_time(cc, dir) cc->cc_exec_entity[dir].ce_migration_time #define cc_migration_prec(cc, dir) cc->cc_exec_entity[dir].ce_migration_prec -static struct callout_cpu cc_cpu[MAXCPU]; +DPCPU_DEFINE_STATIC(struct callout_cpu, cc_cpu); #define CPUBLOCK MAXCPU -#define CC_CPU(cpu) (&cc_cpu[(cpu)]) +#define CC_CPU(cpu) DPCPU_ID_PTR(cpu, cc_cpu) #define CC_SELF() CC_CPU(PCPU_GET(cpuid)) #else static struct callout_cpu cc_cpu; @@ -321,7 +321,7 @@ callout_cpu_init(struct callout_cpu *cc, int cpu) { int i; - mtx_init(&cc->cc_lock, "callout", NULL, MTX_SPIN); + mtx_init(&cc->cc_lock, "callout", NULL, MTX_SPIN | MTX_NEW); cc->cc_callwheel = malloc_domainset(sizeof(struct callout_list) * callwheelsize, M_CALLOUT, DOMAINSET_PREF(pcpu_find(cpu)->pc_domain), M_WAITOK);