From: Yu Kuai <yukuai3@huawei.com>
To: <jack@suse.cz>, <paolo.valente@linaro.org>, <axboe@kernel.dk>
Cc: <linux-block@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<yukuai3@huawei.com>, <yukuai1@huaweicloud.com>,
<yi.zhang@huawei.com>
Subject: [PATCH v3 4/5] blk-wbt: don't enable throttling if default elevator is bfq
Date: Thu, 22 Sep 2022 19:35:57 +0800 [thread overview]
Message-ID: <20220922113558.1085314-5-yukuai3@huawei.com> (raw)
In-Reply-To: <20220922113558.1085314-1-yukuai3@huawei.com>
Commit b5dc5d4d1f4f ("block,bfq: Disable writeback throttling") tries to
disable wbt for bfq, it's done by calling wbt_disable_default() in
bfq_init_queue(). However, wbt is still enabled if default elevator is
bfq:
device_add_disk
elevator_init_mq
bfq_init_queue
wbt_disable_default -> done nothing
blk_register_queue
wbt_enable_default -> wbt is enabled
Fix the problem by adding a new flag ELEVATOR_FLAG_DISBALE_WBT, bfq
will set the flag in bfq_init_queue, and following wbt_enable_default()
won't enable wbt while the flag is set.
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
block/bfq-iosched.c | 2 ++
block/blk-wbt.c | 8 +++++++-
block/elevator.h | 3 ++-
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index fec52968fe07..f67ed271baa9 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -7037,6 +7037,7 @@ static void bfq_exit_queue(struct elevator_queue *e)
#ifdef CONFIG_BFQ_GROUP_IOSCHED
blkcg_deactivate_policy(bfqd->queue, &blkcg_policy_bfq);
+ clear_bit(ELEVATOR_FLAG_DISABLE_WBT, &e->flags);
wbt_enable_default(bfqd->queue);
#else
spin_lock_irq(&bfqd->lock);
@@ -7191,6 +7192,7 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
blk_queue_flag_set(QUEUE_FLAG_SQ_SCHED, q);
#ifdef CONFIG_BFQ_GROUP_IOSCHED
+ set_bit(ELEVATOR_FLAG_DISABLE_WBT, &eq->flags);
wbt_disable_default(q);
#endif
blk_stat_enable_accounting(q);
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index 68851c2c02d2..279f8dc1e952 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -27,6 +27,7 @@
#include "blk-wbt.h"
#include "blk-rq-qos.h"
+#include "elevator.h"
#define CREATE_TRACE_POINTS
#include <trace/events/wbt.h>
@@ -645,9 +646,14 @@ void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)
*/
void wbt_enable_default(struct request_queue *q)
{
- struct rq_qos *rqos = wbt_rq_qos(q);
+ struct rq_qos *rqos;
+
+ if (q->elevator &&
+ test_bit(ELEVATOR_FLAG_DISABLE_WBT, &q->elevator->flags))
+ return;
/* Throttling already enabled? */
+ rqos = wbt_rq_qos(q);
if (rqos) {
if (RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
diff --git a/block/elevator.h b/block/elevator.h
index ed574bf3e629..75382471222d 100644
--- a/block/elevator.h
+++ b/block/elevator.h
@@ -104,7 +104,8 @@ struct elevator_queue
DECLARE_HASHTABLE(hash, ELV_HASH_BITS);
};
-#define ELEVATOR_FLAG_REGISTERED 0
+#define ELEVATOR_FLAG_REGISTERED 0
+#define ELEVATOR_FLAG_DISABLE_WBT 1
/*
* block elevator interface
--
2.31.1
next prev parent reply other threads:[~2022-09-22 11:25 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-22 11:35 [PATCH v3 0/5] blk-wbt: simple improvment to enable wbt correctly Yu Kuai
2022-09-22 11:35 ` [PATCH v3 1/5] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
2022-09-26 9:44 ` Jan Kara
2022-09-26 10:25 ` Yu Kuai
2022-09-26 11:47 ` Jan Kara
2022-09-26 13:01 ` Yu Kuai
2022-09-22 11:35 ` [PATCH v3 2/5] elevator: add new field flags in struct elevator_queue Yu Kuai
2022-09-22 11:35 ` [PATCH v3 3/5] block, bfq: don't disable wbt if CONFIG_BFQ_GROUP_IOSCHED is disabled Yu Kuai
2022-09-23 8:56 ` Christoph Hellwig
2022-09-23 9:50 ` Yu Kuai
2022-09-23 10:06 ` Jan Kara
2022-09-23 10:23 ` Yu Kuai
2022-09-23 11:03 ` Jan Kara
2022-09-23 11:32 ` Yu Kuai
2022-09-26 13:00 ` Yu Kuai
2022-09-26 14:22 ` Jan Kara
2022-09-27 1:02 ` Yu Kuai
2022-09-27 16:14 ` Paolo Valente
2022-09-28 3:30 ` Yu Kuai
2022-09-22 11:35 ` Yu Kuai [this message]
2022-09-22 11:35 ` [PATCH v3 5/5] elevator: remove redundant code in elv_unregister_queue() Yu Kuai
2022-09-23 3:37 ` Eric Biggers
2022-09-23 8:53 ` Christoph Hellwig
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=20220922113558.1085314-5-yukuai3@huawei.com \
--to=yukuai3@huawei.com \
--cc=axboe@kernel.dk \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@linaro.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai1@huaweicloud.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;
as well as URLs for NNTP newsgroup(s).