diff mbox series

[-next,1/3] wbt: don't show valid wbt_lat_usec in sysfs while wbt is disabled

Message ID 20220919014939.175497-2-yukuai1@huaweicloud.com (mailing list archive)
State New, archived
Headers show
Series blk-wbt: simple improvment to enable wbt correctly | expand

Commit Message

Yu Kuai Sept. 19, 2022, 1:49 a.m. UTC
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(-)

Comments

kernel test robot Sept. 19, 2022, 4:28 a.m. UTC | #1
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
kernel test robot Sept. 19, 2022, 5:49 a.m. UTC | #2
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
Yu Kuai Sept. 19, 2022, 6:34 a.m. UTC | #3
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	
>
diff mbox series

Patch

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