linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/3] blk-wbt: simple improvment to enable wbt correctly
@ 2022-09-19  1:49 Yu Kuai
  2022-09-19  1:49 ` [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Yu Kuai @ 2022-09-19  1:49 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, yukuai3, yukuai1, yi.zhang

From: Yu Kuai <yukuai3@huawei.com>

Yu Kuai (3):
  wbt: don't show valid wbt lat in sysfs while wbt is disabled
  block: add a helper to check elevator name
  blk-wbt: don't enable throttling if default elevator is bfq

 block/bfq-iosched.c |  2 +-
 block/blk-sysfs.c   | 11 +++++++++--
 block/blk-wbt.c     | 14 +++++++++++++-
 block/blk-wbt.h     |  6 ++++--
 block/elevator.h    |  5 +++++
 5 files changed, 32 insertions(+), 6 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled
  2022-09-19  1:49 [PATCH -next 0/3] blk-wbt: simple improvment to enable wbt correctly Yu Kuai
@ 2022-09-19  1:49 ` Yu Kuai
  2022-09-19  4:28   ` kernel test robot
  2022-09-19  5:49   ` kernel test robot
  2022-09-19  1:49 ` [PATCH -next 2/3] block: add a helper to check elevator name Yu Kuai
  2022-09-19  1:49 ` [PATCH -next 3/3] blk-wbt: don't enable throttling if default elevator is bfq Yu Kuai
  2 siblings, 2 replies; 7+ messages in thread
From: Yu Kuai @ 2022-09-19  1:49 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, yukuai3, yukuai1, yi.zhang

From: Yu Kuai <yukuai3@huawei.com>

Currently, if wbt is initialized and then disabled by
wbt_disable_default(), sysfs will still show valid wbt_lat_usec, which
will confuse users that wbt is still enabled.

This patch shows wbt_lat_usec as zero and forbid to set it while wbt
is disabled.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reported-and-tested-by: Holger Hoffstätte <holger@applied-asynchrony.com>
---
 block/blk-sysfs.c | 9 ++++++++-
 block/blk-wbt.c   | 7 +++++++
 block/blk-wbt.h   | 1 +
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index e1f009aba6fd..1955bb6a284d 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -467,10 +467,14 @@ static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,
 
 static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
 {
+	u64 lat;
+
 	if (!wbt_rq_qos(q))
 		return -EINVAL;
 
-	return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000));
+	lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
+
+	return sprintf(page, "%llu\n", lat);
 }
 
 static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
@@ -493,6 +497,9 @@ static ssize_t queue_wb_lat_store(struct request_queue *q, const char *page,
 			return ret;
 	}
 
+	if (wbt_disabled(q))
+		return -EINVAL;
+
 	if (val == -1)
 		val = wbt_default_latency_nsec(q);
 	else if (val >= 0)
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index a9982000b667..68851c2c02d2 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -422,6 +422,13 @@ static void wbt_update_limits(struct rq_wb *rwb)
 	rwb_wake_all(rwb);
 }
 
+bool wbt_disabled(struct request_queue *q)
+{
+	struct rq_qos *rqos = wbt_rq_qos(q);
+
+	return !rqos || RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT;
+}
+
 u64 wbt_get_min_lat(struct request_queue *q)
 {
 	struct rq_qos *rqos = wbt_rq_qos(q);
diff --git a/block/blk-wbt.h b/block/blk-wbt.h
index 7e44eccc676d..018d3a14cc30 100644
--- a/block/blk-wbt.h
+++ b/block/blk-wbt.h
@@ -94,6 +94,7 @@ void wbt_enable_default(struct request_queue *);
 
 u64 wbt_get_min_lat(struct request_queue *q);
 void wbt_set_min_lat(struct request_queue *q, u64 val);
+bool wbt_disabled(struct request_queue *);
 
 void wbt_set_write_cache(struct request_queue *, bool);
 
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH -next 2/3] block: add a helper to check elevator name
  2022-09-19  1:49 [PATCH -next 0/3] blk-wbt: simple improvment to enable wbt correctly Yu Kuai
  2022-09-19  1:49 ` [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
@ 2022-09-19  1:49 ` Yu Kuai
  2022-09-19  1:49 ` [PATCH -next 3/3] blk-wbt: don't enable throttling if default elevator is bfq Yu Kuai
  2 siblings, 0 replies; 7+ messages in thread
From: Yu Kuai @ 2022-09-19  1:49 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, yukuai3, yukuai1, yi.zhang

From: Yu Kuai <yukuai3@huawei.com>

The helper will be used in later patch to make sure wbt is not enabled
if default io scheduler is bfq.

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/elevator.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/block/elevator.h b/block/elevator.h
index 3f0593b3bf9d..ccded343cf27 100644
--- a/block/elevator.h
+++ b/block/elevator.h
@@ -104,6 +104,11 @@ struct elevator_queue
 	DECLARE_HASHTABLE(hash, ELV_HASH_BITS);
 };
 
+static inline bool check_elevator_name(struct elevator_queue *elevator,
+				       const char *name)
+{
+	return !strcmp(elevator->type->elevator_name, name);
+}
 /*
  * block elevator interface
  */
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH -next 3/3] blk-wbt: don't enable throttling if default elevator is bfq
  2022-09-19  1:49 [PATCH -next 0/3] blk-wbt: simple improvment to enable wbt correctly Yu Kuai
  2022-09-19  1:49 ` [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
  2022-09-19  1:49 ` [PATCH -next 2/3] block: add a helper to check elevator name Yu Kuai
@ 2022-09-19  1:49 ` Yu Kuai
  2 siblings, 0 replies; 7+ messages in thread
From: Yu Kuai @ 2022-09-19  1:49 UTC (permalink / raw)
  To: axboe; +Cc: linux-block, linux-kernel, yukuai3, yukuai1, yi.zhang

From: Yu Kuai <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 checking elevator name if wbt_enable_default() is
called from blk_register_queue().

Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 block/bfq-iosched.c | 2 +-
 block/blk-sysfs.c   | 2 +-
 block/blk-wbt.c     | 7 ++++++-
 block/blk-wbt.h     | 5 +++--
 4 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
index 7ea427817f7f..f769c90744fd 100644
--- a/block/bfq-iosched.c
+++ b/block/bfq-iosched.c
@@ -7045,7 +7045,7 @@ static void bfq_exit_queue(struct elevator_queue *e)
 #endif
 
 	blk_stat_disable_accounting(bfqd->queue);
-	wbt_enable_default(bfqd->queue);
+	wbt_enable_default(bfqd->queue, false);
 
 	kfree(bfqd);
 }
diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 1955bb6a284d..3e8adb95ff02 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -850,7 +850,7 @@ int blk_register_queue(struct gendisk *disk)
 		goto put_dev;
 
 	blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q);
-	wbt_enable_default(q);
+	wbt_enable_default(q, true);
 	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 68851c2c02d2..54acde63538d 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>
@@ -643,10 +644,14 @@ void wbt_set_write_cache(struct request_queue *q, bool write_cache_on)
 /*
  * Enable wbt if defaults are configured that way
  */
-void wbt_enable_default(struct request_queue *q)
+void wbt_enable_default(struct request_queue *q, bool check_elevator)
 {
 	struct rq_qos *rqos = wbt_rq_qos(q);
 
+	if (check_elevator && q->elevator &&
+	    check_elevator_name(q->elevator, "bfq"))
+		return;
+
 	/* Throttling already enabled? */
 	if (rqos) {
 		if (RQWB(rqos)->enable_state == WBT_STATE_OFF_DEFAULT)
diff --git a/block/blk-wbt.h b/block/blk-wbt.h
index 018d3a14cc30..4252b8077257 100644
--- a/block/blk-wbt.h
+++ b/block/blk-wbt.h
@@ -90,7 +90,7 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb)
 
 int wbt_init(struct request_queue *);
 void wbt_disable_default(struct request_queue *);
-void wbt_enable_default(struct request_queue *);
+void wbt_enable_default(struct request_queue *, bool);
 
 u64 wbt_get_min_lat(struct request_queue *q);
 void wbt_set_min_lat(struct request_queue *q, u64 val);
@@ -109,7 +109,8 @@ static inline int wbt_init(struct request_queue *q)
 static inline void wbt_disable_default(struct request_queue *q)
 {
 }
-static inline void wbt_enable_default(struct request_queue *q)
+static inline void wbt_enable_default(struct request_queue *q,
+				      bool check_elevator)
 {
 }
 static inline void wbt_set_write_cache(struct request_queue *q, bool wc)
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled
  2022-09-19  1:49 ` [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
@ 2022-09-19  4:28   ` kernel test robot
  2022-09-19  6:34     ` Yu Kuai
  2022-09-19  5:49   ` kernel test robot
  1 sibling, 1 reply; 7+ messages in thread
From: kernel test robot @ 2022-09-19  4:28 UTC (permalink / raw)
  To: Yu Kuai, axboe
  Cc: kbuild-all, linux-block, linux-kernel, yukuai3, yukuai1, yi.zhang

Hi Yu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220916]

url:    https://github.com/intel-lab-lkp/linux/commits/Yu-Kuai/blk-wbt-simple-improvment-to-enable-wbt-correctly/20220919-094019
base:    d5538ab91d3a9a237805be6f8c6c272af2987995
config: parisc-randconfig-r021-20220919 (https://download.01.org/0day-ci/archive/20220919/202209191232.Nwt56uMD-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/dd5a7be692b8fc9794f29648d0805a2d65b9c4de
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yu-Kuai/blk-wbt-simple-improvment-to-enable-wbt-correctly/20220919-094019
        git checkout dd5a7be692b8fc9794f29648d0805a2d65b9c4de
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   block/blk-sysfs.c: In function 'queue_wb_lat_show':
>> block/blk-sysfs.c:475:15: error: implicit declaration of function 'wbt_disabled'; did you mean 'irqs_disabled'? [-Werror=implicit-function-declaration]
     475 |         lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
         |               ^~~~~~~~~~~~
         |               irqs_disabled
   cc1: some warnings being treated as errors


vim +475 block/blk-sysfs.c

   467	
   468	static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
   469	{
   470		u64 lat;
   471	
   472		if (!wbt_rq_qos(q))
   473			return -EINVAL;
   474	
 > 475		lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
   476	
   477		return sprintf(page, "%llu\n", lat);
   478	}
   479	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled
  2022-09-19  1:49 ` [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
  2022-09-19  4:28   ` kernel test robot
@ 2022-09-19  5:49   ` kernel test robot
  1 sibling, 0 replies; 7+ messages in thread
From: kernel test robot @ 2022-09-19  5:49 UTC (permalink / raw)
  To: Yu Kuai, axboe
  Cc: llvm, kbuild-all, linux-block, linux-kernel, yukuai3, yukuai1, yi.zhang

Hi Yu,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on next-20220916]

url:    https://github.com/intel-lab-lkp/linux/commits/Yu-Kuai/blk-wbt-simple-improvment-to-enable-wbt-correctly/20220919-094019
base:    d5538ab91d3a9a237805be6f8c6c272af2987995
config: x86_64-randconfig-a001-20220919 (https://download.01.org/0day-ci/archive/20220919/202209191345.OaqfJF8y-lkp@intel.com/config)
compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/intel-lab-lkp/linux/commit/dd5a7be692b8fc9794f29648d0805a2d65b9c4de
        git remote add linux-review https://github.com/intel-lab-lkp/linux
        git fetch --no-tags linux-review Yu-Kuai/blk-wbt-simple-improvment-to-enable-wbt-correctly/20220919-094019
        git checkout dd5a7be692b8fc9794f29648d0805a2d65b9c4de
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> block/blk-sysfs.c:475:8: error: implicit declaration of function 'wbt_disabled' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
                 ^
   block/blk-sysfs.c:500:6: error: implicit declaration of function 'wbt_disabled' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
           if (wbt_disabled(q))
               ^
   2 errors generated.


vim +/wbt_disabled +475 block/blk-sysfs.c

   467	
   468	static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
   469	{
   470		u64 lat;
   471	
   472		if (!wbt_rq_qos(q))
   473			return -EINVAL;
   474	
 > 475		lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
   476	
   477		return sprintf(page, "%llu\n", lat);
   478	}
   479	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled
  2022-09-19  4:28   ` kernel test robot
@ 2022-09-19  6:34     ` Yu Kuai
  0 siblings, 0 replies; 7+ messages in thread
From: Yu Kuai @ 2022-09-19  6:34 UTC (permalink / raw)
  To: kernel test robot, Yu Kuai, axboe
  Cc: kbuild-all, linux-block, linux-kernel, yi.zhang, yukuai (C)

Hi,

在 2022/09/19 12:28, kernel test robot 写道:
> Hi Yu,
> 
> Thank you for the patch! Yet something to improve:
> 
> [auto build test ERROR on next-20220916]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Yu-Kuai/blk-wbt-simple-improvment-to-enable-wbt-correctly/20220919-094019
> base:    d5538ab91d3a9a237805be6f8c6c272af2987995
> config: parisc-randconfig-r021-20220919 (https://download.01.org/0day-ci/archive/20220919/202209191232.Nwt56uMD-lkp@intel.com/config)
> compiler: hppa-linux-gcc (GCC) 12.1.0
> reproduce (this is a W=1 build):
>          wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # https://github.com/intel-lab-lkp/linux/commit/dd5a7be692b8fc9794f29648d0805a2d65b9c4de
>          git remote add linux-review https://github.com/intel-lab-lkp/linux
>          git fetch --no-tags linux-review Yu-Kuai/blk-wbt-simple-improvment-to-enable-wbt-correctly/20220919-094019
>          git checkout dd5a7be692b8fc9794f29648d0805a2d65b9c4de
>          # save the config file
>          mkdir build_dir && cp config build_dir/.config
>          COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=parisc SHELL=/bin/bash
> 
> If you fix the issue, kindly add following tag where applicable
> Reported-by: kernel test robot <lkp@intel.com>
> 
> All errors (new ones prefixed by >>):
> 
>     block/blk-sysfs.c: In function 'queue_wb_lat_show':
>>> block/blk-sysfs.c:475:15: error: implicit declaration of function 'wbt_disabled'; did you mean 'irqs_disabled'? [-Werror=implicit-function-declaration]
>       475 |         lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
>           |               ^~~~~~~~~~~~
>           |               irqs_disabled
>     cc1: some warnings being treated as errors
> 

I forgot to provide a definition while config is disabled, I'll send a
new version to fix this.

Thanks,
Kuai
> 
> vim +475 block/blk-sysfs.c
> 
>     467	
>     468	static ssize_t queue_wb_lat_show(struct request_queue *q, char *page)
>     469	{
>     470		u64 lat;
>     471	
>     472		if (!wbt_rq_qos(q))
>     473			return -EINVAL;
>     474	
>   > 475		lat = wbt_disabled(q) ? 0 : div_u64(wbt_get_min_lat(q), 1000);
>     476	
>     477		return sprintf(page, "%llu\n", lat);
>     478	}
>     479	
> 


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-09-19  6:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19  1:49 [PATCH -next 0/3] blk-wbt: simple improvment to enable wbt correctly Yu Kuai
2022-09-19  1:49 ` [PATCH -next 1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled Yu Kuai
2022-09-19  4:28   ` kernel test robot
2022-09-19  6:34     ` Yu Kuai
2022-09-19  5:49   ` kernel test robot
2022-09-19  1:49 ` [PATCH -next 2/3] block: add a helper to check elevator name Yu Kuai
2022-09-19  1:49 ` [PATCH -next 3/3] blk-wbt: don't enable throttling if default elevator is bfq Yu Kuai

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).