From nobody Thu May 25 22:10:29 2023 X-Original-To: dev-commits-src-main@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 4QS2LF29T1z4Cjq4; Thu, 25 May 2023 22:10:29 +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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4QS2LF1hFnz4Vkl; Thu, 25 May 2023 22:10:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685052629; 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=ogLkSx3z3RfmvLcjTOJn62TNGFh12zbNt8tMbCJOy6I=; b=vFFWBTYmGlSqaBPDyD++82jnUg+zXezTjgXKLRrDmyEcD8gMTK5HEbl62lFOF/SNVl6Y5F WsMSV9QUDuLfqa3eTfV9jnnEpjBA/7UwxkPXRvOVdJ8P4Ea8nKehdekoDbc2/z8DJTUcXK phpAUuIlRaYwhAOLmuyl1UaDQ0K9Cdty+MxepmXGw0tiJ7SDztDAE6+eo2RRMcItFG95b8 l2T634lngcVSC4MpsM0+Xd8KzaKMl2B9D4n6N+siduQH9BtEyUMve65X6kO9lpy7svC8Na V9U0RE1rLcYBhsLD6frLXosTX2R87PkWt7p0iDmQgOIUYQLBVvSvJLJXYanG5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1685052629; 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=ogLkSx3z3RfmvLcjTOJn62TNGFh12zbNt8tMbCJOy6I=; b=PqSrp9ILCBBXq6bkJNULJI28ROG6wSsVeNfK0gQMjUvT+EXG+OZgX9QyJX+INuzoPFG+3w nsz0MDJ0UBKdR0af3OPz36YkppGen9iK6KpxrmUPrXMI//BtBTs5M2pQYipgYf2UDMfyXE 0c1Y8Oj/yk//lTjILsCbj3x4h+KKFI6QbNk6I9bIwnLmd2WfaoadYbXvetp+U18/k2+aVa DkCxPBwlKr2QEOqk47OIEAcxREZ+pB4WH8hDI6ZjOCdfxovQSLHCGmLRguSxlZKhxJM/Ad mQv8Ink1GG4TDkOfdSHEX1m6h+qiKKzTrcoUyfkSJmiFQ8rJMiM4TmwafuSOtA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1685052629; a=rsa-sha256; cv=none; b=aenHGaCtR4jxylxY/ktFp3nQxgkoFryMCGvJcxZGIsTD2tsbtCI+SW8IqUgHOZ3EwVV9XQ vPjLEJU65PXw+CB7HnHqDRWoD1o/CgABWvNBijdD3meRsCNktG2ecAacfu+lf+KM7caxl0 JL2s/LNpn3g52ZHZl3XHHOup7mr/w48vm70dIiwLCjQFDYZu+SQAg5tTCotfxcdWRA/38u Rxunql32bZym4daspsyzcXoX63vnOuK1QCPCGSo8D2508xj00lLHFxnzQd3EJPCw539alX MKdDivPf+KJf+f0FqGbuETDnyQE9oxmF5TpO835ZN6JmIjqvMSLx12fLqHsmng== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4QS2LF0lQWzhnC; Thu, 25 May 2023 22:10:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 34PMATkw032833; Thu, 25 May 2023 22:10:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 34PMATMV032832; Thu, 25 May 2023 22:10:29 GMT (envelope-from git) Date: Thu, 25 May 2023 22:10:29 GMT Message-Id: <202305252210.34PMATMV032832@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 9fb6718d1b18 - main - smp: Dynamically allocate the stoppcbs array List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9fb6718d1b180c341373b25c03dbfc221ddee311 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=9fb6718d1b180c341373b25c03dbfc221ddee311 commit 9fb6718d1b180c341373b25c03dbfc221ddee311 Author: Mark Johnston AuthorDate: 2023-04-25 16:09:24 +0000 Commit: Mark Johnston CommitDate: 2023-05-25 22:09:55 +0000 smp: Dynamically allocate the stoppcbs array This avoids bloating the kernel image when MAXCPU is large. A follow-up patch for kgdb and other kernel debuggers is needed since the stoppcbs symbol is now a pointer. Bump __FreeBSD_version so that debuggers can use osreldate to figure out how to handle stoppcbs. PR: 269572 MFC after: never Reviewed by: mjg, emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39806 --- sys/amd64/include/kdb.h | 2 -- sys/arm/arm/mp_machdep.c | 1 - sys/arm/include/kdb.h | 2 -- sys/arm/include/smp.h | 3 --- sys/arm64/arm64/mp_machdep.c | 2 -- sys/arm64/include/smp.h | 3 --- sys/i386/include/kdb.h | 2 -- sys/kern/subr_kdb.c | 6 +++--- sys/kern/subr_smp.c | 7 +++++++ sys/powerpc/include/kdb.h | 2 -- sys/powerpc/include/smp.h | 2 -- sys/powerpc/powerpc/mp_machdep.c | 1 - sys/riscv/include/kdb.h | 2 -- sys/riscv/include/smp.h | 2 -- sys/riscv/riscv/mp_machdep.c | 2 -- sys/sys/param.h | 2 +- sys/sys/smp.h | 3 +++ sys/x86/include/x86_smp.h | 1 - sys/x86/x86/mp_x86.c | 1 - 19 files changed, 14 insertions(+), 32 deletions(-) diff --git a/sys/amd64/include/kdb.h b/sys/amd64/include/kdb.h index e2a16ccca0eb..6612bfce6361 100644 --- a/sys/amd64/include/kdb.h +++ b/sys/amd64/include/kdb.h @@ -34,8 +34,6 @@ #include #include -#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid] - int kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access); int kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size); diff --git a/sys/arm/arm/mp_machdep.c b/sys/arm/arm/mp_machdep.c index 36a38291dd3a..b823270eb1c9 100644 --- a/sys/arm/arm/mp_machdep.c +++ b/sys/arm/arm/mp_machdep.c @@ -64,7 +64,6 @@ __FBSDID("$FreeBSD$"); /* used to hold the AP's until we are ready to release them */ struct mtx ap_boot_mtx; -struct pcb stoppcbs[MAXCPU]; /* # of Applications processors */ volatile int mp_naps; diff --git a/sys/arm/include/kdb.h b/sys/arm/include/kdb.h index fde37d148fb6..3fed40807761 100644 --- a/sys/arm/include/kdb.h +++ b/sys/arm/include/kdb.h @@ -36,8 +36,6 @@ #include #include -#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid] - extern void kdb_cpu_clear_singlestep(void); extern void kdb_cpu_set_singlestep(void); boolean_t kdb_cpu_pc_is_singlestep(db_addr_t); diff --git a/sys/arm/include/smp.h b/sys/arm/include/smp.h index 4f1545872a4e..fbb769151de6 100644 --- a/sys/arm/include/smp.h +++ b/sys/arm/include/smp.h @@ -29,7 +29,4 @@ void ipi_selected(cpuset_t cpus, u_int ipi); void platform_mp_setmaxid(void); void platform_mp_start_ap(void); -/* global data in mp_machdep.c */ -extern struct pcb stoppcbs[]; - #endif /* !_MACHINE_SMP_H_ */ diff --git a/sys/arm64/arm64/mp_machdep.c b/sys/arm64/arm64/mp_machdep.c index 9a4997358f8a..9dd1182e5721 100644 --- a/sys/arm64/arm64/mp_machdep.c +++ b/sys/arm64/arm64/mp_machdep.c @@ -126,8 +126,6 @@ static void ipi_preempt(void *); static void ipi_rendezvous(void *); static void ipi_stop(void *); -struct pcb stoppcbs[MAXCPU]; - #ifdef FDT static u_int fdt_cpuid; #endif diff --git a/sys/arm64/include/smp.h b/sys/arm64/include/smp.h index 538981a954f0..1404a72f13cc 100644 --- a/sys/arm64/include/smp.h +++ b/sys/arm64/include/smp.h @@ -49,7 +49,4 @@ void ipi_all_but_self(u_int ipi); void ipi_cpu(int cpu, u_int ipi); void ipi_selected(cpuset_t cpus, u_int ipi); -/* global data in mp_machdep.c */ -extern struct pcb stoppcbs[]; - #endif /* !_MACHINE_SMP_H_ */ diff --git a/sys/i386/include/kdb.h b/sys/i386/include/kdb.h index 53fbe6cbe908..47a8ff86fd44 100644 --- a/sys/i386/include/kdb.h +++ b/sys/i386/include/kdb.h @@ -34,8 +34,6 @@ #include #include -#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid] - int kdb_cpu_set_watchpoint(vm_offset_t addr, vm_size_t size, int access); int kdb_cpu_clr_watchpoint(vm_offset_t addr, vm_size_t size); diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c index 79b61f67b1e0..f8b37c2319b0 100644 --- a/sys/kern/subr_kdb.c +++ b/sys/kern/subr_kdb.c @@ -627,18 +627,18 @@ kdb_reenter_silent(void) struct pcb * kdb_thr_ctx(struct thread *thr) { -#if defined(SMP) && defined(KDB_STOPPEDPCB) +#ifdef SMP struct pcpu *pc; #endif if (thr == curthread) return (&kdb_pcb); -#if defined(SMP) && defined(KDB_STOPPEDPCB) +#ifdef SMP STAILQ_FOREACH(pc, &cpuhead, pc_allcpu) { if (pc->pc_curthread == thr && CPU_ISSET(pc->pc_cpuid, &stopped_cpus)) - return (KDB_STOPPEDPCB(pc)); + return (&stoppcbs[pc->pc_cpuid]); } #endif return (thr->td_pcb); diff --git a/sys/kern/subr_smp.c b/sys/kern/subr_smp.c index 00e2396d5774..cdee6fbebb3c 100644 --- a/sys/kern/subr_smp.c +++ b/sys/kern/subr_smp.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include #include "opt_sched.h" @@ -76,6 +77,9 @@ int mp_maxcpus = MAXCPU; volatile int smp_started; u_int mp_maxid; +/* Array of CPU contexts saved during a panic. */ +struct pcb *stoppcbs; + static SYSCTL_NODE(_kern, OID_AUTO, smp, CTLFLAG_RD | CTLFLAG_CAPRD | CTLFLAG_MPSAFE, NULL, "Kernel SMP"); @@ -178,6 +182,9 @@ mp_start(void *dummy) if (mp_ncores < 0) mp_ncores = mp_ncpus; + stoppcbs = mallocarray(mp_maxid + 1, sizeof(struct pcb), M_DEVBUF, + M_WAITOK | M_ZERO); + cpu_mp_announce(); } SYSINIT(cpu_mp, SI_SUB_CPU, SI_ORDER_THIRD, mp_start, NULL); diff --git a/sys/powerpc/include/kdb.h b/sys/powerpc/include/kdb.h index f399b7523143..6594acb77fd1 100644 --- a/sys/powerpc/include/kdb.h +++ b/sys/powerpc/include/kdb.h @@ -40,8 +40,6 @@ void kdb_cpu_clear_singlestep(void); void kdb_cpu_set_singlestep(void); -#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid] - static __inline void kdb_cpu_sync_icache(unsigned char *addr, size_t size) { diff --git a/sys/powerpc/include/smp.h b/sys/powerpc/include/smp.h index 67e9d51f0bc4..6fcff18ffa4b 100644 --- a/sys/powerpc/include/smp.h +++ b/sys/powerpc/include/smp.h @@ -61,8 +61,6 @@ uintptr_t cpudep_ap_bootstrap(void); void cpudep_ap_setup(void); void machdep_ap_bootstrap(void); -extern struct pcb stoppcbs[]; - #endif /* !LOCORE */ #endif /* _KERNEL */ #endif /* !_MACHINE_SMP_H */ diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index df602912b234..59a000e8e24d 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -66,7 +66,6 @@ volatile static int ap_awake; volatile static u_int ap_letgo; volatile static u_quad_t ap_timebase; static struct mtx ap_boot_mtx; -struct pcb stoppcbs[MAXCPU]; void machdep_ap_bootstrap(void) diff --git a/sys/riscv/include/kdb.h b/sys/riscv/include/kdb.h index 0fdff26bb432..24c6145853c3 100644 --- a/sys/riscv/include/kdb.h +++ b/sys/riscv/include/kdb.h @@ -31,8 +31,6 @@ #include -#define KDB_STOPPEDPCB(pc) &stoppcbs[pc->pc_cpuid] - static __inline void kdb_cpu_clear_singlestep(void) { diff --git a/sys/riscv/include/smp.h b/sys/riscv/include/smp.h index a1d588f31567..1760647903cb 100644 --- a/sys/riscv/include/smp.h +++ b/sys/riscv/include/smp.h @@ -52,6 +52,4 @@ void ipi_all_but_self(u_int ipi); void ipi_cpu(int cpu, u_int ipi); void ipi_selected(cpuset_t cpus, u_int ipi); -extern struct pcb stoppcbs[]; - #endif /* !_MACHINE_SMP_H_ */ diff --git a/sys/riscv/riscv/mp_machdep.c b/sys/riscv/riscv/mp_machdep.c index cd75f2dbbb73..018d7c653304 100644 --- a/sys/riscv/riscv/mp_machdep.c +++ b/sys/riscv/riscv/mp_machdep.c @@ -88,8 +88,6 @@ static device_attach_t riscv64_cpu_attach; static int ipi_handler(void *); -struct pcb stoppcbs[MAXCPU]; - extern uint32_t boot_hart; extern cpuset_t all_harts; diff --git a/sys/sys/param.h b/sys/sys/param.h index 25fac3efde1d..5bdc3e2ebee4 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -76,7 +76,7 @@ * cannot include sys/param.h and should only be updated here. */ #undef __FreeBSD_version -#define __FreeBSD_version 1400088 +#define __FreeBSD_version 1400089 /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, diff --git a/sys/sys/smp.h b/sys/sys/smp.h index 4583dc4350c9..7c3ce7f4ff8d 100644 --- a/sys/sys/smp.h +++ b/sys/sys/smp.h @@ -178,6 +178,9 @@ extern int smp_threads_per_core; extern cpuset_t all_cpus; extern cpuset_t cpuset_domain[MAXMEMDOM]; /* CPUs in each NUMA domain. */ +struct pcb; +extern struct pcb *stoppcbs; + /* * Macro allowing us to determine whether a CPU is absent at any given * time, thus permitting us to configure sparse maps of cpuid-dependent diff --git a/sys/x86/include/x86_smp.h b/sys/x86/include/x86_smp.h index 9d8e1c4ebaec..356d8b881962 100644 --- a/sys/x86/include/x86_smp.h +++ b/sys/x86/include/x86_smp.h @@ -30,7 +30,6 @@ extern unsigned int boot_address; /* global data in mp_x86.c */ extern int mp_naps; extern int boot_cpu_id; -extern struct pcb stoppcbs[]; extern int cpu_apic_ids[]; extern int bootAP; extern void *dpcpu; diff --git a/sys/x86/x86/mp_x86.c b/sys/x86/x86/mp_x86.c index 34c54b27eeff..581ec0ac518a 100644 --- a/sys/x86/x86/mp_x86.c +++ b/sys/x86/x86/mp_x86.c @@ -99,7 +99,6 @@ int bootAP; void *bootstacks[MAXCPU]; void *dpcpu; -struct pcb stoppcbs[MAXCPU]; struct susppcb **susppcbs; #ifdef COUNT_IPIS