- Add a BIT_FFS() macro and use it to replace cpusetffs_obj()
Discussed with: attilio Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
parent
f5c2e46822
commit
17a2737732
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=251703
@ -1150,7 +1150,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_of
|
||||
ipi_all_but_self(vector);
|
||||
} else {
|
||||
ncpu = 0;
|
||||
while ((cpu = cpusetobj_ffs(&mask)) != 0) {
|
||||
while ((cpu = CPU_FFS(&mask)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &mask);
|
||||
CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__,
|
||||
@ -1299,7 +1299,7 @@ ipi_selected(cpuset_t cpus, u_int ipi)
|
||||
if (ipi == IPI_STOP_HARD)
|
||||
CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus);
|
||||
|
||||
while ((cpu = cpusetobj_ffs(&cpus)) != 0) {
|
||||
while ((cpu = CPU_FFS(&cpus)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &cpus);
|
||||
CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi);
|
||||
|
@ -1249,7 +1249,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_of
|
||||
ipi_all_but_self(vector);
|
||||
} else {
|
||||
ncpu = 0;
|
||||
while ((cpu = cpusetobj_ffs(&mask)) != 0) {
|
||||
while ((cpu = CPU_FFS(&mask)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &mask);
|
||||
CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu,
|
||||
@ -1398,7 +1398,7 @@ ipi_selected(cpuset_t cpus, u_int ipi)
|
||||
if (ipi == IPI_STOP_HARD)
|
||||
CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus);
|
||||
|
||||
while ((cpu = cpusetobj_ffs(&cpus)) != 0) {
|
||||
while ((cpu = CPU_FFS(&cpus)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &cpus);
|
||||
CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi);
|
||||
|
@ -1957,7 +1957,7 @@ pmap_lazyfix(pmap_t pmap)
|
||||
spins = 50000000;
|
||||
|
||||
/* Find least significant set bit. */
|
||||
lsb = cpusetobj_ffs(&mask);
|
||||
lsb = CPU_FFS(&mask);
|
||||
MPASS(lsb != 0);
|
||||
lsb--;
|
||||
CPU_SETOF(lsb, &mask);
|
||||
|
@ -1039,7 +1039,7 @@ smp_targeted_tlb_shootdown(cpuset_t mask, u_int vector, vm_offset_t addr1, vm_of
|
||||
ipi_all_but_self(vector);
|
||||
} else {
|
||||
ncpu = 0;
|
||||
while ((cpu = cpusetobj_ffs(&mask)) != 0) {
|
||||
while ((cpu = CPU_FFS(&mask)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &mask);
|
||||
CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu,
|
||||
@ -1132,7 +1132,7 @@ ipi_selected(cpuset_t cpus, u_int ipi)
|
||||
if (ipi == IPI_STOP_HARD)
|
||||
CPU_OR_ATOMIC(&ipi_nmi_pending, &cpus);
|
||||
|
||||
while ((cpu = cpusetobj_ffs(&cpus)) != 0) {
|
||||
while ((cpu = CPU_FFS(&cpus)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &cpus);
|
||||
CTR3(KTR_SMP, "%s: cpu: %d ipi: %x", __func__, cpu, ipi);
|
||||
|
@ -1707,7 +1707,7 @@ pmap_lazyfix(pmap_t pmap)
|
||||
spins = 50000000;
|
||||
|
||||
/* Find least significant set bit. */
|
||||
lsb = cpusetobj_ffs(&mask);
|
||||
lsb = CPU_FFS(&mask);
|
||||
MPASS(lsb != 0);
|
||||
lsb--;
|
||||
CPU_SETOF(lsb, &mask);
|
||||
|
@ -620,26 +620,6 @@ cpuset_setproc(pid_t pid, struct cpuset *set, cpuset_t *mask)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the ffs() of the cpuset.
|
||||
*/
|
||||
int
|
||||
cpusetobj_ffs(const cpuset_t *set)
|
||||
{
|
||||
size_t i;
|
||||
int cbit;
|
||||
|
||||
cbit = 0;
|
||||
for (i = 0; i < _NCPUWORDS; i++) {
|
||||
if (set->__bits[i] != 0) {
|
||||
cbit = ffsl(set->__bits[i]);
|
||||
cbit += i * _NCPUBITS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return (cbit);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return a string representing a valid layout for a cpuset_t object.
|
||||
* It expects an incoming buffer at least sized as CPUSETBUFSIZ.
|
||||
|
@ -208,7 +208,7 @@ cpu_mp_setmaxid(void)
|
||||
platform_cpu_mask(&cpumask);
|
||||
mp_ncpus = 0;
|
||||
last = 1;
|
||||
while ((cpu = cpusetobj_ffs(&cpumask)) != 0) {
|
||||
while ((cpu = CPU_FFS(&cpumask)) != 0) {
|
||||
last = cpu;
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &cpumask);
|
||||
@ -251,7 +251,7 @@ cpu_mp_start(void)
|
||||
platform_cpu_mask(&cpumask);
|
||||
|
||||
while (!CPU_EMPTY(&cpumask)) {
|
||||
cpuid = cpusetobj_ffs(&cpumask) - 1;
|
||||
cpuid = CPU_FFS(&cpumask) - 1;
|
||||
CPU_CLR(cpuid, &cpumask);
|
||||
|
||||
if (cpuid >= MAXCPU) {
|
||||
|
@ -557,7 +557,7 @@ spitfire_ipi_selected(cpuset_t cpus, u_long d0, u_long d1, u_long d2)
|
||||
{
|
||||
u_int cpu;
|
||||
|
||||
while ((cpu = cpusetobj_ffs(&cpus)) != 0) {
|
||||
while ((cpu = CPU_FFS(&cpus)) != 0) {
|
||||
cpu--;
|
||||
CPU_CLR(cpu, &cpus);
|
||||
spitfire_ipi_single(cpu, d0, d1, d2);
|
||||
|
@ -150,4 +150,19 @@
|
||||
(f)->__bits[__i]); \
|
||||
} while (0)
|
||||
|
||||
#define BIT_FFS(_s, p) __extension__ ({ \
|
||||
__size_t __i; \
|
||||
int __bit; \
|
||||
\
|
||||
__bit = 0; \
|
||||
for (__i = 0; __i < __bitset_words((_s)); __i++) { \
|
||||
if ((p)->__bits[__i] != 0) { \
|
||||
__bit = ffsl((p)->__bits[__i]); \
|
||||
__bit += __i * _BITSET_BITS; \
|
||||
break; \
|
||||
} \
|
||||
} \
|
||||
__bit; \
|
||||
})
|
||||
|
||||
#endif /* !_SYS_BITSET_H_ */
|
||||
|
@ -57,6 +57,7 @@
|
||||
#define CPU_SET_ATOMIC(n, p) BIT_SET_ATOMIC(CPU_SETSIZE, n, p)
|
||||
#define CPU_OR_ATOMIC(d, s) BIT_OR_ATOMIC(CPU_SETSIZE, d, s)
|
||||
#define CPU_COPY_STORE_REL(f, t) BIT_COPY_STORE_REL(CPU_SETSIZE, f, t)
|
||||
#define CPU_FFS(p) BIT_FFS(CPU_SETSIZE, p)
|
||||
|
||||
/*
|
||||
* Valid cpulevel_t values.
|
||||
@ -118,7 +119,6 @@ void cpuset_rel(struct cpuset *);
|
||||
int cpuset_setthread(lwpid_t id, cpuset_t *);
|
||||
int cpuset_create_root(struct prison *, struct cpuset **);
|
||||
int cpuset_setproc_update_set(struct proc *, struct cpuset *);
|
||||
int cpusetobj_ffs(const cpuset_t *);
|
||||
char *cpusetobj_strprint(char *, const cpuset_t *);
|
||||
int cpusetobj_strscan(cpuset_t *, const char *);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user