The branch main has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=2fefe2c88b31dc7f173c9424f3eb13d49e98d55a

commit 2fefe2c88b31dc7f173c9424f3eb13d49e98d55a
Author:     Olivier Certner <o...@freebsd.org>
AuthorDate: 2024-02-26 18:12:42 +0000
Commit:     Olivier Certner <o...@freebsd.org>
CommitDate: 2025-06-18 02:07:56 +0000

    runq: Deduce most parameters, remove machine headers
    
    The 'runq' machinery now depends on only two settable parameters,
    RQ_MAX_PRIO, the maximum priority number that can be accepted, the
    minimum being 0, and RQ_PPQ, the number of priorities per queue (to
    reduce the number of queues).
    
    All other parameters are deduced from these ones.  Also, all
    architectures automatically get a runq word that is their natural word.
    
    RQB_FFS() always was 'ffsl() - 1' except for amd64 where it was
    'bsfq()'.  Now that all these finally call compiler builtins, the
    resulting assembly code is the same, so there is no cost to removing
    this special case.
    
    After all these changes, <machine/runq.h> headers have no more purpose,
    so remove them.
    
    While here, fix potentially confusing parameter name for RQB_WORD() and
    RQB_BIT().
    
    While here, include all necessary headers so that <sys/runq.h> can be
    included standalone.
    
    No functional change (intended).
    
    Reviewed by:    kib
    MFC after:      1 month
    Event:          Kitchener-Waterloo Hackathon 202506
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D45387
---
 sys/amd64/include/runq.h   | 46 --------------------------------------
 sys/arm/include/runq.h     | 46 --------------------------------------
 sys/arm64/include/runq.h   | 50 -----------------------------------------
 sys/i386/include/runq.h    | 46 --------------------------------------
 sys/kern/kern_switch.c     |  6 ++---
 sys/kern/sched_ule.c       |  6 ++---
 sys/powerpc/include/runq.h | 55 ----------------------------------------------
 sys/riscv/include/runq.h   | 44 -------------------------------------
 sys/sys/runq.h             | 25 ++++++++++++++++++---
 9 files changed, 27 insertions(+), 297 deletions(-)

diff --git a/sys/amd64/include/runq.h b/sys/amd64/include/runq.h
deleted file mode 100644
index 8d3b55be11a8..000000000000
--- a/sys/amd64/include/runq.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2001 Jake Burkholder <j...@freebsd.org>
- * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef        _MACHINE_RUNQ_H_
-#define        _MACHINE_RUNQ_H_
-
-#define        RQB_LEN         (1)             /* Number of priority status 
words. */
-#define        RQB_L2BPW       (6)             /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#define        RQB_BPW         (1<<RQB_L2BPW)  /* Bits in an rqb_word_t. */
-
-#define        RQB_BIT(pri)    (1ul << ((pri) & (RQB_BPW - 1)))
-#define        RQB_WORD(pri)   ((pri) >> RQB_L2BPW)
-
-#define        RQB_FFS(word)   (bsfq(word))
-
-/*
- * Type of run queue status word.
- */
-typedef        u_int64_t       rqb_word_t;
-
-#endif
diff --git a/sys/arm/include/runq.h b/sys/arm/include/runq.h
deleted file mode 100644
index c461a0702599..000000000000
--- a/sys/arm/include/runq.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2001 Jake Burkholder <j...@freebsd.org>
- * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef        _MACHINE_RUNQ_H_
-#define        _MACHINE_RUNQ_H_
-
-#define        RQB_LEN         (2)             /* Number of priority status 
words. */
-#define        RQB_L2BPW       (5)             /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#define        RQB_BPW         (1<<RQB_L2BPW)  /* Bits in an rqb_word_t. */
-
-#define        RQB_BIT(pri)    (1 << ((pri) & (RQB_BPW - 1)))
-#define        RQB_WORD(pri)   ((pri) >> RQB_L2BPW)
-
-#define        RQB_FFS(word)   (ffs(word) - 1)
-
-/*
- * Type of run queue status word.
- */
-typedef        u_int32_t       rqb_word_t;
-
-#endif
diff --git a/sys/arm64/include/runq.h b/sys/arm64/include/runq.h
deleted file mode 100644
index 5076bd9169df..000000000000
--- a/sys/arm64/include/runq.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*-
- * Copyright (c) 2001 Jake Burkholder <j...@freebsd.org>
- * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifdef __arm__
-#include <arm/runq.h>
-#else /* !__arm__ */
-
-#ifndef        _MACHINE_RUNQ_H_
-#define        _MACHINE_RUNQ_H_
-
-#define        RQB_LEN         (1)             /* Number of priority status 
words. */
-#define        RQB_L2BPW       (6)             /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#define        RQB_BPW         (1<<RQB_L2BPW)  /* Bits in an rqb_word_t. */
-
-#define        RQB_BIT(pri)    (1ul << ((pri) & (RQB_BPW - 1)))
-#define        RQB_WORD(pri)   ((pri) >> RQB_L2BPW)
-
-#define        RQB_FFS(word)   (ffsl(word) - 1)
-
-/*
- * Type of run queue status word.
- */
-typedef        unsigned long   rqb_word_t;
-
-#endif
-
-#endif /* !__arm__ */
diff --git a/sys/i386/include/runq.h b/sys/i386/include/runq.h
deleted file mode 100644
index c461a0702599..000000000000
--- a/sys/i386/include/runq.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2001 Jake Burkholder <j...@freebsd.org>
- * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef        _MACHINE_RUNQ_H_
-#define        _MACHINE_RUNQ_H_
-
-#define        RQB_LEN         (2)             /* Number of priority status 
words. */
-#define        RQB_L2BPW       (5)             /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#define        RQB_BPW         (1<<RQB_L2BPW)  /* Bits in an rqb_word_t. */
-
-#define        RQB_BIT(pri)    (1 << ((pri) & (RQB_BPW - 1)))
-#define        RQB_WORD(pri)   ((pri) >> RQB_L2BPW)
-
-#define        RQB_FFS(word)   (ffs(word) - 1)
-
-/*
- * Type of run queue status word.
- */
-typedef        u_int32_t       rqb_word_t;
-
-#endif
diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c
index 191d58edf4c4..610566bcfacf 100644
--- a/sys/kern/kern_switch.c
+++ b/sys/kern/kern_switch.c
@@ -57,8 +57,6 @@
 #endif
 #endif
 
-CTASSERT((RQB_BPW * RQB_LEN) == RQ_NQS);
-
 /*
  * kern.sched.preemption allows user space to determine if preemption support
  * is compiled in or not.  It is not currently a boot or runtime flag that
@@ -297,7 +295,7 @@ runq_findbit(struct runq *rq)
        rqb = &rq->rq_status;
        for (i = 0; i < RQB_LEN; i++)
                if (rqb->rqb_bits[i]) {
-                       pri = RQB_FFS(rqb->rqb_bits[i]) + (i << RQB_L2BPW);
+                       pri = RQB_FFS(rqb->rqb_bits[i]) + i * RQB_BPW;
                        CTR3(KTR_RUNQ, "runq_findbit: bits=%#x i=%d pri=%d",
                            rqb->rqb_bits[i], i, pri);
                        return (pri);
@@ -323,7 +321,7 @@ again:
                mask = rqb->rqb_bits[i] & mask;
                if (mask == 0)
                        continue;
-               pri = RQB_FFS(mask) + (i << RQB_L2BPW);
+               pri = RQB_FFS(mask) + i * RQB_BPW;
                CTR3(KTR_RUNQ, "runq_findbit_from: bits=%#x i=%d pri=%d",
                    mask, i, pri);
                return (pri);
diff --git a/sys/kern/sched_ule.c b/sys/kern/sched_ule.c
index b29a37aa1026..d91f20d06667 100644
--- a/sys/kern/sched_ule.c
+++ b/sys/kern/sched_ule.c
@@ -397,7 +397,7 @@ runq_print(struct runq *rq)
                    i, rq->rq_status.rqb_bits[i]);
                for (j = 0; j < RQB_BPW; j++)
                        if (rq->rq_status.rqb_bits[i] & (1ul << j)) {
-                               pri = j + (i << RQB_L2BPW);
+                               pri = j + i * RQB_BPW;
                                rqh = &rq->rq_queues[pri];
                                TAILQ_FOREACH(td, rqh, td_runq) {
                                        printf("\t\t\ttd %p(%s) priority %d 
rqindex %d pri %d\n",
@@ -1203,7 +1203,7 @@ again:
                for (; bit < RQB_BPW; bit++) {
                        if ((rqb->rqb_bits[i] & (1ul << bit)) == 0)
                                continue;
-                       rqh = &rq->rq_queues[bit + (i << RQB_L2BPW)];
+                       rqh = &rq->rq_queues[bit + i * RQB_BPW];
                        TAILQ_FOREACH(td, rqh, td_runq) {
                                if (first) {
                                        if (THREAD_CAN_MIGRATE(td) &&
@@ -1244,7 +1244,7 @@ runq_steal(struct runq *rq, int cpu)
                for (bit = 0; bit < RQB_BPW; bit++) {
                        if ((rqb->rqb_bits[word] & (1ul << bit)) == 0)
                                continue;
-                       rqh = &rq->rq_queues[bit + (word << RQB_L2BPW)];
+                       rqh = &rq->rq_queues[bit + word * RQB_BPW];
                        TAILQ_FOREACH(td, rqh, td_runq)
                                if (THREAD_CAN_MIGRATE(td) &&
                                    THREAD_CAN_SCHED(td, cpu))
diff --git a/sys/powerpc/include/runq.h b/sys/powerpc/include/runq.h
deleted file mode 100644
index 83ffacde4053..000000000000
--- a/sys/powerpc/include/runq.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2001 Jake Burkholder <j...@freebsd.org>
- * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef        _MACHINE_RUNQ_H_
-#define        _MACHINE_RUNQ_H_
-
-#ifdef __powerpc64__
-#define        RQB_LEN         (1UL)           /* Number of priority status 
words. */
-#define        RQB_L2BPW       (6UL)           /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#else
-#define        RQB_LEN         (2)             /* Number of priority status 
words. */
-#define        RQB_L2BPW       (5)             /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#endif
-#define        RQB_BPW         (1UL<<RQB_L2BPW) /* Bits in an rqb_word_t. */
-
-#define        RQB_BIT(pri)    (1UL << ((pri) & (RQB_BPW - 1)))
-#define        RQB_WORD(pri)   ((pri) >> RQB_L2BPW)
-
-#define        RQB_FFS(word)   (ffsl(word) - 1)
-
-/*
- * Type of run queue status word.
- */
-#ifdef __powerpc64__
-typedef        u_int64_t       rqb_word_t;
-#else
-typedef        u_int32_t       rqb_word_t;
-#endif
-
-#endif
diff --git a/sys/riscv/include/runq.h b/sys/riscv/include/runq.h
deleted file mode 100644
index 3a7de010cd72..000000000000
--- a/sys/riscv/include/runq.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * Copyright (c) 2001 Jake Burkholder <j...@freebsd.org>
- * 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, 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 AND CONTRIBUTORS ``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 OR CONTRIBUTORS 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.
- */
-
-#ifndef        _MACHINE_RUNQ_H_
-#define        _MACHINE_RUNQ_H_
-
-#define        RQB_LEN         (1)             /* Number of priority status 
words. */
-#define        RQB_L2BPW       (6)             /* Log2(sizeof(rqb_word_t) * 
NBBY)). */
-#define        RQB_BPW         (1<<RQB_L2BPW)  /* Bits in an rqb_word_t. */
-
-#define        RQB_BIT(pri)    (1ul << ((pri) & (RQB_BPW - 1)))
-#define        RQB_WORD(pri)   ((pri) >> RQB_L2BPW)
-
-#define        RQB_FFS(word)   (ffsl(word) - 1)
-
-/*
- * Type of run queue status word.
- */
-typedef        unsigned long   rqb_word_t;
-
-#endif
diff --git a/sys/sys/runq.h b/sys/sys/runq.h
index 1a54e83a7db3..d40fee25846e 100644
--- a/sys/sys/runq.h
+++ b/sys/sys/runq.h
@@ -29,7 +29,14 @@
 #ifndef        _RUNQ_H_
 #define        _RUNQ_H_
 
-#include <machine/runq.h>
+#include <sys/_param.h>
+#include <sys/queue.h>
+
+#ifdef _KERNEL
+#include <sys/libkern.h>
+#else
+#include <strings.h>
+#endif
 
 struct thread;
 
@@ -37,8 +44,20 @@ struct thread;
  * Run queue parameters.
  */
 
-#define        RQ_NQS          (64)            /* Number of run queues. */
-#define        RQ_PPQ          (4)             /* Priorities per queue. */
+#define        RQ_MAX_PRIO     (255)   /* Maximum priority (minimum is 0). */
+#define        RQ_PPQ          (4)     /* Priorities per queue. */
+
+/*
+ * Deduced from the above parameters and machine ones.
+ */
+typedef        unsigned long   rqb_word_t;     /* runq's status words type. */
+
+#define        RQ_NQS  (howmany(RQ_MAX_PRIO + 1, RQ_PPQ)) /* Number of run 
queues. */
+#define        RQB_BPW (sizeof(rqb_word_t) * NBBY) /* Bits per runq word. */
+#define        RQB_LEN (howmany(RQ_NQS, RQB_BPW)) /* Words to cover RQ_NQS 
queues. */
+#define        RQB_WORD(idx)   ((idx) / RQB_BPW)
+#define        RQB_BIT(idx)    (1ul << ((idx) % RQB_BPW))
+#define        RQB_FFS(word)   (ffsl((long)(word)) - 1) /* Assumes 
two-complement. */
 
 /*
  * Head of run queues.

Reply via email to