Linux block layer
 help / color / mirror / Atom feed
From: "Holger Hoffstätte" <holger@applied-asynchrony.com>
To: Yu Kuai <yukuai1@huaweicloud.com>,
	linux-block <linux-block@vger.kernel.org>,
	"zhangyi (F)" <yi.zhang@huawei.com>,
	"yukuai (C)" <yukuai3@huawei.com>
Subject: Re: wbt_lat_usec still set despite wbt disabled by BFQ
Date: Wed, 14 Sep 2022 08:05:41 +0200	[thread overview]
Message-ID: <fb7b8224-70e7-7597-5a84-82293991573a@applied-asynchrony.com> (raw)
In-Reply-To: <4f1ec88a-909c-611f-bfa4-19be9553ebda@huaweicloud.com>

On 2022-09-14 03:35, Yu Kuai wrote:
[snip]
> Thanks for the test, it turns out this way doesn't select bfq as default
> as I expected...
> 
> wbt can show min_lat_nsec despite that wbt can be disabled by
> wbt_disable_default(), I do miss that previously...
> 
> Can you try the following patch again?
> 
> diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
> index a630d657c054..3e8adb95ff02 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 26ee6ca66a93..55d1015ef117 100644
> --- a/block/blk-wbt.c
> +++ b/block/blk-wbt.c
> @@ -423,6 +423,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 1a49b6ac397c..4252b8077257 100644
> --- a/block/blk-wbt.h
> +++ b/block/blk-wbt.h
> @@ -94,6 +94,7 @@ 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);
> +bool wbt_disabled(struct request_queue *);
> 
>   void wbt_set_write_cache(struct request_queue *, bool);
> 

This one works! :)

After boot:

$cat /sys/block/sdc/queue/scheduler
mq-deadline [bfq] none
$cat /sys/block/sdc/queue/wbt_lat_usec
0

Changing schedulers  back and forth - here on a device with different
default - also works:

$cat /sys/block/sda/queue/scheduler
[mq-deadline] bfq none
$cat /sys/block/sda/queue/wbt_lat_usec
2000
$echo bfq > /sys/block/sda/queue/scheduler
$cat /sys/block/sda/queue/wbt_lat_usec
0
$echo deadline > /sys/block/sda/queue/scheduler
$cat /sys/block/sda/queue/wbt_lat_usec
2000

Feel free to add my Reported-by and Tested-by.

cheers!
Holger

  reply	other threads:[~2022-09-14  6:05 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 17:12 wbt_lat_usec still set despite wbt disabled by BFQ Holger Hoffstätte
2022-09-13 13:39 ` Yu Kuai
2022-09-13 14:12   ` Holger Hoffstätte
2022-09-13 14:20     ` Yu Kuai
2022-09-13 16:13       ` Holger Hoffstätte
2022-09-14  1:35         ` Yu Kuai
2022-09-14  6:05           ` Holger Hoffstätte [this message]
2022-09-14  9:23             ` Yu Kuai

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=fb7b8224-70e7-7597-5a84-82293991573a@applied-asynchrony.com \
    --to=holger@applied-asynchrony.com \
    --cc=linux-block@vger.kernel.org \
    --cc=yi.zhang@huawei.com \
    --cc=yukuai1@huaweicloud.com \
    --cc=yukuai3@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: 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