Commit 202bc942 authored by Damien Le Moal's avatar Damien Le Moal Committed by Jens Axboe

block: Introduce IOPRIO_NR_LEVELS

The BFQ scheduler and ioprio_check_cap() both assume that the RT
priority class (IOPRIO_CLASS_RT) can have up to 8 different priority
levels, similarly to the BE class (IOPRIO_CLASS_iBE). This is
controlled using the IOPRIO_BE_NR macro , which is badly named as the
number of levels also applies to the RT class.

Introduce the class independent IOPRIO_NR_LEVELS macro, defined to 8,
to make things clear. Keep the old IOPRIO_BE_NR macro definition as an
alias for IOPRIO_NR_LEVELS.
Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
Link: https://lore.kernel.org/r/20210811033702.368488-6-damien.lemoal@wdc.comSigned-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent ba05200f
...@@ -2508,7 +2508,7 @@ void bfq_end_wr_async_queues(struct bfq_data *bfqd, ...@@ -2508,7 +2508,7 @@ void bfq_end_wr_async_queues(struct bfq_data *bfqd,
int i, j; int i, j;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
for (j = 0; j < IOPRIO_BE_NR; j++) for (j = 0; j < IOPRIO_NR_LEVELS; j++)
if (bfqg->async_bfqq[i][j]) if (bfqg->async_bfqq[i][j])
bfq_bfqq_end_wr(bfqg->async_bfqq[i][j]); bfq_bfqq_end_wr(bfqg->async_bfqq[i][j]);
if (bfqg->async_idle_bfqq) if (bfqg->async_idle_bfqq)
...@@ -5293,10 +5293,10 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic) ...@@ -5293,10 +5293,10 @@ bfq_set_next_ioprio_data(struct bfq_queue *bfqq, struct bfq_io_cq *bic)
break; break;
} }
if (bfqq->new_ioprio >= IOPRIO_BE_NR) { if (bfqq->new_ioprio >= IOPRIO_NR_LEVELS) {
pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n", pr_crit("bfq_set_next_ioprio_data: new_ioprio %d\n",
bfqq->new_ioprio); bfqq->new_ioprio);
bfqq->new_ioprio = IOPRIO_BE_NR - 1; bfqq->new_ioprio = IOPRIO_NR_LEVELS - 1;
} }
bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio); bfqq->entity.new_weight = bfq_ioprio_to_weight(bfqq->new_ioprio);
...@@ -6825,7 +6825,7 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg) ...@@ -6825,7 +6825,7 @@ void bfq_put_async_queues(struct bfq_data *bfqd, struct bfq_group *bfqg)
int i, j; int i, j;
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
for (j = 0; j < IOPRIO_BE_NR; j++) for (j = 0; j < IOPRIO_NR_LEVELS; j++)
__bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j]); __bfq_put_async_bfqq(bfqd, &bfqg->async_bfqq[i][j]);
__bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq); __bfq_put_async_bfqq(bfqd, &bfqg->async_idle_bfqq);
......
...@@ -931,7 +931,7 @@ struct bfq_group { ...@@ -931,7 +931,7 @@ struct bfq_group {
void *bfqd; void *bfqd;
struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; struct bfq_queue *async_bfqq[2][IOPRIO_NR_LEVELS];
struct bfq_queue *async_idle_bfqq; struct bfq_queue *async_idle_bfqq;
struct bfq_entity *my_entity; struct bfq_entity *my_entity;
...@@ -948,7 +948,7 @@ struct bfq_group { ...@@ -948,7 +948,7 @@ struct bfq_group {
struct bfq_entity entity; struct bfq_entity entity;
struct bfq_sched_data sched_data; struct bfq_sched_data sched_data;
struct bfq_queue *async_bfqq[2][IOPRIO_BE_NR]; struct bfq_queue *async_bfqq[2][IOPRIO_NR_LEVELS];
struct bfq_queue *async_idle_bfqq; struct bfq_queue *async_idle_bfqq;
struct rb_root rq_pos_tree; struct rb_root rq_pos_tree;
......
...@@ -505,7 +505,7 @@ static void bfq_active_insert(struct bfq_service_tree *st, ...@@ -505,7 +505,7 @@ static void bfq_active_insert(struct bfq_service_tree *st,
*/ */
unsigned short bfq_ioprio_to_weight(int ioprio) unsigned short bfq_ioprio_to_weight(int ioprio)
{ {
return (IOPRIO_BE_NR - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF; return (IOPRIO_NR_LEVELS - ioprio) * BFQ_WEIGHT_CONVERSION_COEFF;
} }
/** /**
...@@ -514,12 +514,12 @@ unsigned short bfq_ioprio_to_weight(int ioprio) ...@@ -514,12 +514,12 @@ unsigned short bfq_ioprio_to_weight(int ioprio)
* *
* To preserve as much as possible the old only-ioprio user interface, * To preserve as much as possible the old only-ioprio user interface,
* 0 is used as an escape ioprio value for weights (numerically) equal or * 0 is used as an escape ioprio value for weights (numerically) equal or
* larger than IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF. * larger than IOPRIO_NR_LEVELS * BFQ_WEIGHT_CONVERSION_COEFF.
*/ */
static unsigned short bfq_weight_to_ioprio(int weight) static unsigned short bfq_weight_to_ioprio(int weight)
{ {
return max_t(int, 0, return max_t(int, 0,
IOPRIO_BE_NR * BFQ_WEIGHT_CONVERSION_COEFF - weight); IOPRIO_NR_LEVELS * BFQ_WEIGHT_CONVERSION_COEFF - weight);
} }
static void bfq_get_entity(struct bfq_entity *entity) static void bfq_get_entity(struct bfq_entity *entity)
......
...@@ -74,9 +74,8 @@ int ioprio_check_cap(int ioprio) ...@@ -74,9 +74,8 @@ int ioprio_check_cap(int ioprio)
fallthrough; fallthrough;
/* rt has prio field too */ /* rt has prio field too */
case IOPRIO_CLASS_BE: case IOPRIO_CLASS_BE:
if (data >= IOPRIO_BE_NR || data < 0) if (data >= IOPRIO_NR_LEVELS || data < 0)
return -EINVAL; return -EINVAL;
break; break;
case IOPRIO_CLASS_IDLE: case IOPRIO_CLASS_IDLE:
break; break;
......
...@@ -378,7 +378,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a, ...@@ -378,7 +378,7 @@ static ssize_t __sbi_store(struct f2fs_attr *a,
ret = kstrtol(name, 10, &data); ret = kstrtol(name, 10, &data);
if (ret) if (ret)
return ret; return ret;
if (data >= IOPRIO_BE_NR || data < 0) if (data >= IOPRIO_NR_LEVELS || data < 0)
return -EINVAL; return -EINVAL;
cprc->ckpt_thread_ioprio = IOPRIO_PRIO_VALUE(class, data); cprc->ckpt_thread_ioprio = IOPRIO_PRIO_VALUE(class, data);
......
...@@ -32,9 +32,10 @@ enum { ...@@ -32,9 +32,10 @@ enum {
}; };
/* /*
* 8 best effort priority levels are supported * The RT and BE priority classes both support up to 8 priority levels.
*/ */
#define IOPRIO_BE_NR (8) #define IOPRIO_NR_LEVELS 8
#define IOPRIO_BE_NR IOPRIO_NR_LEVELS
enum { enum {
IOPRIO_WHO_PROCESS = 1, IOPRIO_WHO_PROCESS = 1,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment