aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/subr_pcpu.c
diff options
context:
space:
mode:
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>2016-07-06 14:09:49 +0000
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>2016-07-06 14:09:49 +0000
commit96c85efb4b85dbc0bfc4968516a627a727ac7ec5 (patch)
tree9241a6d42fe0265d4c88af6ad2c2c916b4f9f0d3 /sys/kern/subr_pcpu.c
parentc5390e5ab4fde7f7440d0aba0319f69838645718 (diff)
downloadsrc-96c85efb4b85dbc0bfc4968516a627a727ac7ec5.tar.gz
src-96c85efb4b85dbc0bfc4968516a627a727ac7ec5.zip
Replace a number of conflations of mp_ncpus and mp_maxid with either
mp_maxid or CPU_FOREACH() as appropriate. This fixes a number of places in the kernel that assumed CPU IDs are dense in [0, mp_ncpus) and would try, for example, to run tasks on CPUs that did not exist or to allocate too few buffers on systems with sparse CPU IDs in which there are holes in the range and mp_maxid > mp_ncpus. Such circumstances generally occur on systems with SMT, but on which SMT is disabled. This patch restores system operation at least on POWER8 systems configured in this way. There are a number of other places in the kernel with potential problems in these situations, but where sparse CPU IDs are not currently known to occur, mostly in the ARM machine-dependent code. These will be fixed in a follow-up commit after the stable/11 branch. PR: kern/210106 Reviewed by: jhb Approved by: re (glebius)
Notes
Notes: svn path=/head/; revision=302372
Diffstat (limited to 'sys/kern/subr_pcpu.c')
-rw-r--r--sys/kern/subr_pcpu.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/kern/subr_pcpu.c b/sys/kern/subr_pcpu.c
index a01f67aba1e6..fbfa1a647471 100644
--- a/sys/kern/subr_pcpu.c
+++ b/sys/kern/subr_pcpu.c
@@ -248,7 +248,7 @@ dpcpu_copy(void *s, int size)
uintptr_t dpcpu;
int i;
- for (i = 0; i < mp_ncpus; ++i) {
+ CPU_FOREACH(i) {
dpcpu = dpcpu_off[i];
if (dpcpu == 0)
continue;
@@ -289,7 +289,7 @@ sysctl_dpcpu_quad(SYSCTL_HANDLER_ARGS)
int i;
count = 0;
- for (i = 0; i < mp_ncpus; ++i) {
+ CPU_FOREACH(i) {
dpcpu = dpcpu_off[i];
if (dpcpu == 0)
continue;
@@ -306,7 +306,7 @@ sysctl_dpcpu_long(SYSCTL_HANDLER_ARGS)
int i;
count = 0;
- for (i = 0; i < mp_ncpus; ++i) {
+ CPU_FOREACH(i) {
dpcpu = dpcpu_off[i];
if (dpcpu == 0)
continue;
@@ -323,7 +323,7 @@ sysctl_dpcpu_int(SYSCTL_HANDLER_ARGS)
int i;
count = 0;
- for (i = 0; i < mp_ncpus; ++i) {
+ CPU_FOREACH(i) {
dpcpu = dpcpu_off[i];
if (dpcpu == 0)
continue;