From: Yu Kuai <yukuai3@huawei.com> To: <jack@suse.cz>, <paolo.valente@linaro.org>, <axboe@kernel.dk>, <tj@kernel.org> Cc: <linux-block@vger.kernel.org>, <cgroups@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <yukuai3@huawei.com>, <yi.zhang@huawei.com> Subject: [PATCH -next v2 3/5] bfq, block: record how many queues have pending requests in bfq_group Date: Sat, 16 Apr 2022 17:37:51 +0800 [thread overview] Message-ID: <20220416093753.3054696-4-yukuai3@huawei.com> (raw) In-Reply-To: <20220416093753.3054696-1-yukuai3@huawei.com> Prepare to refactor the counting of 'num_groups_with_pending_reqs'. bfqq will be inserted to weights_tree when new io is inserted to it, and bfqq will be removed from weights_tree when all the requests are completed. Thus use weights_tree insertion and removal to track how many queues have pending requests. Signed-off-by: Yu Kuai <yukuai3@huawei.com> --- block/bfq-cgroup.c | 1 + block/bfq-iosched.c | 17 ++++++++++++++++- block/bfq-iosched.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 420eda2589c0..e8b58b2361a6 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_entities_with_pending_reqs = 0; bfqg->rq_pos_tree = RB_ROOT; } diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index a2977c938c70..994c6b36a5d5 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -889,7 +889,7 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq) if (bfqq->wr_coeff != 1) { bfqq->weight_counter = BFQ_FAKE_WEIGHT_COUNTER; bfqq->ref++; - return; + goto update; } while (*new) { @@ -936,6 +936,14 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq) inc_counter: bfqq->weight_counter->num_active++; bfqq->ref++; + +update: +#ifdef CONFIG_BFQ_GROUP_IOSCHED + if (!entity->in_groups_with_pending_reqs) { + entity->in_groups_with_pending_reqs = true; + bfqq_group(bfqq)->num_entities_with_pending_reqs++; + } +#endif } /* @@ -963,6 +971,13 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bfqq) kfree(bfqq->weight_counter); reset_entity_pointer: +#ifdef CONFIG_BFQ_GROUP_IOSCHED + if (bfqq->entity.in_groups_with_pending_reqs) { + bfqq->entity.in_groups_with_pending_reqs = false; + bfqq_group(bfqq)->num_entities_with_pending_reqs--; + } +#endif + bfqq->weight_counter = NULL; bfq_put_queue(bfqq); } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 072099b0c11a..5e1a0ead2b6a 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -940,6 +940,7 @@ struct bfq_group { struct bfq_entity *my_entity; int active_entities; + int num_entities_with_pending_reqs; struct rb_root rq_pos_tree; -- 2.31.1
WARNING: multiple messages have this Message-ID (diff)
From: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> To: jack-AlSwsSmVLrQ@public.gmane.org, paolo.valente-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org, tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org Cc: linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, yi.zhang-hv44wF8Li93QT0dZR+AlfA@public.gmane.org Subject: [PATCH -next v2 3/5] bfq, block: record how many queues have pending requests in bfq_group Date: Sat, 16 Apr 2022 17:37:51 +0800 [thread overview] Message-ID: <20220416093753.3054696-4-yukuai3@huawei.com> (raw) In-Reply-To: <20220416093753.3054696-1-yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> Prepare to refactor the counting of 'num_groups_with_pending_reqs'. bfqq will be inserted to weights_tree when new io is inserted to it, and bfqq will be removed from weights_tree when all the requests are completed. Thus use weights_tree insertion and removal to track how many queues have pending requests. Signed-off-by: Yu Kuai <yukuai3-hv44wF8Li93QT0dZR+AlfA@public.gmane.org> --- block/bfq-cgroup.c | 1 + block/bfq-iosched.c | 17 ++++++++++++++++- block/bfq-iosched.h | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/block/bfq-cgroup.c b/block/bfq-cgroup.c index 420eda2589c0..e8b58b2361a6 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_entities_with_pending_reqs = 0; bfqg->rq_pos_tree = RB_ROOT; } diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index a2977c938c70..994c6b36a5d5 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -889,7 +889,7 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq) if (bfqq->wr_coeff != 1) { bfqq->weight_counter = BFQ_FAKE_WEIGHT_COUNTER; bfqq->ref++; - return; + goto update; } while (*new) { @@ -936,6 +936,14 @@ void bfq_weights_tree_add(struct bfq_data *bfqd, struct bfq_queue *bfqq) inc_counter: bfqq->weight_counter->num_active++; bfqq->ref++; + +update: +#ifdef CONFIG_BFQ_GROUP_IOSCHED + if (!entity->in_groups_with_pending_reqs) { + entity->in_groups_with_pending_reqs = true; + bfqq_group(bfqq)->num_entities_with_pending_reqs++; + } +#endif } /* @@ -963,6 +971,13 @@ void __bfq_weights_tree_remove(struct bfq_data *bfqd, struct bfq_queue *bfqq) kfree(bfqq->weight_counter); reset_entity_pointer: +#ifdef CONFIG_BFQ_GROUP_IOSCHED + if (bfqq->entity.in_groups_with_pending_reqs) { + bfqq->entity.in_groups_with_pending_reqs = false; + bfqq_group(bfqq)->num_entities_with_pending_reqs--; + } +#endif + bfqq->weight_counter = NULL; bfq_put_queue(bfqq); } diff --git a/block/bfq-iosched.h b/block/bfq-iosched.h index 072099b0c11a..5e1a0ead2b6a 100644 --- a/block/bfq-iosched.h +++ b/block/bfq-iosched.h @@ -940,6 +940,7 @@ struct bfq_group { struct bfq_entity *my_entity; int active_entities; + int num_entities_with_pending_reqs; struct rb_root rq_pos_tree; -- 2.31.1
next prev parent reply other threads:[~2022-04-16 9:23 UTC|newest] Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-16 9:37 [PATCH -next v2 0/5] support concurrent sync io for bfq on a specail occasion Yu Kuai 2022-04-16 9:37 ` Yu Kuai 2022-04-16 9:37 ` [PATCH -next v2 1/5] block, bfq: cleanup bfq_weights_tree add/remove apis Yu Kuai 2022-04-16 9:37 ` Yu Kuai 2022-04-25 9:37 ` Jan Kara 2022-04-25 9:37 ` Jan Kara 2022-04-16 9:37 ` [PATCH -next v2 2/5] block, bfq: add fake weight_counter for weight-raised queue Yu Kuai 2022-04-16 9:37 ` Yu Kuai 2022-04-25 9:48 ` Jan Kara 2022-04-25 9:48 ` Jan Kara 2022-04-25 13:34 ` yukuai (C) 2022-04-25 13:34 ` yukuai (C) 2022-04-25 13:55 ` yukuai (C) 2022-04-25 13:55 ` yukuai (C) 2022-04-25 16:26 ` Jan Kara 2022-04-25 16:26 ` Jan Kara 2022-04-25 16:16 ` Jan Kara 2022-04-25 16:16 ` Jan Kara 2022-04-26 1:49 ` yukuai (C) 2022-04-26 1:49 ` yukuai (C) 2022-04-26 7:40 ` Jan Kara 2022-04-26 8:27 ` yukuai (C) 2022-04-26 8:27 ` yukuai (C) 2022-04-26 9:15 ` Jan Kara 2022-04-26 9:15 ` Jan Kara 2022-04-26 11:27 ` yukuai (C) 2022-04-26 11:27 ` yukuai (C) 2022-04-26 14:04 ` Paolo Valente 2022-04-16 9:37 ` Yu Kuai [this message] 2022-04-16 9:37 ` [PATCH -next v2 3/5] bfq, block: record how many queues have pending requests in bfq_group Yu Kuai 2022-04-16 9:37 ` [PATCH -next v2 4/5] block, bfq: refactor the counting of 'num_groups_with_pending_reqs' Yu Kuai 2022-04-16 9:37 ` Yu Kuai 2022-04-16 9:37 ` [PATCH -next v2 5/5] block, bfq: do not idle if only one cgroup is activated Yu Kuai 2022-04-16 9:37 ` Yu Kuai 2022-04-24 2:44 ` [PATCH -next v2 0/5] support concurrent sync io for bfq on a specail occasion yukuai (C) 2022-04-24 2:44 ` yukuai (C)
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=20220416093753.3054696-4-yukuai3@huawei.com \ --to=yukuai3@huawei.com \ --cc=axboe@kernel.dk \ --cc=cgroups@vger.kernel.org \ --cc=jack@suse.cz \ --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 \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.