diff options
author | attilio <attilio@FreeBSD.org> | 2011-07-04 12:04:52 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2011-07-04 12:04:52 +0000 |
commit | 364d0522f778b206262efce0932d6cea821879c6 (patch) | |
tree | f85bc4cd83b575a0c42f08d746e644f6dfc0e2ef /lib | |
parent | 95ca970257de274a90a1a867048c5ace5acf532d (diff) | |
download | FreeBSD-src-364d0522f778b206262efce0932d6cea821879c6.zip FreeBSD-src-364d0522f778b206262efce0932d6cea821879c6.tar.gz |
With retirement of cpumask_t and usage of cpuset_t for representing a
mask of CPUs, pc_other_cpus and pc_cpumask become highly inefficient.
Remove them and replace their usage with custom pc_cpuid magic (as,
atm, pc_cpumask can be easilly represented by (1 << pc_cpuid) and
pc_other_cpus by (all_cpus & ~(1 << pc_cpuid))).
This change is not targeted for MFC because of struct pcpu members
removal and dependency by cpumask_t retirement.
MD review by: marcel, marius, alc
Tested by: pluknet
MD testing by: marcel, marius, gonzo, andreast
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libkvm/kvm_pcpu.c | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/lib/libkvm/kvm_pcpu.c b/lib/libkvm/kvm_pcpu.c index bc73baf..d7108b4 100644 --- a/lib/libkvm/kvm_pcpu.c +++ b/lib/libkvm/kvm_pcpu.c @@ -39,13 +39,11 @@ __FBSDID("$FreeBSD$"); #include <sys/param.h> -#include <sys/cpuset.h> #include <sys/pcpu.h> #include <sys/sysctl.h> #include <kvm.h> #include <limits.h> #include <stdlib.h> -#include <unistd.h> #include "kvm_private.h" @@ -120,9 +118,6 @@ _kvm_pcpu_clear(void) void * kvm_getpcpu(kvm_t *kd, int cpu) { - long kcpusetsize; - ssize_t nbytes; - uintptr_t readptr; char *buf; if (kd == NULL) { @@ -130,10 +125,6 @@ kvm_getpcpu(kvm_t *kd, int cpu) return (NULL); } - kcpusetsize = sysconf(_SC_CPUSET_SIZE); - if (kcpusetsize == -1 || (u_long)kcpusetsize > sizeof(cpuset_t)) - return ((void *)-1); - if (maxcpu == 0) if (_kvm_pcpu_init(kd) < 0) return ((void *)-1); @@ -146,26 +137,8 @@ kvm_getpcpu(kvm_t *kd, int cpu) _kvm_err(kd, kd->program, "out of memory"); return ((void *)-1); } - nbytes = sizeof(struct pcpu) - 2 * kcpusetsize; - readptr = (uintptr_t)pcpu_data[cpu]; - if (kvm_read(kd, readptr, buf, nbytes) != nbytes) { - _kvm_err(kd, kd->program, "unable to read per-CPU data"); - free(buf); - return ((void *)-1); - } - - /* Fetch the valid cpuset_t objects. */ - CPU_ZERO((cpuset_t *)(buf + nbytes)); - CPU_ZERO((cpuset_t *)(buf + nbytes + sizeof(cpuset_t))); - readptr += nbytes; - if (kvm_read(kd, readptr, buf + nbytes, kcpusetsize) != kcpusetsize) { - _kvm_err(kd, kd->program, "unable to read per-CPU data"); - free(buf); - return ((void *)-1); - } - readptr += kcpusetsize; - if (kvm_read(kd, readptr, buf + nbytes + sizeof(cpuset_t), - kcpusetsize) != kcpusetsize) { + if (kvm_read(kd, (uintptr_t)pcpu_data[cpu], buf, + sizeof(struct pcpu)) != sizeof(struct pcpu)) { _kvm_err(kd, kd->program, "unable to read per-CPU data"); free(buf); return ((void *)-1); |