lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220224090654.54671-11-jianchao.wan9@gmail.com>
Date:   Thu, 24 Feb 2022 17:06:48 +0800
From:   "Wang Jianchao (Kuaishou)" <jianchao.wan9@...il.com>
To:     Jens Axboe <axboe@...nel.dk>
Cc:     Josef Bacik <jbacik@...com>, Tejun Heo <tj@...nel.org>,
        Bart Van Assche <bvanassche@....org>,
        linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [RFC V5 10/16] blk-wbt: get rid of wbt_enable/disable_default()

wbt_enable_default() is used to open wbt feature by default.
wbt_disable_default() is only employed by bfq which has similar
writeback throttling mechanism. This kind of policy should be
selected by the user instead of being set in kernel. This patch
get rid of the interfaces and let the user configure appropricate
blk-rq-qos policy by themselves.

Signed-off-by: Wang Jianchao (Kuaishou) <jianchao.wan9@...il.com>
---
 block/bfq-iosched.c |  2 --
 block/blk-sysfs.c   |  3 +--
 block/blk-wbt.c     | 60 +--------------------------------------------
 block/blk-wbt.h     | 22 -----------------
 block/elevator.c    |  3 ---
 5 files changed, 2 insertions(+), 88 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 0c612a911696..adbe5ff6c5e8 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -132,7 +132,6 @@
 #include "blk-mq-tag.h"
 #include "blk-mq-sched.h"
 #include "bfq-iosched.h"
-#include "blk-wbt.h"
 
 #define BFQ_BFQQ_FNS(name)						\
 void bfq_mark_bfqq_##name(struct bfq_queue *bfqq)			\
@@ -7158,7 +7157,6 @@ static int bfq_init_queue(struct request_queue *q, struct elevator_type *e)
 	bfq_init_root_group(bfqd->root_group, bfqd);
 	bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group);
 
-	wbt_disable_default(q);
 	return 0;
 
 out_free:
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 1b321edd7ba7..4563283dae07 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -17,8 +17,8 @@
 #include "blk-mq.h"
 #include "blk-mq-debugfs.h"
 #include "blk-mq-sched.h"
-#include "blk-wbt.h"
 #include "blk-throttle.h"
+#include "blk-rq-qos.h"
 
 static ssize_t
 queue_var_show(unsigned long var, char *page)
@@ -810,7 +810,6 @@ int blk_register_queue(struct gendisk *disk)
 	}
 
 	blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
-	wbt_enable_default(q);
 	blk_throtl_register_queue(q);
 
 	/* Now everything is ready and send out KOBJ_ADD uevent */
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index bbec3b394273..6c0a85ddb107 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -86,8 +86,7 @@ enum {
 
 static inline bool rwb_enabled(struct rq_wb *rwb)
 {
-	return rwb && rwb->enable_state != WBT_STATE_OFF_DEFAULT &&
-		      rwb->wb_normal != 0;
+	return rwb && rwb->wb_normal != 0;
 }
 
 static void wb_timestamp(struct rq_wb *rwb, unsigned long *var)
@@ -703,7 +702,6 @@ static ssize_t wbt_lat_store(struct request_queue *q, const char *page,
 	blk_mq_quiesce_queue(q);
 
 	rwb->min_lat_nsec = val;
-	rwb->enable_state = WBT_STATE_ON_MANUAL;
 	wbt_update_limits(rwb);
 
 	blk_mq_unquiesce_queue(q);
@@ -734,26 +732,6 @@ static void wbt_exit(struct rq_qos *rqos)
 	__wbt_exit(rqos);
 }
 
-/*
- * Disable wbt, if enabled by default.
- */
-void wbt_disable_default(struct request_queue *q)
-{
-	struct rq_qos *rqos = wbt_rq_qos(q);
-	struct rq_wb *rwb;
-
-	if (!rqos)
-		return;
-
-	rwb = RQWB(rqos);
-	if (rwb->enable_state == WBT_STATE_ON_DEFAULT) {
-		blk_stat_deactivate(rwb->cb);
-		rwb->enable_state = WBT_STATE_OFF_DEFAULT;
-	}
-	rq_qos_put(rqos);
-}
-EXPORT_SYMBOL_GPL(wbt_disable_default);
-
 #ifdef CONFIG_BLK_DEBUG_FS
 static int wbt_curr_win_nsec_show(void *data, struct seq_file *m)
 {
@@ -764,15 +742,6 @@ static int wbt_curr_win_nsec_show(void *data, struct seq_file *m)
 	return 0;
 }
 
-static int wbt_enabled_show(void *data, struct seq_file *m)
-{
-	struct rq_qos *rqos = data;
-	struct rq_wb *rwb = RQWB(rqos);
-
-	seq_printf(m, "%d\n", rwb->enable_state);
-	return 0;
-}
-
 static int wbt_id_show(void *data, struct seq_file *m)
 {
 	struct rq_qos *rqos = data;
@@ -831,7 +800,6 @@ static int wbt_background_show(void *data, struct seq_file *m)
 
 static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] = {
 	{"curr_win_nsec", 0400, wbt_curr_win_nsec_show},
-	{"enabled", 0400, wbt_enabled_show},
 	{"id", 0400, wbt_id_show},
 	{"inflight", 0400, wbt_inflight_show},
 	{"min_lat_nsec", 0400, wbt_min_lat_nsec_show},
@@ -862,7 +830,6 @@ static int wbt_init(struct request_queue *q)
 
 	rwb->last_comp = rwb->last_issue = jiffies;
 	rwb->win_nsec = RWB_WINDOW_NSEC;
-	rwb->enable_state = WBT_STATE_ON_DEFAULT;
 	rwb->wc = 1;
 	rwb->rq_depth.default_depth = RWB_DEF_DEPTH;
 
@@ -900,31 +867,6 @@ static struct rq_qos_ops wbt_rqos_ops = {
 #endif
 };
 
-/*
- * Enable wbt if defaults are configured that way
- */
-void wbt_enable_default(struct request_queue *q)
-{
-	struct rq_qos *rqos = wbt_rq_qos(q);
-
-	/* Throttling already enabled? */
-	if (rqos) {
-		if (RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
-			RQWB(rqos)->enable_state = WBT_STATE_ON_DEFAULT;
-
-		rq_qos_put(rqos);
-		return;
-	}
-
-	/* Queue not registered? Maybe shutting down... */
-	if (!blk_queue_registered(q))
-		return;
-
-	if (queue_is_mq(q) && IS_ENABLED(CONFIG_BLK_WBT_MQ))
-		wbt_init(q);
-}
-EXPORT_SYMBOL_GPL(wbt_enable_default);
-
 static __init int wbt_mod_init(void)
 {
 	return rq_qos_register(&wbt_rqos_ops);
diff --git a/block/blk-wbt.h b/block/blk-wbt.h
index b9ed3f373b5a..fe26f78390bd 100644
--- a/block/blk-wbt.h
+++ b/block/blk-wbt.h
@@ -27,16 +27,6 @@ enum {
 	WBT_NUM_RWQ,
 };
 
-/*
- * Enable states. Either off, or on by default (done at init time),
- * or on through manual setup in sysfs.
- */
-enum {
-	WBT_STATE_ON_DEFAULT	= 1,
-	WBT_STATE_ON_MANUAL	= 2,
-	WBT_STATE_OFF_DEFAULT
-};
-
 struct rq_wb {
 	/*
 	 * Settings that govern how we throttle
@@ -44,8 +34,6 @@ struct rq_wb {
 	unsigned int wb_background;		/* background writeback */
 	unsigned int wb_normal;			/* normal writeback */
 
-	short enable_state;			/* WBT_STATE_* */
-
 	/*
 	 * Number of consecutive periods where we don't have enough
 	 * information to make a firm scale up/down decision.
@@ -85,12 +73,8 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)
 	return ret;
 }
 
-
 #ifdef CONFIG_BLK_WBT
 
-void wbt_disable_default(struct request_queue *);
-void wbt_enable_default(struct request_queue *);
-
 void wbt_set_write_cache(struct request_queue *, bool);
 
 #else
@@ -98,12 +82,6 @@ void wbt_set_write_cache(struct request_queue *, bool);
 static inline void wbt_track(struct request *rq, enum wbt_flags flags)
 {
 }
-static inline void wbt_disable_default(struct request_queue *q)
-{
-}
-static inline void wbt_enable_default(struct request_queue *q)
-{
-}
 static inline void wbt_set_write_cache(struct request_queue *q, bool wc)
 {
 }
diff --git a/block/elevator.c b/block/elevator.c
index ec98aed39c4f..0da6fcf08d7b 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -43,7 +43,6 @@
 #include "blk.h"
 #include "blk-mq-sched.h"
 #include "blk-pm.h"
-#include "blk-wbt.h"
 
 static DEFINE_SPINLOCK(elv_list_lock);
 static LIST_HEAD(elv_list);
@@ -525,8 +524,6 @@ void elv_unregister_queue(struct request_queue *q)
 		kobject_del(&e->kobj);
 
 		e->registered = 0;
-		/* Re-enable throttling in case elevator disabled it */
-		wbt_enable_default(q);
 	}
 }
 
-- 
2.17.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ