diff options
author | bmilekic <bmilekic@FreeBSD.org> | 2001-07-26 18:47:46 +0000 |
---|---|---|
committer | bmilekic <bmilekic@FreeBSD.org> | 2001-07-26 18:47:46 +0000 |
commit | 0caeab3ccdc5926c530383c04c96653559f47400 (patch) | |
tree | c92cd4663cb459d84696efa19cbdcbe5005277c8 /sys | |
parent | d3c6cce7de3c0e2296ad3aaaec504d56bd72ca1b (diff) | |
download | FreeBSD-src-0caeab3ccdc5926c530383c04c96653559f47400.zip FreeBSD-src-0caeab3ccdc5926c530383c04c96653559f47400.tar.gz |
- Do not handle the per-CPU containers in mbuf code as though the cpuids
were indices in a dense array. The cpuids are a sparse set and treat
them as such, setting up containers only for CPUs activated during
mb_init().
- Fix netstat(1) and systat(1) to treat the per-CPU stats area as a sparse
map, in accordance with the above.
This allows us to properly boot with certain CPUs disactivated. However, if
we later decide to re-activate said CPUs, we will barf until we decide to
implement CPU spinon/spinoff callback hooks to allow for said CPUs' per-CPU
containers to get configured on their activation.
Reported by: mjacob
Partially (sys/ diffs) Submitted by: mjacob
Diffstat (limited to 'sys')
-rw-r--r-- | sys/alpha/alpha/mp_machdep.c | 11 | ||||
-rw-r--r-- | sys/amd64/amd64/mp_machdep.c | 9 | ||||
-rw-r--r-- | sys/amd64/amd64/mptable.c | 9 | ||||
-rw-r--r-- | sys/amd64/include/mptable.h | 9 | ||||
-rw-r--r-- | sys/i386/i386/mp_machdep.c | 9 | ||||
-rw-r--r-- | sys/i386/i386/mptable.c | 9 | ||||
-rw-r--r-- | sys/i386/include/mptable.h | 9 | ||||
-rw-r--r-- | sys/ia64/ia64/mp_machdep.c | 1 | ||||
-rw-r--r-- | sys/kern/subr_mbuf.c | 29 | ||||
-rw-r--r-- | sys/powerpc/powerpc/mp_machdep.c | 1 | ||||
-rw-r--r-- | sys/sys/mbuf.h | 1 |
11 files changed, 68 insertions, 29 deletions
diff --git a/sys/alpha/alpha/mp_machdep.c b/sys/alpha/alpha/mp_machdep.c index 74500b8..e042183 100644 --- a/sys/alpha/alpha/mp_machdep.c +++ b/sys/alpha/alpha/mp_machdep.c @@ -301,6 +301,11 @@ cpu_mp_probe(void) /* XXX: Need to check for valid platforms here. */ + boot_cpu_id = PCPU_GET(cpuid); + KASSERT(boot_cpu_id == hwrpb->rpb_primary_cpu_id, + ("cpu_mp_probe() called on non-primary CPU")); + all_cpus = 1 << boot_cpu_id; + mp_ncpus = 1; /* Make sure we have at least one secondary CPU. */ @@ -324,16 +329,12 @@ cpu_mp_probe(void) } void -cpu_mp_start() +cpu_mp_start(void) { int i; mtx_init(&ap_boot_mtx, "ap boot", MTX_SPIN); - boot_cpu_id = PCPU_GET(cpuid); - KASSERT(boot_cpu_id == hwrpb->rpb_primary_cpu_id, - ("mp_start() called on non-primary CPU")); - all_cpus = 1 << boot_cpu_id; for (i = 0; i < hwrpb->rpb_pcs_cnt; i++) { struct pcs *pcsp; diff --git a/sys/amd64/amd64/mp_machdep.c b/sys/amd64/amd64/mp_machdep.c index d5af7b3..eaf508c 100644 --- a/sys/amd64/amd64/mp_machdep.c +++ b/sys/amd64/amd64/mp_machdep.c @@ -406,6 +406,12 @@ found: int cpu_mp_probe(void) { + /* + * Record BSP in CPU map + * This is done here so that MBUF init code works correctly. + */ + all_cpus = 1; + return (mp_capable); } @@ -1929,9 +1935,6 @@ start_all_aps(u_int boot_addr) mpbiosreason = inb(CMOS_DATA); #endif - /* record BSP in CPU map */ - all_cpus = 1; - /* set up temporary P==V mapping for AP boot */ /* XXX this is a hack, we should boot the AP on its own stack/PTD */ kptbase = (uintptr_t)(void *)KPTphys; diff --git a/sys/amd64/amd64/mptable.c b/sys/amd64/amd64/mptable.c index d5af7b3..eaf508c 100644 --- a/sys/amd64/amd64/mptable.c +++ b/sys/amd64/amd64/mptable.c @@ -406,6 +406,12 @@ found: int cpu_mp_probe(void) { + /* + * Record BSP in CPU map + * This is done here so that MBUF init code works correctly. + */ + all_cpus = 1; + return (mp_capable); } @@ -1929,9 +1935,6 @@ start_all_aps(u_int boot_addr) mpbiosreason = inb(CMOS_DATA); #endif - /* record BSP in CPU map */ - all_cpus = 1; - /* set up temporary P==V mapping for AP boot */ /* XXX this is a hack, we should boot the AP on its own stack/PTD */ kptbase = (uintptr_t)(void *)KPTphys; diff --git a/sys/amd64/include/mptable.h b/sys/amd64/include/mptable.h index d5af7b3..eaf508c 100644 --- a/sys/amd64/include/mptable.h +++ b/sys/amd64/include/mptable.h @@ -406,6 +406,12 @@ found: int cpu_mp_probe(void) { + /* + * Record BSP in CPU map + * This is done here so that MBUF init code works correctly. + */ + all_cpus = 1; + return (mp_capable); } @@ -1929,9 +1935,6 @@ start_all_aps(u_int boot_addr) mpbiosreason = inb(CMOS_DATA); #endif - /* record BSP in CPU map */ - all_cpus = 1; - /* set up temporary P==V mapping for AP boot */ /* XXX this is a hack, we should boot the AP on its own stack/PTD */ kptbase = (uintptr_t)(void *)KPTphys; diff --git a/sys/i386/i386/mp_machdep.c b/sys/i386/i386/mp_machdep.c index d5af7b3..eaf508c 100644 --- a/sys/i386/i386/mp_machdep.c +++ b/sys/i386/i386/mp_machdep.c @@ -406,6 +406,12 @@ found: int cpu_mp_probe(void) { + /* + * Record BSP in CPU map + * This is done here so that MBUF init code works correctly. + */ + all_cpus = 1; + return (mp_capable); } @@ -1929,9 +1935,6 @@ start_all_aps(u_int boot_addr) mpbiosreason = inb(CMOS_DATA); #endif - /* record BSP in CPU map */ - all_cpus = 1; - /* set up temporary P==V mapping for AP boot */ /* XXX this is a hack, we should boot the AP on its own stack/PTD */ kptbase = (uintptr_t)(void *)KPTphys; diff --git a/sys/i386/i386/mptable.c b/sys/i386/i386/mptable.c index d5af7b3..eaf508c 100644 --- a/sys/i386/i386/mptable.c +++ b/sys/i386/i386/mptable.c @@ -406,6 +406,12 @@ found: int cpu_mp_probe(void) { + /* + * Record BSP in CPU map + * This is done here so that MBUF init code works correctly. + */ + all_cpus = 1; + return (mp_capable); } @@ -1929,9 +1935,6 @@ start_all_aps(u_int boot_addr) mpbiosreason = inb(CMOS_DATA); #endif - /* record BSP in CPU map */ - all_cpus = 1; - /* set up temporary P==V mapping for AP boot */ /* XXX this is a hack, we should boot the AP on its own stack/PTD */ kptbase = (uintptr_t)(void *)KPTphys; diff --git a/sys/i386/include/mptable.h b/sys/i386/include/mptable.h index d5af7b3..eaf508c 100644 --- a/sys/i386/include/mptable.h +++ b/sys/i386/include/mptable.h @@ -406,6 +406,12 @@ found: int cpu_mp_probe(void) { + /* + * Record BSP in CPU map + * This is done here so that MBUF init code works correctly. + */ + all_cpus = 1; + return (mp_capable); } @@ -1929,9 +1935,6 @@ start_all_aps(u_int boot_addr) mpbiosreason = inb(CMOS_DATA); #endif - /* record BSP in CPU map */ - all_cpus = 1; - /* set up temporary P==V mapping for AP boot */ /* XXX this is a hack, we should boot the AP on its own stack/PTD */ kptbase = (uintptr_t)(void *)KPTphys; diff --git a/sys/ia64/ia64/mp_machdep.c b/sys/ia64/ia64/mp_machdep.c index d97c551..b46819d 100644 --- a/sys/ia64/ia64/mp_machdep.c +++ b/sys/ia64/ia64/mp_machdep.c @@ -71,6 +71,7 @@ SYSCTL_INT(_machdep, OID_AUTO, forward_irq_enabled, CTLFLAG_RW, int cpu_mp_probe() { + all_cpus = 1; /* Needed for MB init code */ return (0); } diff --git a/sys/kern/subr_mbuf.c b/sys/kern/subr_mbuf.c index 97ea586..8be31a0 100644 --- a/sys/kern/subr_mbuf.c +++ b/sys/kern/subr_mbuf.c @@ -48,7 +48,12 @@ /* * Maximum number of PCPU containers. If you know what you're doing you could * explicitly define MBALLOC_NCPU to be exactly the number of CPUs on your - * system during compilation, and thus prevent kernel structure bloats. + * system during compilation, and thus prevent kernel structure bloat. + * + * SMP and non-SMP kernels clearly have a different number of possible cpus, + * but because we cannot assume a dense array of CPUs, we always allocate + * and traverse PCPU containers up to NCPU amount and merely check for + * CPU availability. */ #ifdef MBALLOC_NCPU #define NCPU MBALLOC_NCPU @@ -57,12 +62,18 @@ #endif /* - * SMP and non-SMP kernels clearly have a different number of possible cpus. + * Macros allowing us to determine whether or not a given CPU's container + * should be configured during mb_init(). + * XXX: Eventually we may want to provide hooks for CPU spinon/spinoff that + * will allow us to configure the containers on spinon/spinoff. As it + * stands, booting with CPU x disactivated and activating CPU x only + * after bootup will lead to disaster and CPU x's container will be + * uninitialized. */ #ifdef SMP -#define NCPU_PRESENT mp_ncpus +#define CPU_ABSENT(x) ((all_cpus & (1 << x)) == 0) #else -#define NCPU_PRESENT 1 +#define CPU_ABSENT(x) 0 #endif /* @@ -388,7 +399,10 @@ mb_init(void *dummy) /* * Allocate and initialize PCPU containers. */ - for (i = 0; i < NCPU_PRESENT; i++) { + for (i = 0; i < NCPU; i++) { + if (CPU_ABSENT(i)) + continue; + mb_list_mbuf.ml_cntlst[i] = malloc(sizeof(struct mb_pcpu_list), M_MBUF, M_NOWAIT); mb_list_clust.ml_cntlst[i] = malloc(sizeof(struct mb_pcpu_list), @@ -401,6 +415,7 @@ mb_init(void *dummy) mb_list_mbuf.ml_cntlst[i]->mb_cont.mc_lock = mb_list_clust.ml_cntlst[i]->mb_cont.mc_lock = &mbuf_pcpu[i]; + mb_statpcpu[i].mb_active = 1; mb_list_mbuf.ml_cntlst[i]->mb_cont.mc_numowner = mb_list_clust.ml_cntlst[i]->mb_cont.mc_numowner = i; mb_list_mbuf.ml_cntlst[i]->mb_cont.mc_starved = @@ -626,7 +641,9 @@ mb_alloc_wait(struct mb_lstmngr *mb_list) * Cycle all the PCPU containers. Increment starved counts if found * empty. */ - for (i = 0; i < NCPU_PRESENT; i++) { + for (i = 0; i < NCPU; i++) { + if (CPU_ABSENT(i)) + continue; cnt_lst = MB_GET_PCPU_LIST_NUM(mb_list, i); MB_LOCK_CONT(cnt_lst); diff --git a/sys/powerpc/powerpc/mp_machdep.c b/sys/powerpc/powerpc/mp_machdep.c index a8e5819..5e4c339 100644 --- a/sys/powerpc/powerpc/mp_machdep.c +++ b/sys/powerpc/powerpc/mp_machdep.c @@ -51,6 +51,7 @@ int boot_cpu_id; int cpu_mp_probe(void) { + all_cpus = 1; /* needed for MB init code */ return 0; } diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h index ec496d4..d0eed39 100644 --- a/sys/sys/mbuf.h +++ b/sys/sys/mbuf.h @@ -216,6 +216,7 @@ struct mbpstat { u_long mb_mbpgs; u_long mb_clfree; u_long mb_clpgs; + short mb_active; }; /* |