Index: sys/sys/_cpuset.h =================================================================== --- sys/sys/_cpuset.h (revision 0) +++ sys/sys/_cpuset.h (revision 0) @@ -0,0 +1,70 @@ +/*- + * Copyright (c) 2008, Jeffrey Roberson + * All rights reserved. + * + * Copyright (c) 2008 Nokia Corporation + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice unmodified, this list of conditions, and the following + * disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#ifndef _SYS__CPUSET_H_ +#define _SYS__CPUSET_H_ + +#include + +/* + * In userland a bigger cpuset structure is preferable in order to cope + * with kernel bumping of MAXCPU and still have a compatible layout. + * Anyway, for userland define a value supporting the current kernel + * CPU_SETSIZE in order to be used by KVM or similar tools. + */ +#ifdef _KERNEL +#define CPU_SETSIZE MAXCPU +#else +#define CPU_KERNSETSIZE MAXCPU +#endif + +/* + * In userland a bigger cpuset structure is preferable in order to cope + * with kernel bumping of MAXCPU and still have a compatible layout. + */ +#define CPU_MAXSIZE (4 * MAXCPU) + +#ifndef CPU_SETSIZE +#define CPU_SETSIZE CPU_MAXSIZE +#endif + +#define _NCPUBITS (sizeof(long) * NBBY) /* bits per mask */ +#define _NCPUWORDS howmany(CPU_SETSIZE, _NCPUBITS) + +#ifndef _KERNEL +#define CPU_OBJKERNSIZE (sizeof(long) * howmany(CPU_KERNSETSIZE, _NCPUBITS)) +#endif + +typedef struct _cpuset { + long __bits[howmany(CPU_SETSIZE, _NCPUBITS)]; +} cpuset_t; + +#endif /* !_SYS__CPUSET_H_ */ Index: gnu/usr.bin/gdb/kgdb/kthr.c =================================================================== --- gnu/usr.bin/gdb/kgdb/kthr.c (revision 221413) +++ gnu/usr.bin/gdb/kgdb/kthr.c (working copy) @@ -28,6 +28,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include #include @@ -48,7 +49,7 @@ static int dumptid; static CORE_ADDR stoppcbs; -static __cpumask_t stopped_cpus; +static cpuset_t stopped_cpus; static struct kthr *first; struct kthr *curkthr; @@ -102,10 +103,9 @@ dumptid = -1; addr = kgdb_lookup("stopped_cpus"); + CPU_ZERO(&stopped_cpus); if (addr != 0) - kvm_read(kvm, addr, &stopped_cpus, sizeof(stopped_cpus)); - else - stopped_cpus = 0; + kvm_read(kvm, addr, &stopped_cpus, CPU_OBJKERNSIZE); stoppcbs = kgdb_lookup("stoppcbs"); @@ -126,8 +126,8 @@ kt->kaddr = addr; if (td.td_tid == dumptid) kt->pcb = dumppcb; - else if (td.td_state == TDS_RUNNING && ((1 << td.td_oncpu) & stopped_cpus) - && stoppcbs != 0) + else if (td.td_state == TDS_RUNNING && stoppcbs != 0 && + CPU_ISSET(td.td_oncpu, &stopped_cpus)) kt->pcb = (uintptr_t) stoppcbs + sizeof(struct pcb) * td.td_oncpu; else kt->pcb = (uintptr_t)td.td_pcb; Index: lib/libmemstat/memstat_uma.c =================================================================== --- lib/libmemstat/memstat_uma.c (revision 221413) +++ lib/libmemstat/memstat_uma.c (working copy) @@ -27,6 +27,7 @@ */ #include +#include #include #define LIBMEMSTAT /* Cause vm_page.h not to include opt_vmpage.h */ @@ -104,7 +105,7 @@ return (-1); } - if (maxcpus > MEMSTAT_MAXCPU) { + if (maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; return (-1); } @@ -168,7 +169,7 @@ return (-1); } - if (ushp->ush_maxcpus > MEMSTAT_MAXCPU) { + if (ushp->ush_maxcpus > MAXCPU) { list->mtl_error = MEMSTAT_ERROR_TOOMANYCPUS; free(buffer); return (-1); @@ -313,7 +314,7 @@ struct uma_keg *kzp, kz; int hint_dontsearch, i, mp_maxid, ret; char name[MEMTYPE_MAXNAME]; - __cpumask_t all_cpus; + cpuset_t all_cpus; kvm_t *kvm; kvm = (kvm_t *)kvm_handle; @@ -337,7 +338,8 @@ list->mtl_error = ret; return (-1); } - ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, sizeof(all_cpus), 0); + CPU_ZERO(&all_cpus); + ret = kread_symbol(kvm, X_ALL_CPUS, &all_cpus, CPU_OBJKERNSIZE, 0); if (ret != 0) { list->mtl_error = ret; return (-1); @@ -407,7 +409,7 @@ if (kz.uk_flags & UMA_ZFLAG_INTERNAL) goto skip_percpu; for (i = 0; i < mp_maxid + 1; i++) { - if ((all_cpus & (1 << i)) == 0) + if (!CPU_ISSET(i, &all_cpus)) continue; ucp = &ucp_array[i]; mtp->mt_numallocs += ucp->uc_allocs;