mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Yu Kuai <yukuai3@huawei.com>
Cc: paolo.valente@linaro.org, jack@suse.cz, tj@kernel.org,
	axboe@kernel.dk, cgroups@vger.kernel.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	yi.zhang@huawei.com
Subject: Re: [PATCH -next v9 2/4] block, bfq: record how many queues have pending requests
Date: Wed, 1 Jun 2022 15:18:06 +0200	[thread overview]
Message-ID: <20220601131806.gs3txjgvhhbn5ign@quack3.lan> (raw)
In-Reply-To: <20220601114340.949953-3-yukuai3@huawei.com>

On Wed 01-06-22 19:43:38, Yu Kuai wrote:
> Prepare to refactor the counting of 'num_groups_with_pending_reqs'.
> 
> Add a counter in bfq_group, update it while tracking if bfqq have pending
> requests and when bfq_bfqq_move() is called.
> 
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza


> ---
>  block/bfq-cgroup.c  | 10 ++++++++++
>  block/bfq-iosched.h |  1 +
>  block/bfq-wf2q.c    | 12 ++++++++++--
>  3 files changed, 21 insertions(+), 2 deletions(-)
> 
> diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c
> index 09574af83566..88c0c320ddf3 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;
>  }
> @@ -646,6 +647,7 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
>  {
>  	struct bfq_entity *entity = &bfqq->entity;
>  	struct bfq_group *old_parent = bfqq_group(bfqq);
> +	bool has_pending_reqs = false;
>  
>  	/*
>  	 * No point to move bfqq to the same group, which can happen when
> @@ -666,6 +668,11 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
>  	 */
>  	bfqq->ref++;
>  
> +	if (entity->in_groups_with_pending_reqs) {
> +		has_pending_reqs = true;
> +		bfq_del_bfqq_in_groups_with_pending_reqs(bfqq);
> +	}
> +
>  	/* If bfqq is empty, then bfq_bfqq_expire also invokes
>  	 * bfq_del_bfqq_busy, thereby removing bfqq and its entity
>  	 * from data structures related to current group. Otherwise we
> @@ -693,6 +700,9 @@ void bfq_bfqq_move(struct bfq_data *bfqd, struct bfq_queue *bfqq,
>  	/* pin down bfqg and its associated blkg  */
>  	bfqg_and_blkg_get(bfqg);
>  
> +	if (has_pending_reqs)
> +		bfq_add_bfqq_in_groups_with_pending_reqs(bfqq);
> +
>  	if (bfq_bfqq_busy(bfqq)) {
>  		if (unlikely(!bfqd->nonrot_with_queueing))
>  			bfq_pos_tree_add_move(bfqd, bfqq);
> diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h
> index 69c7d15417e5..de2446a9b7ab 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 5704a0315cf2..6f36f3fe5cc8 100644
> --- a/block/bfq-wf2q.c
> +++ b/block/bfq-wf2q.c
> @@ -1651,16 +1651,24 @@ 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
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2022-06-01 13:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-01 11:43 [PATCH -next v9 0/4] support concurrent sync io for bfq on a specail occasion Yu Kuai
2022-06-01 11:43 ` [PATCH -next v9 1/4] block, bfq: support to track if bfqq has pending requests Yu Kuai
2022-06-01 11:43 ` [PATCH -next v9 2/4] block, bfq: record how many queues have " Yu Kuai
2022-06-01 13:18   ` Jan Kara [this message]
2022-06-01 11:43 ` [PATCH -next v9 3/4] block, bfq: refactor the counting of 'num_groups_with_pending_reqs' Yu Kuai
2022-06-01 11:43 ` [PATCH -next v9 4/4] block, bfq: do not idle if only one group is activated Yu Kuai
2022-06-08 12:27 ` [PATCH -next v9 0/4] support concurrent sync io for bfq on a specail occasion Yu Kuai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220601131806.gs3txjgvhhbn5ign@quack3.lan \
    --to=jack@suse.cz \
    --cc=axboe@kernel.dk \
    --cc=cgroups@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paolo.valente@linaro.org \
    --cc=tj@kernel.org \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai3@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®