summaryrefslogtreecommitdiffstats
path: root/sys/i386/include
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2016-07-06 14:09:49 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2016-07-06 14:09:49 +0000
commit89d01c24d15d07f044ec78b4f662e6df23069c91 (patch)
tree9241a6d42fe0265d4c88af6ad2c2c916b4f9f0d3 /sys/i386/include
parent6716d2f9c59a7e486e25adf6deb45918be1898ef (diff)
downloadFreeBSD-src-89d01c24d15d07f044ec78b4f662e6df23069c91.zip
FreeBSD-src-89d01c24d15d07f044ec78b4f662e6df23069c91.tar.gz
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)
Diffstat (limited to 'sys/i386/include')
-rw-r--r--sys/i386/include/counter.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/i386/include/counter.h b/sys/i386/include/counter.h
index 01b09bb..86f3ec9 100644
--- a/sys/i386/include/counter.h
+++ b/sys/i386/include/counter.h
@@ -98,13 +98,13 @@ counter_u64_fetch_inline(uint64_t *p)
* critical section as well.
*/
critical_enter();
- for (i = 0; i < mp_ncpus; i++) {
+ CPU_FOREACH(i) {
res += *(uint64_t *)((char *)p +
sizeof(struct pcpu) * i);
}
critical_exit();
} else {
- for (i = 0; i < mp_ncpus; i++)
+ CPU_FOREACH(i)
res += counter_u64_read_one_8b((uint64_t *)((char *)p +
sizeof(struct pcpu) * i));
}
@@ -144,7 +144,7 @@ counter_u64_zero_inline(counter_u64_t c)
if ((cpu_feature & CPUID_CX8) == 0) {
critical_enter();
- for (i = 0; i < mp_ncpus; i++)
+ CPU_FOREACH(i)
*(uint64_t *)((char *)c + sizeof(struct pcpu) * i) = 0;
critical_exit();
} else {
OpenPOWER on IntegriCloud