From: Tang Yizhou <yizhou.tang@shopee.com>
In the current implementation, the sync_cookie and last_cookie members of
struct rq_wb are used only by read requests and not by non-throttled write
requests. Based on this, we can optimize wbt_done() by removing one if
condition check for non-throttled write requests.
Signed-off-by: Tang Yizhou <yizhou.tang@shopee.com>
---
block/blk-wbt.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/block/blk-wbt.c b/block/blk-wbt.c
index a50d4cd55f41..30886d44f6cd 100644
--- a/block/blk-wbt.c
+++ b/block/blk-wbt.c
@@ -248,13 +248,14 @@ static void wbt_done(struct rq_qos *rqos, struct request *rq)
struct rq_wb *rwb = RQWB(rqos);
if (!wbt_is_tracked(rq)) {
- if (rwb->sync_cookie == rq) {
- rwb->sync_issue = 0;
- rwb->sync_cookie = NULL;
- }
+ if (wbt_is_read(rq)) {
+ if (rwb->sync_cookie == rq) {
+ rwb->sync_issue = 0;
+ rwb->sync_cookie = NULL;
+ }
- if (wbt_is_read(rq))
wb_timestamp(rwb, &rwb->last_comp);
+ }
} else {
WARN_ON_ONCE(rq == rwb->sync_cookie);
__wbt_done(rqos, wbt_flags(rq));
--
2.25.1
Hi,
在 2025/7/24 16:29, Tang Yizhou 写道:
> From: Tang Yizhou <yizhou.tang@shopee.com>
>
> In the current implementation, the sync_cookie and last_cookie members of
> struct rq_wb are used only by read requests and not by non-throttled write
> requests. Based on this, we can optimize wbt_done() by removing one if
> condition check for non-throttled write requests.
>
> Signed-off-by: Tang Yizhou <yizhou.tang@shopee.com>
> ---
> block/blk-wbt.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
> index a50d4cd55f41..30886d44f6cd 100644
> --- a/block/blk-wbt.c
> +++ b/block/blk-wbt.c
> @@ -248,13 +248,14 @@ static void wbt_done(struct rq_qos *rqos, struct request *rq)
> struct rq_wb *rwb = RQWB(rqos);
>
> if (!wbt_is_tracked(rq)) {
> - if (rwb->sync_cookie == rq) {
> - rwb->sync_issue = 0;
> - rwb->sync_cookie = NULL;
> - }
> + if (wbt_is_read(rq)) {
> + if (rwb->sync_cookie == rq) {
> + rwb->sync_issue = 0;
> + rwb->sync_cookie = NULL;
> + }
>
> - if (wbt_is_read(rq))
> wb_timestamp(rwb, &rwb->last_comp);
> + }
> } else {
> WARN_ON_ONCE(rq == rwb->sync_cookie);
> __wbt_done(rqos, wbt_flags(rq));
At lease this is correct logically.
Reviewed-by: Yu Kuai <yukuai3@huawei.com>
On Thu 24-07-25 16:29:59, Tang Yizhou wrote:
> From: Tang Yizhou <yizhou.tang@shopee.com>
>
> In the current implementation, the sync_cookie and last_cookie members of
> struct rq_wb are used only by read requests and not by non-throttled write
> requests. Based on this, we can optimize wbt_done() by removing one if
> condition check for non-throttled write requests.
>
> Signed-off-by: Tang Yizhou <yizhou.tang@shopee.com>
Nah, I'm undecided if this is actually worth it. But it looks correct and
doesn't make the code harder to follow so I guess feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> block/blk-wbt.c | 11 ++++++-----
> 1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/block/blk-wbt.c b/block/blk-wbt.c
> index a50d4cd55f41..30886d44f6cd 100644
> --- a/block/blk-wbt.c
> +++ b/block/blk-wbt.c
> @@ -248,13 +248,14 @@ static void wbt_done(struct rq_qos *rqos, struct request *rq)
> struct rq_wb *rwb = RQWB(rqos);
>
> if (!wbt_is_tracked(rq)) {
> - if (rwb->sync_cookie == rq) {
> - rwb->sync_issue = 0;
> - rwb->sync_cookie = NULL;
> - }
> + if (wbt_is_read(rq)) {
> + if (rwb->sync_cookie == rq) {
> + rwb->sync_issue = 0;
> + rwb->sync_cookie = NULL;
> + }
>
> - if (wbt_is_read(rq))
> wb_timestamp(rwb, &rwb->last_comp);
> + }
> } else {
> WARN_ON_ONCE(rq == rwb->sync_cookie);
> __wbt_done(rqos, wbt_flags(rq));
> --
> 2.25.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
© 2016 - 2026 Red Hat, Inc.