diff --git a/sys/alpha/include/runq.h b/sys/alpha/include/runq.h index 3fc658afaa22..9f844b69fe5f 100644 --- a/sys/alpha/include/runq.h +++ b/sys/alpha/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word)) +#define RQB_FFS(word) (ffs64(word) - 1) /* * Type of run queue status word. diff --git a/sys/amd64/include/runq.h b/sys/amd64/include/runq.h index 1ea7735631bc..2a21bfa4ca29 100644 --- a/sys/amd64/include/runq.h +++ b/sys/amd64/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs(word)) +#define RQB_FFS(word) (ffs(word) - 1) /* * Type of run queue status word. diff --git a/sys/i386/include/runq.h b/sys/i386/include/runq.h index 1ea7735631bc..2a21bfa4ca29 100644 --- a/sys/i386/include/runq.h +++ b/sys/i386/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs(word)) +#define RQB_FFS(word) (ffs(word) - 1) /* * Type of run queue status word. diff --git a/sys/ia64/include/runq.h b/sys/ia64/include/runq.h index 3fc658afaa22..9f844b69fe5f 100644 --- a/sys/ia64/include/runq.h +++ b/sys/ia64/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word)) +#define RQB_FFS(word) (ffs64(word) - 1) /* * Type of run queue status word. diff --git a/sys/kern/kern_switch.c b/sys/kern/kern_switch.c index 2c6e6f62aa6c..2b531c0dae3d 100644 --- a/sys/kern/kern_switch.c +++ b/sys/kern/kern_switch.c @@ -129,8 +129,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]) - 1) + - (i << RQB_L2BPW); + pri = RQB_FFS(rqb->rqb_bits[i]) + (i << RQB_L2BPW); CTR3(KTR_RUNQ, "runq_findbit: bits=%#x i=%d pri=%d", rqb->rqb_bits[i], i, pri); return (pri); diff --git a/sys/powerpc/include/runq.h b/sys/powerpc/include/runq.h index 1ea7735631bc..2a21bfa4ca29 100644 --- a/sys/powerpc/include/runq.h +++ b/sys/powerpc/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1 << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs(word)) +#define RQB_FFS(word) (ffs(word) - 1) /* * Type of run queue status word. diff --git a/sys/sparc64/include/runq.h b/sys/sparc64/include/runq.h index 3fc658afaa22..9f844b69fe5f 100644 --- a/sys/sparc64/include/runq.h +++ b/sys/sparc64/include/runq.h @@ -36,7 +36,7 @@ #define RQB_BIT(pri) (1UL << ((pri) & (RQB_BPW - 1))) #define RQB_WORD(pri) ((pri) >> RQB_L2BPW) -#define RQB_FFS(word) (ffs64(word)) +#define RQB_FFS(word) (ffs64(word) - 1) /* * Type of run queue status word.