diff mbox series

[-next,v8,2/4] block, bfq: record how many queues have pending requests

Message ID 20220531140858.3324294-3-yukuai3@huawei.com (mailing list archive)
State New, archived
Headers show
Series support concurrent sync io for bfq on a specail occasion | expand

Commit Message

Yu Kuai May 31, 2022, 2:08 p.m. UTC
Prepare to refactor the counting of 'num_groups_with_pending_reqs'.

Add a counter in bfq_group, and update it while tracking if bfqq have
pending requests.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/bfq-cgroup.c  |  1 +
 block/bfq-iosched.h |  1 +
 block/bfq-wf2q.c    | 12 ++++++++++--
 3 files changed, 12 insertions(+), 2 deletions(-)

Comments

Jan Kara June 1, 2022, 8:35 a.m. UTC | #1
On Tue 31-05-22 22:08:56, Yu Kuai wrote:
> Prepare to refactor the counting of 'num_groups_with_pending_reqs'.
> 
> Add a counter in bfq_group, and update it while tracking if bfqq have
> pending requests.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Looks good, except I think that we also need to update the counters
'num_groups_with_pending_reqs' in bfq_move_bfqq()?

								Honza

> ---
>  block/bfq-cgroup.c  |  1 +
>  block/bfq-iosched.h |  1 +
>  block/bfq-wf2q.c    | 12 ++++++++++--
>  3 files changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
> index 09574af83566..0954a258a107 100644
> --- a/block/bfq-cgroup.c
> +++ b/block/bfq-cgroup.c
> @@ -557,6 +557,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
>  				   */
>  	bfqg->bfqd = bfqd;
>  	bfqg->active_entities = 0;
> +	bfqg->num_queues_with_pending_reqs = 0;
>  	bfqg->online = true;
>  	bfqg->rq_pos_tree = RB_ROOT;
>  }
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index 3b9b1a0e7c1c..a5f7c0c1a3b3 100644
> --- a/block/bfq-iosched.h
> +++ b/block/bfq-iosched.h
> @@ -943,6 +943,7 @@ struct bfq_group {
>  	struct bfq_entity *my_entity;
>  
>  	int active_entities;
> +	int num_queues_with_pending_reqs;
>  
>  	struct rb_root rq_pos_tree;
>  
> diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
> index 12d20f26ad69..b533e17e9f0c 100644
> --- a/block/bfq-wf2q.c
> +++ b/block/bfq-wf2q.c
> @@ -1651,16 +1651,24 @@ static void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
>  {
>  	struct bfq_entity *entity = &bfqq->entity;
>  
> -	if (!entity->in_groups_with_pending_reqs)
> +	if (!entity->in_groups_with_pending_reqs) {
>  		entity->in_groups_with_pending_reqs = true;
> +#ifdef CONFIG_BFQ_GROUP_IOSCHED
> +		bfqq_group(bfqq)->num_queues_with_pending_reqs++;
> +#endif
> +	}
>  }
>  
>  void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
>  {
>  	struct bfq_entity *entity = &bfqq->entity;
>  
> -	if (entity->in_groups_with_pending_reqs)
> +	if (entity->in_groups_with_pending_reqs) {
>  		entity->in_groups_with_pending_reqs = false;
> +#ifdef CONFIG_BFQ_GROUP_IOSCHED
> +		bfqq_group(bfqq)->num_queues_with_pending_reqs--;
> +#endif
> +	}
>  }
>  
>  /*
> -- 
> 2.31.1
>
Yu Kuai June 1, 2022, 10:58 a.m. UTC | #2
在 2022/06/01 16:35, Jan Kara 写道:
> On Tue 31-05-22 22:08:56, Yu Kuai wrote:
>> Prepare to refactor the counting of 'num_groups_with_pending_reqs'.
>>
>> Add a counter in bfq_group, and update it while tracking if bfqq have
>> pending requests.
>>
>> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
> 
> Looks good, except I think that we also need to update the counters
> 'num_groups_with_pending_reqs' in bfq_move_bfqq()?
Yes, you're right. I'll do that in next version.

Thanks,
Kuai
> 
> 								Honza
> 
>> ---
>>   block/bfq-cgroup.c  |  1 +
>>   block/bfq-iosched.h |  1 +
>>   block/bfq-wf2q.c    | 12 ++++++++++--
>>   3 files changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
>> index 09574af83566..0954a258a107 100644
>> --- a/block/bfq-cgroup.c
>> +++ b/block/bfq-cgroup.c
>> @@ -557,6 +557,7 @@ static void bfq_pd_init(struct blkg_policy_data *pd)
>>   				   */
>>   	bfqg->bfqd = bfqd;
>>   	bfqg->active_entities = 0;
>> +	bfqg->num_queues_with_pending_reqs = 0;
>>   	bfqg->online = true;
>>   	bfqg->rq_pos_tree = RB_ROOT;
>>   }
>> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
>> index 3b9b1a0e7c1c..a5f7c0c1a3b3 100644
>> --- a/block/bfq-iosched.h
>> +++ b/block/bfq-iosched.h
>> @@ -943,6 +943,7 @@ struct bfq_group {
>>   	struct bfq_entity *my_entity;
>>   
>>   	int active_entities;
>> +	int num_queues_with_pending_reqs;
>>   
>>   	struct rb_root rq_pos_tree;
>>   
>> diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
>> index 12d20f26ad69..b533e17e9f0c 100644
>> --- a/block/bfq-wf2q.c
>> +++ b/block/bfq-wf2q.c
>> @@ -1651,16 +1651,24 @@ static void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
>>   {
>>   	struct bfq_entity *entity = &bfqq->entity;
>>   
>> -	if (!entity->in_groups_with_pending_reqs)
>> +	if (!entity->in_groups_with_pending_reqs) {
>>   		entity->in_groups_with_pending_reqs = true;
>> +#ifdef CONFIG_BFQ_GROUP_IOSCHED
>> +		bfqq_group(bfqq)->num_queues_with_pending_reqs++;
>> +#endif
>> +	}
>>   }
>>   
>>   void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
>>   {
>>   	struct bfq_entity *entity = &bfqq->entity;
>>   
>> -	if (entity->in_groups_with_pending_reqs)
>> +	if (entity->in_groups_with_pending_reqs) {
>>   		entity->in_groups_with_pending_reqs = false;
>> +#ifdef CONFIG_BFQ_GROUP_IOSCHED
>> +		bfqq_group(bfqq)->num_queues_with_pending_reqs--;
>> +#endif
>> +	}
>>   }
>>   
>>   /*
>> -- 
>> 2.31.1
>>
diff mbox series

Patch

diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
index 09574af83566..0954a258a107 100644
--- a/block/bfq-cgroup.c
+++ b/block/bfq-cgroup.c
@@ -557,6 +557,7 @@  static void bfq_pd_init(struct blkg_policy_data *pd)
 				   */
 	bfqg->bfqd = bfqd;
 	bfqg->active_entities = 0;
+	bfqg->num_queues_with_pending_reqs = 0;
 	bfqg->online = true;
 	bfqg->rq_pos_tree = RB_ROOT;
 }
diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
index 3b9b1a0e7c1c..a5f7c0c1a3b3 100644
--- a/block/bfq-iosched.h
+++ b/block/bfq-iosched.h
@@ -943,6 +943,7 @@  struct bfq_group {
 	struct bfq_entity *my_entity;
 
 	int active_entities;
+	int num_queues_with_pending_reqs;
 
 	struct rb_root rq_pos_tree;
 
diff --git a/block/bfq-wf2q.c b/block/bfq-wf2q.c
index 12d20f26ad69..b533e17e9f0c 100644
--- a/block/bfq-wf2q.c
+++ b/block/bfq-wf2q.c
@@ -1651,16 +1651,24 @@  static void bfq_add_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
 {
 	struct bfq_entity *entity = &bfqq->entity;
 
-	if (!entity->in_groups_with_pending_reqs)
+	if (!entity->in_groups_with_pending_reqs) {
 		entity->in_groups_with_pending_reqs = true;
+#ifdef CONFIG_BFQ_GROUP_IOSCHED
+		bfqq_group(bfqq)->num_queues_with_pending_reqs++;
+#endif
+	}
 }
 
 void bfq_del_bfqq_in_groups_with_pending_reqs(struct bfq_queue *bfqq)
 {
 	struct bfq_entity *entity = &bfqq->entity;
 
-	if (entity->in_groups_with_pending_reqs)
+	if (entity->in_groups_with_pending_reqs) {
 		entity->in_groups_with_pending_reqs = false;
+#ifdef CONFIG_BFQ_GROUP_IOSCHED
+		bfqq_group(bfqq)->num_queues_with_pending_reqs--;
+#endif
+	}
 }
 
 /*