Use mp_maxid in preference to MAXCPU when creating exports of UMA

per-CPU cache statistics.  UMA sizes the cache array based on the
number of CPUs at boot (mp_maxid + 1), and iterating based on MAXCPU
could read off the end of the array (into the next zone).

Reported by:	yongari
MFC after:	1 week
This commit is contained in:
Robert Watson 2005-07-16 11:03:06 +00:00
parent 08ecce74bc
commit ab3a57c04d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=148079

View file

@ -2933,7 +2933,7 @@ sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS)
mtx_unlock(&uma_mtx);
buflen = sizeof(ush) + count * (sizeof(uth) + sizeof(ups) *
MAXCPU) + 1;
(mp_maxid + 1)) + 1;
buffer = malloc(buflen, M_TEMP, M_WAITOK | M_ZERO);
mtx_lock(&uma_mtx);
@ -2955,7 +2955,7 @@ sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS)
*/
bzero(&ush, sizeof(ush));
ush.ush_version = UMA_STREAM_VERSION;
ush.ush_maxcpus = MAXCPU;
ush.ush_maxcpus = (mp_maxid + 1);
ush.ush_count = count;
if (sbuf_bcat(&sbuf, &ush, sizeof(ush)) < 0) {
mtx_unlock(&uma_mtx);
@ -2999,7 +2999,7 @@ sysctl_vm_zone_stats(SYSCTL_HANDLER_ARGS)
* accept the possible race associated with bucket
* exchange during monitoring.
*/
for (i = 0; i < MAXCPU; i++) {
for (i = 0; i < (mp_maxid + 1); i++) {
bzero(&ups, sizeof(ups));
if (kz->uk_flags & UMA_ZFLAG_INTERNAL)
goto skip;