From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4452CC433F5 for ; Thu, 24 Feb 2022 09:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232568AbiBXJJR (ORCPT ); Thu, 24 Feb 2022 04:09:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232498AbiBXJI4 (ORCPT ); Thu, 24 Feb 2022 04:08:56 -0500 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5F8A1A0299; Thu, 24 Feb 2022 01:08:25 -0800 (PST) Received: by mail-pj1-x102b.google.com with SMTP id gi6so1456044pjb.1; Thu, 24 Feb 2022 01:08:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3qV9UcfDlhAtdycG/J2QOpmGOMHKDJw+84ivqZISOMw=; b=IjmAeg2pDMjLBkjhDzcPiuyBVYTe1bHui+bbO2vn62dW7dxWewlKo3AxD3ielKGiui LwbUCXIfMntnMG9hz177Jy813YUYtvVMuwOzyG+6MBLAN/tWchzrMh9eCuklwgbzhKIT Iulp3RcFLMPEOjMoZcTq2cE9gBrtWOF/aYKTnoVWT+ecNZ/btouTylVyQcemxk2Foimc oZN2AznQ0TGG0jn0jUwjGG6xI3uJ/y9WlLf9Q9Nl/GnOzKnc8grxrfBJKRBm8ylbz3yD Bc7rO+mzhSw90IvMlN3slWPTDZ0g3TbcsYqToPZonfQZQk8y87eikLQ0YuDujuwBHqIg KZwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3qV9UcfDlhAtdycG/J2QOpmGOMHKDJw+84ivqZISOMw=; b=YvPYklQLSETevwEhANWH+flKbDKwpy22ZTBprAMEcxpbVtX0PuUrifzg8mQJAijthB z2mjkuJk6rtr6gL2r+g6YDtBCoQb+Ch3s2hzb2PmpxFGQJSZXV3xRH0GhyN9JENYCdeD hjeKzElaBe/QHMtmLnvJ4UG6wkh2A3rhzCcdEZufoSog8pepIJU8trKG9RiXUigSdVj4 KWez7qbfqVxx/FsNhECrErTz5tUKta1DaVhGNR53B0pBFo68RaAdPUQIGPh8WR7ZDvyp pzcYjN9XSvZ910eO6EDVpeAKQNstLrBBK9oK8Fvcabi3KRAE8V4Tf6Nf5Nq5J4+SSI74 O97w== X-Gm-Message-State: AOAM530pY/0VY33CPseeAAnQ0+4r8ZIt0kRe9KSr89k/zUFPBVUvWYyC s+KMlNhuwmdnfmhOew+Zw+o= X-Google-Smtp-Source: ABdhPJzYCCdc66Px6kgcsd2keNn2AV14IvK10+oNUoVGSXgrEJ9kfydYiX3JXraJAWyrCMLduZT5Qw== X-Received: by 2002:a17:90a:4891:b0:1b9:81c:8774 with SMTP id b17-20020a17090a489100b001b9081c8774mr1840091pjh.8.1645693705380; Thu, 24 Feb 2022 01:08:25 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:25 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 01/16] blk: make the whole blk_mq_submit_bio under q_usage_counter Date: Thu, 24 Feb 2022 17:06:39 +0800 Message-Id: <20220224090654.54671-2-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is to protect the rqos list against the rqos open/close. We need to drain all of the caller of blk_mq_submit_bio() before we can operate the rqos list. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-mq.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/block/blk-mq.c b/block/blk-mq.c index 1adfe4824ef5..3c1cd32c72fd 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -2723,8 +2723,7 @@ static struct request *blk_mq_get_new_requests(struct= request_queue *q, }; struct request *rq; =20 - if (unlikely(bio_queue_enter(bio))) - return NULL; + percpu_ref_get(&q->q_usage_counter); =20 if (plug) { data.nr_tags =3D plug->nr_ios; @@ -2789,15 +2788,18 @@ void blk_mq_submit_bio(struct bio *bio) if (unlikely(!blk_crypto_bio_prep(&bio))) return; =20 + if (unlikely(bio_queue_enter(bio))) + return; + blk_queue_bounce(q, &bio); if (blk_may_split(q, bio)) __blk_queue_split(q, &bio, &nr_segs); =20 if (!bio_integrity_prep(bio)) - return; + goto exit; =20 if (blk_mq_attempt_bio_merge(q, bio, nr_segs)) - return; + goto exit; =20 rq_qos_throttle(q, bio); =20 @@ -2805,7 +2807,7 @@ void blk_mq_submit_bio(struct bio *bio) if (!rq) { rq =3D blk_mq_get_new_requests(q, plug, bio); if (unlikely(!rq)) - return; + goto exit; } =20 trace_block_getrq(bio); @@ -2819,12 +2821,12 @@ void blk_mq_submit_bio(struct bio *bio) bio->bi_status =3D ret; bio_endio(bio); blk_mq_free_request(rq); - return; + goto exit; } =20 if (op_is_flush(bio->bi_opf)) { blk_insert_flush(rq); - return; + goto exit; } =20 if (plug) @@ -2836,6 +2838,8 @@ void blk_mq_submit_bio(struct bio *bio) else blk_mq_run_dispatch_ops(rq->q, blk_mq_try_issue_directly(rq->mq_hctx, rq)); +exit: + blk_queue_exit(q); } =20 /** --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89D42C433F5 for ; Thu, 24 Feb 2022 09:08:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232571AbiBXJJV (ORCPT ); Thu, 24 Feb 2022 04:09:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232520AbiBXJI5 (ORCPT ); Thu, 24 Feb 2022 04:08:57 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33EA419E09B; Thu, 24 Feb 2022 01:08:28 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id q8-20020a17090a178800b001bc299b8de1so1500663pja.1; Thu, 24 Feb 2022 01:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EG+9Tmn7QgIN9x1YJfpebtDxHiDxr2IlFvxydQ8lHH8=; b=AQEud2jm1cGodIEDiEA9sfmipttXDcP1WN7+BvOuPLN4wkikS8J2lf4BhNrd54UQ40 IZWHIiN9n1Yaw+cFhK83scaTgkRxcxjgx9WJpmZa2wmxVmmQ8KockRMMkuZ0aP0qTG0t 9pY6y4rrPKZ6C6wL+YYEC5DlBITmK/SS34x1bPvsEkGTQNyxEmYcZX0y1vNhLejfuefN G1NSiureac63d/tz4wgP8IAhREu1pMiOXy7cRuZ4kzRvbZ1NQhK4pKR7+fphVPL1JxJ6 wFoUUZjYzqK5jORaMmQX+PhX/2r3bSwFA0whW7CnVvysb9irINCLStR6P2+1eT6gvPQm KB0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EG+9Tmn7QgIN9x1YJfpebtDxHiDxr2IlFvxydQ8lHH8=; b=sDJO3Oq4Xvzx8++BmOwOmn6D0yya/vUF1TZ8fBh8yIGLaqFYifighl163SbYNPYytz MSnQOHhhRO0nXuBW62GWXcWOooCJSkqXAWpiJBP+Eb9yOouCUBVv2FPrDRWhlGVwFzxd +xrFXMKap03HSCcENjKBI6FBGQzKhUG9eW0StyHGLftpasIg51Xqcut+E1PWeaNU8VcN Cgv6AVMHREhjMkxtCqgW9XMQKCrpKKErxoBdKHu7Juec52yvaacE0YJ0hyPW+QJs+TmU 6NWQ07Hm8nCcy2jksukdXlX1Mv7oh0+A4LMIH8jtm32LhZmNUPlwyJV6yWDMD3Fv56jk pNwQ== X-Gm-Message-State: AOAM532/vQwCgXiIij60D7xXhQe8XiZCNPVC3OPyHp6kf5t9nh4reZhe L6mqPUpkGispPxJ7zyqpb5o= X-Google-Smtp-Source: ABdhPJxhxEjoNI3MULwqlEW2x19JpXwakblQ7INZa//RIx16PLZg+HyjEVlDhE9+i8bv6MqnMmeYww== X-Received: by 2002:a17:90a:ac14:b0:1bc:2b81:4f5d with SMTP id o20-20020a17090aac1400b001bc2b814f5dmr13471421pjq.207.1645693707644; Thu, 24 Feb 2022 01:08:27 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:27 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 02/16] blk/rq-qos: prepare to make blk-rq-qos pluggable Date: Thu, 24 Feb 2022 17:06:40 +0800 Message-Id: <20220224090654.54671-3-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch makes blk-rq-qos policies pluggable as following, (1) Add code to maintain the rq_qos_ops. A rq-qos policy need to register itself with rq_qos_register(). The original enum rq_qos_id will be removed in following patch. They will use a dynamic id maintained by rq_qos_ida. (2) Add .init callback into rq_qos_ops. We use it to initialize the resource. (3) Add /sys/block/x/queue/qos We can use '+name' or "-name" to open or close the blk-rq-qos policy. This patch mainly prepare help interfaces and no functional changes. Following patches will adpat the code of wbt, iolatency, iocost and ioprio to make them pluggable one by one. And after that, the sysfs interface /sys/block/xxx/queue/qos will be exported. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-core.c | 1 + block/blk-mq-debugfs.c | 12 +- block/blk-rq-qos.c | 246 ++++++++++++++++++++++++++++++++++++++++- block/blk-rq-qos.h | 25 ++++- include/linux/blkdev.h | 1 + 5 files changed, 280 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index d93e3bb9a769..448d153e515b 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -485,6 +485,7 @@ struct request_queue *blk_alloc_queue(int node_id, bool= alloc_srcu) mutex_init(&q->sysfs_lock); mutex_init(&q->sysfs_dir_lock); spin_lock_init(&q->queue_lock); + spin_lock_init(&q->rqos_lock); =20 init_waitqueue_head(&q->mq_freeze_wq); mutex_init(&q->mq_freeze_lock); diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 3a790eb4995c..24d47bc90b4a 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -729,7 +729,10 @@ void blk_mq_debugfs_register(struct request_queue *q) =20 if (q->rq_qos) { struct rq_qos *rqos =3D q->rq_qos; - + /* + * Queue has not been registered right now, it is safe to + * iterate the rqos w/o lock + */ while (rqos) { blk_mq_debugfs_register_rqos(rqos); rqos =3D rqos->next; @@ -844,7 +847,12 @@ void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqo= s) void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) { struct request_queue *q =3D rqos->q; - const char *dir_name =3D rq_qos_id_to_name(rqos->id); + const char *dir_name; + + if (rqos->ops->name) + dir_name =3D rqos->ops->name; + else + dir_name =3D rq_qos_id_to_name(rqos->id); =20 if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) return; diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index e83af7bc7591..c43436c2ead1 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -2,6 +2,9 @@ =20 #include "blk-rq-qos.h" =20 +static DEFINE_IDR(rq_qos_idr); +static DEFINE_MUTEX(rq_qos_mutex); + /* * Increment 'v', if 'v' is below 'below'. Returns true if we succeeded, * false if 'v' + 1 would be bigger than 'below'. @@ -294,11 +297,250 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_= data, =20 void rq_qos_exit(struct request_queue *q) { - blk_mq_debugfs_unregister_queue_rqos(q); - + /* + * Queue must have been unregistered here, it is safe to + * iterate the list w/o lock + */ while (q->rq_qos) { struct rq_qos *rqos =3D q->rq_qos; q->rq_qos =3D rqos->next; rqos->ops->exit(rqos); } + blk_mq_debugfs_unregister_queue_rqos(q); +} + +static struct rq_qos *rq_qos_by_name(struct request_queue *q, + const char *name) +{ + struct rq_qos *rqos; + + for (rqos =3D q->rq_qos; rqos; rqos =3D rqos->next) { + if (!rqos->ops->name) + continue; + + if (!strncmp(rqos->ops->name, name, + strlen(rqos->ops->name))) + return rqos; + } + return NULL; +} + +/* + * This helper interface is to keep rqos alive against + * rqos switching. rq_qos_deactivate() drains all of + * rq_qos_get() before it frees the rqos structure. + */ +struct rq_qos *rq_qos_get(struct request_queue *q, int id) +{ + struct rq_qos *rqos; + + spin_lock_irq(&q->rqos_lock); + for (rqos =3D q->rq_qos; rqos; rqos =3D rqos->next) { + if (rqos->id =3D=3D id) { + break; + } + } + if (rqos && rqos->dying) + rqos =3D NULL; + if (rqos) + refcount_inc(&rqos->ref); + spin_unlock_irq(&q->rqos_lock); + return rqos; +} + +void rq_qos_put(struct rq_qos *rqos) +{ + struct request_queue *q =3D rqos->q; + + spin_lock_irq(&q->rqos_lock); + refcount_dec(&rqos->ref); + if (rqos->dying) + wake_up(&rqos->waitq); + spin_unlock_irq(&q->rqos_lock); +} + +void rq_qos_activate(struct request_queue *q, + struct rq_qos *rqos, const struct rq_qos_ops *ops) +{ + struct rq_qos *pos; + + rqos->dying =3D false; + refcount_set(&rqos->ref, 1); + init_waitqueue_head(&rqos->waitq); + rqos->id =3D ops->id; + rqos->ops =3D ops; + rqos->q =3D q; + rqos->next =3D NULL; + + spin_lock_irq(&q->rqos_lock); + pos =3D q->rq_qos; + if (pos) { + while (pos->next) + pos =3D pos->next; + pos->next =3D rqos; + } else { + q->rq_qos =3D rqos; + } + spin_unlock_irq(&q->rqos_lock); + + if (rqos->ops->debugfs_attrs) + blk_mq_debugfs_register_rqos(rqos); +} + +void rq_qos_deactivate(struct rq_qos *rqos) +{ + struct request_queue *q =3D rqos->q; + struct rq_qos **cur; + + spin_lock_irq(&q->rqos_lock); + rqos->dying =3D true; + /* + * Drain all of the usage of get/put_rqos() + */ + wait_event_lock_irq(rqos->waitq, + refcount_read(&rqos->ref) =3D=3D 1, q->rqos_lock); + for (cur =3D &q->rq_qos; *cur; cur =3D &(*cur)->next) { + if (*cur =3D=3D rqos) { + *cur =3D rqos->next; + break; + } + } + spin_unlock_irq(&q->rqos_lock); + blk_mq_debugfs_unregister_rqos(rqos); +} + +static struct rq_qos_ops *rq_qos_op_find(const char *name) +{ + struct rq_qos_ops *pos; + int id; + + idr_for_each_entry(&rq_qos_idr, pos, id) { + if (!strncmp(pos->name, name, strlen(pos->name))) + return pos; + } + + return NULL; +} + +int rq_qos_register(struct rq_qos_ops *ops) +{ + int ret, start; + + mutex_lock(&rq_qos_mutex); + + if (rq_qos_op_find(ops->name)) { + ret =3D -EEXIST; + goto out; + } + + start =3D RQ_QOS_IOPRIO + 1; + ret =3D idr_alloc(&rq_qos_idr, ops, start, INT_MAX, GFP_KERNEL); + if (ret < 0) + goto out; + + ops->id =3D ret; + ret =3D 0; +out: + mutex_unlock(&rq_qos_mutex); + return ret; +} + +void rq_qos_unregister(struct rq_qos_ops *ops) +{ + mutex_lock(&rq_qos_mutex); + idr_remove(&rq_qos_idr, ops->id); + mutex_unlock(&rq_qos_mutex); +} + +ssize_t queue_qos_show(struct request_queue *q, char *buf) +{ + struct rq_qos_ops *ops; + struct rq_qos *rqos; + int id, ret =3D 0; + + mutex_lock(&rq_qos_mutex); + /* + * Show the policies in the order of being invoked. + * rqos_lock is not needed here as the sysfs_lock is + * protected us from the queue_qos_store() + */ + for (rqos =3D q->rq_qos; rqos; rqos =3D rqos->next) { + if (!rqos->ops->name) + continue; + ret +=3D sprintf(buf + ret, "[%s] ", rqos->ops->name); + } + idr_for_each_entry(&rq_qos_idr, ops, id) { + if (!rq_qos_by_name(q, ops->name)) + ret +=3D sprintf(buf + ret, "%s ", ops->name); + } + + ret--; /* overwrite the last space */ + ret +=3D sprintf(buf + ret, "\n"); + mutex_unlock(&rq_qos_mutex); + + return ret; +} + +ssize_t queue_qos_store(struct request_queue *q, const char *page, + size_t count) +{ + const struct rq_qos_ops *ops; + struct rq_qos *rqos; + const char *qosname; + char *buf; + bool add; + int ret; + + if (!blk_queue_registered(q)) + return -ENOENT; + + buf =3D kstrdup(page, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + buf =3D strim(buf); + if (buf[0] !=3D '+' && buf[0] !=3D '-') { + ret =3D -EINVAL; + goto out; + } + + add =3D buf[0] =3D=3D '+'; + qosname =3D buf + 1; + + rqos =3D rq_qos_by_name(q, qosname); + if ((buf[0] =3D=3D '+' && rqos)) { + ret =3D -EEXIST; + goto out; + } + + if ((buf[0] =3D=3D '-' && !rqos)) { + ret =3D -ENODEV; + goto out; + } + + if (add) { + mutex_lock(&rq_qos_mutex); + ops =3D rq_qos_op_find(qosname); + mutex_unlock(&rq_qos_mutex); + if (!ops) { + ret =3D -EINVAL; + goto out; + } + } else { + ops =3D rqos->ops; + } + + blk_mq_freeze_queue(q); + blk_mq_quiesce_queue(q); + if (add) { + ret =3D ops->init(q); + } else { + ops->exit(rqos); + ret =3D 0; + } + blk_mq_unquiesce_queue(q); + blk_mq_unfreeze_queue(q); +out: + kfree(buf); + return ret ? ret : count; } diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 3cfbc8668cba..aa6ef12637a0 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -26,9 +26,12 @@ struct rq_wait { }; =20 struct rq_qos { - struct rq_qos_ops *ops; + const struct rq_qos_ops *ops; struct request_queue *q; enum rq_qos_id id; + refcount_t ref; + wait_queue_head_t waitq; + bool dying; struct rq_qos *next; #ifdef CONFIG_BLK_DEBUG_FS struct dentry *debugfs_dir; @@ -36,6 +39,8 @@ struct rq_qos { }; =20 struct rq_qos_ops { + const char *name; + int id; void (*throttle)(struct rq_qos *, struct bio *); void (*track)(struct rq_qos *, struct request *, struct bio *); void (*merge)(struct rq_qos *, struct request *, struct bio *); @@ -46,6 +51,7 @@ struct rq_qos_ops { void (*cleanup)(struct rq_qos *, struct bio *); void (*queue_depth_changed)(struct rq_qos *); void (*exit)(struct rq_qos *); + int (*init)(struct request_queue *); const struct blk_mq_debugfs_attr *debugfs_attrs; }; =20 @@ -132,6 +138,17 @@ static inline void rq_qos_del(struct request_queue *q,= struct rq_qos *rqos) blk_mq_debugfs_unregister_rqos(rqos); } =20 +int rq_qos_register(struct rq_qos_ops *ops); +void rq_qos_unregister(struct rq_qos_ops *ops); +void rq_qos_activate(struct request_queue *q, + struct rq_qos *rqos, const struct rq_qos_ops *ops); +void rq_qos_deactivate(struct rq_qos *rqos); +ssize_t queue_qos_show(struct request_queue *q, char *buf); +ssize_t queue_qos_store(struct request_queue *q, const char *page, + size_t count); +struct rq_qos *rq_qos_get(struct request_queue *q, int id); +void rq_qos_put(struct rq_qos *rqos); + typedef bool (acquire_inflight_cb_t)(struct rq_wait *rqw, void *private_da= ta); typedef void (cleanup_cb_t)(struct rq_wait *rqw, void *private_data); =20 @@ -211,8 +228,14 @@ static inline void rq_qos_merge(struct request_queue *= q, struct request *rq, =20 static inline void rq_qos_queue_depth_changed(struct request_queue *q) { + /* + * It is called by external module, protect the rqos list with + * sysfs_lock against qos switching + */ + mutex_lock(&q->sysfs_lock); if (q->rq_qos) __rq_qos_queue_depth_changed(q->rq_qos); + mutex_unlock(&q->sysfs_lock); } =20 void rq_qos_exit(struct request_queue *); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f35aea98bc35..126aac824ccc 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -230,6 +230,7 @@ struct request_queue { int id; =20 spinlock_t queue_lock; + spinlock_t rqos_lock; =20 struct gendisk *disk; =20 --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 02684C433EF for ; Thu, 24 Feb 2022 09:08:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232560AbiBXJJZ (ORCPT ); Thu, 24 Feb 2022 04:09:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232524AbiBXJJA (ORCPT ); Thu, 24 Feb 2022 04:09:00 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6CEC319DEBD; Thu, 24 Feb 2022 01:08:30 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id o26so560683pgb.8; Thu, 24 Feb 2022 01:08:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VQWIdijd8YwqRIfHznzt1wRRlGBAE5pmKuYQxNsoRdY=; b=AhWfUFH5g+cUmjdw5aN0o59ZH1C6Hs6qtAYSccQENEhwPFLZfzMzegv6vDLTJzNkUl taW0b1N6lmriA7dZ941LEQqrxIGw2NFN1j3PxzlZX5/9Wr8j/boEd5dl35PiHdiJAnfH pupr3CcEePDia+1MF/Fbc707XyvHxV5HD84GgQl/t8i6O7BKN89yWiuxBOizQl4eA8r8 D4AjEmIqufou02R4TBf5bwPeNnZAQkPLFcrLltK2yXOrXHfKbELvy0f++S37e1qLv3sL Haax4SnTmWnGBKmRly6lFnK2D643d7EC1TT7J+WhaqfuBE5ae244H6wy7Tt583C8zxfQ BQfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VQWIdijd8YwqRIfHznzt1wRRlGBAE5pmKuYQxNsoRdY=; b=no0YjpkzBoOIsHFz2Z0HsH5nCqZhavyAUg0ZhnUyX+LM59pIZQ2pdorZRZR7uv/TME pTeQWLxGy2Cg7zNWbHTzk1kakNkMHE+eaxmGSe8VxPncz01Ad0qWElYJSXcER03pAgvH ojbevFFQLyHShJ6QCgJ4VMKDEQkarNlgsD/hptpdhy0irDm2JfbERaDPALJldgHRBC4t JXrjeghvvds4C+Ndxye6V0i1n/znYc08XmqIxOFb+QnpycYHb7S0IXDfQq4czbPJKuxd 4iY/EpRLLgZjESaEsyPYTGwaT5F/035VsAQzIN5vKeUkYMQh/dwjNbWBu303+8Z2ldmQ eIgg== X-Gm-Message-State: AOAM532XnKnKtPvyu2kisdAS/ktcz4+a37TQjIvUaIE4ykHCB2vrVmhw ivfTZeBzUsJ1u6tgk6Dqgeo= X-Google-Smtp-Source: ABdhPJydnrUAn3e0HiHtwM3ROWY+XfD2DFDxK3+Kt4DTkObc4fOrvDhAONg9UEzxMjQqyNSkhs2S6g== X-Received: by 2002:a05:6a00:1152:b0:4be:ab79:fcfa with SMTP id b18-20020a056a00115200b004beab79fcfamr1690820pfm.3.1645693709907; Thu, 24 Feb 2022 01:08:29 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:29 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 03/16] blk-wbt: make wbt pluggable Date: Thu, 24 Feb 2022 17:06:41 +0800 Message-Id: <20220224090654.54671-4-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch makes wbt pluggable through /sys/block/xxx/queue/qos. Some queue_lock/unlock is added to protect rq_qos_by_id() in wbt_rq_qos(). By default, wbt is enabled which is same with previous code. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-mq-debugfs.c | 2 -- block/blk-rq-qos.h | 6 ----- block/blk-sysfs.c | 6 ++--- block/blk-wbt.c | 56 +++++++++++++++++++++++++++++++++++++----- block/blk-wbt.h | 6 +++++ 5 files changed, 58 insertions(+), 18 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 24d47bc90b4a..073ca7fca9b3 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -826,8 +826,6 @@ void blk_mq_debugfs_unregister_sched(struct request_que= ue *q) static const char *rq_qos_id_to_name(enum rq_qos_id id) { switch (id) { - case RQ_QOS_WBT: - return "wbt"; case RQ_QOS_LATENCY: return "latency"; case RQ_QOS_COST: diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index aa6ef12637a0..8ce3f48b16b9 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -14,7 +14,6 @@ struct blk_mq_debugfs_attr; =20 enum rq_qos_id { - RQ_QOS_WBT, RQ_QOS_LATENCY, RQ_QOS_COST, RQ_QOS_IOPRIO, @@ -76,11 +75,6 @@ static inline struct rq_qos *rq_qos_id(struct request_qu= eue *q, return rqos; } =20 -static inline struct rq_qos *wbt_rq_qos(struct request_queue *q) -{ - return rq_qos_id(q, RQ_QOS_WBT); -} - static inline struct rq_qos *blkcg_rq_qos(struct request_queue *q) { return rq_qos_id(q, RQ_QOS_LATENCY); diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 9f32882ceb2f..c713d6b305cc 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -463,7 +463,7 @@ static ssize_t queue_io_timeout_store(struct request_qu= eue *q, const char *page, =20 static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) { - if (!wbt_rq_qos(q)) + if (!wbt_opened(q)) return -EINVAL; =20 return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); @@ -472,7 +472,6 @@ static ssize_t queue_wb_lat_show(struct request_queue *= q, char *page) static ssize_t queue_wb_lat_store(struct request_queue *q, const char *pag= e, size_t count) { - struct rq_qos *rqos; ssize_t ret; s64 val; =20 @@ -482,8 +481,7 @@ static ssize_t queue_wb_lat_store(struct request_queue = *q, const char *page, if (val < -1) return -EINVAL; =20 - rqos =3D wbt_rq_qos(q); - if (!rqos) { + if (!wbt_opened(q)) { ret =3D wbt_init(q); if (ret) return ret; diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 0c119be0e813..44a920d83475 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -31,6 +31,22 @@ #define CREATE_TRACE_POINTS #include =20 +static struct rq_qos_ops wbt_rqos_ops; + +static inline struct rq_qos *wbt_rq_qos(struct request_queue *q) +{ + return rq_qos_get(q, wbt_rqos_ops.id); +} + +bool wbt_opened(struct request_queue *q) +{ + struct rq_qos *rqos =3D wbt_rq_qos(q); + + rq_qos_put(rqos); + + return !!rqos; +} + static inline void wbt_clear_state(struct request *rq) { rq->wbt_flags =3D 0; @@ -425,19 +441,27 @@ static void wbt_update_limits(struct rq_wb *rwb) u64 wbt_get_min_lat(struct request_queue *q) { struct rq_qos *rqos =3D wbt_rq_qos(q); + u64 nsec; + if (!rqos) return 0; - return RQWB(rqos)->min_lat_nsec; + + nsec =3D RQWB(rqos)->min_lat_nsec; + rq_qos_put(rqos); + + return nsec; } =20 void wbt_set_min_lat(struct request_queue *q, u64 val) { struct rq_qos *rqos =3D wbt_rq_qos(q); + if (!rqos) return; RQWB(rqos)->min_lat_nsec =3D val; RQWB(rqos)->enable_state =3D WBT_STATE_ON_MANUAL; wbt_update_limits(RQWB(rqos)); + rq_qos_put(rqos); } =20 =20 @@ -629,8 +653,11 @@ static void wbt_requeue(struct rq_qos *rqos, struct re= quest *rq) void wbt_set_write_cache(struct request_queue *q, bool write_cache_on) { struct rq_qos *rqos =3D wbt_rq_qos(q); - if (rqos) + + if (rqos) { RQWB(rqos)->wc =3D write_cache_on; + rq_qos_put(rqos); + } } =20 /* @@ -644,6 +671,8 @@ void wbt_enable_default(struct request_queue *q) if (rqos) { if (RQWB(rqos)->enable_state =3D=3D WBT_STATE_OFF_DEFAULT) RQWB(rqos)->enable_state =3D WBT_STATE_ON_DEFAULT; + + rq_qos_put(rqos); return; } =20 @@ -692,6 +721,7 @@ static void wbt_exit(struct rq_qos *rqos) struct rq_wb *rwb =3D RQWB(rqos); struct request_queue *q =3D rqos->q; =20 + rq_qos_deactivate(rqos); blk_stat_remove_callback(q, rwb->cb); blk_stat_free_callback(rwb->cb); kfree(rwb); @@ -704,13 +734,16 @@ void wbt_disable_default(struct request_queue *q) { struct rq_qos *rqos =3D wbt_rq_qos(q); struct rq_wb *rwb; + if (!rqos) return; + rwb =3D RQWB(rqos); if (rwb->enable_state =3D=3D WBT_STATE_ON_DEFAULT) { blk_stat_deactivate(rwb->cb); rwb->enable_state =3D WBT_STATE_OFF_DEFAULT; } + rq_qos_put(rqos); } EXPORT_SYMBOL_GPL(wbt_disable_default); =20 @@ -803,6 +836,7 @@ static const struct blk_mq_debugfs_attr wbt_debugfs_att= rs[] =3D { #endif =20 static struct rq_qos_ops wbt_rqos_ops =3D { + .name =3D "wbt", .throttle =3D wbt_wait, .issue =3D wbt_issue, .track =3D wbt_track, @@ -811,6 +845,7 @@ static struct rq_qos_ops wbt_rqos_ops =3D { .cleanup =3D wbt_cleanup, .queue_depth_changed =3D wbt_queue_depth_changed, .exit =3D wbt_exit, + .init =3D wbt_init, #ifdef CONFIG_BLK_DEBUG_FS .debugfs_attrs =3D wbt_debugfs_attrs, #endif @@ -834,9 +869,6 @@ int wbt_init(struct request_queue *q) for (i =3D 0; i < WBT_NUM_RWQ; i++) rq_wait_init(&rwb->rq_wait[i]); =20 - rwb->rqos.id =3D RQ_QOS_WBT; - rwb->rqos.ops =3D &wbt_rqos_ops; - rwb->rqos.q =3D q; rwb->last_comp =3D rwb->last_issue =3D jiffies; rwb->win_nsec =3D RWB_WINDOW_NSEC; rwb->enable_state =3D WBT_STATE_ON_DEFAULT; @@ -846,7 +878,7 @@ int wbt_init(struct request_queue *q) /* * Assign rwb and add the stats callback. */ - rq_qos_add(q, &rwb->rqos); + rq_qos_activate(q, &rwb->rqos, &wbt_rqos_ops); blk_stat_add_callback(q, rwb->cb); =20 rwb->min_lat_nsec =3D wbt_default_latency_nsec(q); @@ -856,3 +888,15 @@ int wbt_init(struct request_queue *q) =20 return 0; } + +static __init int wbt_mod_init(void) +{ + return rq_qos_register(&wbt_rqos_ops); +} + +static __exit void wbt_mod_exit(void) +{ + return rq_qos_unregister(&wbt_rqos_ops); +} +module_init(wbt_mod_init); +module_exit(wbt_mod_exit); diff --git a/block/blk-wbt.h b/block/blk-wbt.h index 2eb01becde8c..f128dcf662db 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -88,6 +88,7 @@ static inline unsigned int wbt_inflight(struct rq_wb *rwb) =20 #ifdef CONFIG_BLK_WBT =20 +bool wbt_opened(struct request_queue *q); int wbt_init(struct request_queue *); void wbt_disable_default(struct request_queue *); void wbt_enable_default(struct request_queue *); @@ -101,6 +102,11 @@ u64 wbt_default_latency_nsec(struct request_queue *); =20 #else =20 +bool wbt_opened(struct request_queue *q) +{ + return false; +} + static inline void wbt_track(struct request *rq, enum wbt_flags flags) { } --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4D6CC4332F for ; Thu, 24 Feb 2022 09:08:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232582AbiBXJJ1 (ORCPT ); Thu, 24 Feb 2022 04:09:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232537AbiBXJJF (ORCPT ); Thu, 24 Feb 2022 04:09:05 -0500 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B67619E0A5; Thu, 24 Feb 2022 01:08:32 -0800 (PST) Received: by mail-pg1-x533.google.com with SMTP id 12so1259110pgd.0; Thu, 24 Feb 2022 01:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Nx8GCTCx6Zwjghi38JpLlv6BNyEAfbmY7D9QOG9o9BE=; b=DzEeRDK/keZK/gwZpdZ137RRiHFrQyVRP39pKv58zsMwCzQhnIuGNzFNuDce6+hdWW Qaveh5x6rErROnWbwY0jBBuwcpb0SabJOVg31R4DssC4OUznzIARc3X2DFM8o4xlhWg2 3ZAf0sVBLaOeUk9LhVPNXw/vk+CXIrVfCeLqRHxSSLY6SnHvVp6Y9R4VX4FExXkVCfGl kTpnlv2SQby+dBAINjmIZRzhDCn1tVcfPmEwBFxv5bOPIN0gs9fujeUTgg1bk3ZY2AeX HIhaYkfudhDTZWkjtCBP/rtiTRLT7/czDD5AYv97t/RLdv9PcX0O5RIAXpaNJdWHsOd3 c/UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Nx8GCTCx6Zwjghi38JpLlv6BNyEAfbmY7D9QOG9o9BE=; b=OQKMwstIagygZMFO2JWTyEFqtpR9QsbgI4/B1i0irMIaIyl7iMpyiEzbVMKi0z0cdb x112AcXQzBsWrzQ5kPaHdU+lF3b90FDDlFFNwEMpXR+MNa6Q4tpDMEmWo0ld9z/+m/4N dBPYAFixUQL8RipLpUL8D+Lf304wWVK+tmpIhAr8v3aDXtEO62CyZ9tsTuqdaD5wUP6A K5b4c+MKLaGeraUNCcKbApQmDXxLDQaXDaNrhpq4vvGQzmRdCg5SfPYCYtjINdfallQY 7FBGEsj7iG3CsDdEsHYBtsXHgnL9i1wtugPokCzojrCUUJ9Rn/IguaLIvruzIDvMiDz0 IARg== X-Gm-Message-State: AOAM532WrGhJLoBtq/p3H9TdoWAwnCg4TBEGIUSNK5icNOjrIvl/1jWX HTyhGnwLyh+ItKIuDJlgs28OSVwbRdEojg== X-Google-Smtp-Source: ABdhPJx0S/65fbYpA5OKdQStj/iXK+wsS+H3aKskTsHu7ozvaCyl7g0+CwIKsI/ilj57UGQVA0A++Q== X-Received: by 2002:a63:3545:0:b0:36c:479c:927a with SMTP id c66-20020a633545000000b0036c479c927amr1506619pga.347.1645693712016; Thu, 24 Feb 2022 01:08:32 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:31 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 04/16] blk-iolatency: make iolatency pluggable Date: Thu, 24 Feb 2022 17:06:42 +0800 Message-Id: <20220224090654.54671-5-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use new blk-rq-qos API to make blk-iolatency pluggable. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-cgroup.c | 6 ------ block/blk-iolatency.c | 44 +++++++++++++++++++++++++++--------------- block/blk-mq-debugfs.c | 2 -- block/blk-rq-qos.h | 6 ------ block/blk.h | 6 ------ 5 files changed, 28 insertions(+), 36 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 650f7e27989f..3ae2aa557aef 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1203,12 +1203,6 @@ int blkcg_init_queue(struct request_queue *q) if (ret) goto err_destroy_all; =20 - ret =3D blk_iolatency_init(q); - if (ret) { - blk_throtl_exit(q); - goto err_destroy_all; - } - return 0; =20 err_destroy_all: diff --git a/block/blk-iolatency.c b/block/blk-iolatency.c index 6593c7123b97..1459b606e995 100644 --- a/block/blk-iolatency.c +++ b/block/blk-iolatency.c @@ -90,6 +90,8 @@ struct blk_iolatency { atomic_t enabled; }; =20 +static struct rq_qos_ops blkcg_iolatency_ops; + static inline struct blk_iolatency *BLKIOLATENCY(struct rq_qos *rqos) { return container_of(rqos, struct blk_iolatency, rqos); @@ -646,15 +648,10 @@ static void blkcg_iolatency_exit(struct rq_qos *rqos) =20 del_timer_sync(&blkiolat->timer); blkcg_deactivate_policy(rqos->q, &blkcg_policy_iolatency); + rq_qos_deactivate(rqos); kfree(blkiolat); } =20 -static struct rq_qos_ops blkcg_iolatency_ops =3D { - .throttle =3D blkcg_iolatency_throttle, - .done_bio =3D blkcg_iolatency_done_bio, - .exit =3D blkcg_iolatency_exit, -}; - static void blkiolatency_timer_fn(struct timer_list *t) { struct blk_iolatency *blkiolat =3D from_timer(blkiolat, t, timer); @@ -716,7 +713,7 @@ static void blkiolatency_timer_fn(struct timer_list *t) rcu_read_unlock(); } =20 -int blk_iolatency_init(struct request_queue *q) +static int blk_iolatency_init(struct request_queue *q) { struct blk_iolatency *blkiolat; struct rq_qos *rqos; @@ -727,15 +724,10 @@ int blk_iolatency_init(struct request_queue *q) return -ENOMEM; =20 rqos =3D &blkiolat->rqos; - rqos->id =3D RQ_QOS_LATENCY; - rqos->ops =3D &blkcg_iolatency_ops; - rqos->q =3D q; - - rq_qos_add(q, rqos); - + rq_qos_activate(q, rqos, &blkcg_iolatency_ops); ret =3D blkcg_activate_policy(q, &blkcg_policy_iolatency); if (ret) { - rq_qos_del(q, rqos); + rq_qos_deactivate(rqos); kfree(blkiolat); return ret; } @@ -745,6 +737,14 @@ int blk_iolatency_init(struct request_queue *q) return 0; } =20 +static struct rq_qos_ops blkcg_iolatency_ops =3D { + .name =3D "iolat", + .throttle =3D blkcg_iolatency_throttle, + .done_bio =3D blkcg_iolatency_done_bio, + .exit =3D blkcg_iolatency_exit, + .init =3D blk_iolatency_init, +}; + /* * return 1 for enabling iolatency, return -1 for disabling iolatency, oth= erwise * return 0. @@ -962,7 +962,7 @@ static void iolatency_pd_init(struct blkg_policy_data *= pd) { struct iolatency_grp *iolat =3D pd_to_lat(pd); struct blkcg_gq *blkg =3D lat_to_blkg(iolat); - struct rq_qos *rqos =3D blkcg_rq_qos(blkg->q); + struct rq_qos *rqos =3D rq_qos_get(blkg->q, blkcg_iolatency_ops.id); struct blk_iolatency *blkiolat =3D BLKIOLATENCY(rqos); u64 now =3D ktime_to_ns(ktime_get()); int cpu; @@ -1016,6 +1016,7 @@ static void iolatency_pd_offline(struct blkg_policy_d= ata *pd) if (ret =3D=3D -1) atomic_dec(&blkiolat->enabled); iolatency_clear_scaling(blkg); + rq_qos_put(&blkiolat->rqos); } =20 static void iolatency_pd_free(struct blkg_policy_data *pd) @@ -1046,12 +1047,23 @@ static struct blkcg_policy blkcg_policy_iolatency = =3D { =20 static int __init iolatency_init(void) { - return blkcg_policy_register(&blkcg_policy_iolatency); + int ret; + + ret =3D rq_qos_register(&blkcg_iolatency_ops); + if (ret) + return ret; + + ret =3D blkcg_policy_register(&blkcg_policy_iolatency); + if (ret) + rq_qos_unregister(&blkcg_iolatency_ops); + + return ret; } =20 static void __exit iolatency_exit(void) { blkcg_policy_unregister(&blkcg_policy_iolatency); + rq_qos_unregister(&blkcg_iolatency_ops); } =20 module_init(iolatency_init); diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 073ca7fca9b3..102bc5814cda 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -826,8 +826,6 @@ void blk_mq_debugfs_unregister_sched(struct request_que= ue *q) static const char *rq_qos_id_to_name(enum rq_qos_id id) { switch (id) { - case RQ_QOS_LATENCY: - return "latency"; case RQ_QOS_COST: return "cost"; case RQ_QOS_IOPRIO: diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 8ce3f48b16b9..ecd1d1692a7d 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -14,7 +14,6 @@ struct blk_mq_debugfs_attr; =20 enum rq_qos_id { - RQ_QOS_LATENCY, RQ_QOS_COST, RQ_QOS_IOPRIO, }; @@ -75,11 +74,6 @@ static inline struct rq_qos *rq_qos_id(struct request_qu= eue *q, return rqos; } =20 -static inline struct rq_qos *blkcg_rq_qos(struct request_queue *q) -{ - return rq_qos_id(q, RQ_QOS_LATENCY); -} - static inline void rq_wait_init(struct rq_wait *rq_wait) { atomic_set(&rq_wait->inflight, 0); diff --git a/block/blk.h b/block/blk.h index 8bd43b3ad33d..1a314257b6a3 100644 --- a/block/blk.h +++ b/block/blk.h @@ -400,12 +400,6 @@ static inline void blk_queue_bounce(struct request_que= ue *q, struct bio **bio) __blk_queue_bounce(q, bio);=09 } =20 -#ifdef CONFIG_BLK_CGROUP_IOLATENCY -extern int blk_iolatency_init(struct request_queue *q); -#else -static inline int blk_iolatency_init(struct request_queue *q) { return 0; } -#endif - struct bio *blk_next_bio(struct bio *bio, unsigned int nr_pages, gfp_t gfp= ); =20 #ifdef CONFIG_BLK_DEV_ZONED --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 137A8C433F5 for ; Thu, 24 Feb 2022 09:09:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232623AbiBXJJi (ORCPT ); Thu, 24 Feb 2022 04:09:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232480AbiBXJJJ (ORCPT ); Thu, 24 Feb 2022 04:09:09 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAC641A02A7; Thu, 24 Feb 2022 01:08:34 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id q1so1146451plx.4; Thu, 24 Feb 2022 01:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=uoP7wXyeblwzayPXVHQ1z0JW6TP8fvO+buqRA0F2cHo=; b=GL/daupG7qcVsle7TnNCJfjJBxXccDltckxk33WmlmeT7SICgGXSTxlQDv7lDVNdvb uC6JwPJQbg5Rhio30dWb73nmWQLb7Ds3IBTz829ShtfU4pLesGBdkpD+ztvgVrCtmola 0ttfBiTdZEM+spj/TDreZ+qhyQp+otB2/6CDW/XQLEXC5HAYeRK3bbqjJYHOR5JiZmbw Mn+8RM/lkt9Lp6+t7V25k0bDtcM8ZMnhVKmCbs145FgIT1k0Layyrijp52e680FuYbXo 74qXv+fjvNFli16WpKepS8R7IweXkeXfVtIqtlpjTxp0tvgwwkz25SfqIenN8WJp3tPp 0pXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=uoP7wXyeblwzayPXVHQ1z0JW6TP8fvO+buqRA0F2cHo=; b=8JHd8JBTYaVnUtbQXlyPDzP0mRnLvzy6V1yIvBlV+EIGyjGNVriDDJ+stSIWAoamoc W4fJnDzLPCvDSpQi5mMggKYoSMUJtx4omh134qjODqWrE4UaXg9+4PFGS7hq++QqLrl7 rHhcYpG4tiaqcED0SIdsVL1gSPaYEqx5xlIPFQf2FbPnAOJWOhYi12AH3tcELILcM6IH 2+mGtGaiDCecYKCQDhV4YtxgD0h6b9ITfDl4cm/TKKf4jeb2Y5RNmHf4sO5UHJJj8P37 1N129u5Sf1G0oCX5//tGBuu1ztYb4Fm0JC0vknH+RL3JSktoKBKMEgQOOG0gz+6ccSnm jCcA== X-Gm-Message-State: AOAM530rzLF+0De0Tfe32+MdBEs/CRdILP6O4uITluFl682vAMm9z7N1 EVkY7Gay93Mpa+4RrhGvzpA= X-Google-Smtp-Source: ABdhPJw+gXMgSc/t/r5GMXt3uwZNfS8HZLDU2lmgABLWg6dNtNJKnN4+vdIcc9t+kbrXETRuUZ2GSg== X-Received: by 2002:a17:902:ee45:b0:14f:b66c:dbad with SMTP id 5-20020a170902ee4500b0014fb66cdbadmr1885052plo.73.1645693714254; Thu, 24 Feb 2022 01:08:34 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:33 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 05/16] blk-iocost: make iocost pluggable Date: Thu, 24 Feb 2022 17:06:43 +0800 Message-Id: <20220224090654.54671-6-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use new blk-rq-qos API to make blk-iocost pluggable. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-iocost.c | 80 ++++++++++++++++++++++++------------------ block/blk-mq-debugfs.c | 2 -- block/blk-rq-qos.h | 1 - 3 files changed, 45 insertions(+), 38 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 769b64394298..886c03383444 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -660,10 +660,7 @@ static struct ioc *rqos_to_ioc(struct rq_qos *rqos) return container_of(rqos, struct ioc, rqos); } =20 -static struct ioc *q_to_ioc(struct request_queue *q) -{ - return rqos_to_ioc(rq_qos_id(q, RQ_QOS_COST)); -} +static struct rq_qos_ops ioc_rqos_ops; =20 static const char *q_name(struct request_queue *q) { @@ -2810,6 +2807,7 @@ static void ioc_rqos_exit(struct rq_qos *rqos) struct ioc *ioc =3D rqos_to_ioc(rqos); =20 blkcg_deactivate_policy(rqos->q, &blkcg_policy_iocost); + rq_qos_deactivate(rqos); =20 spin_lock_irq(&ioc->lock); ioc->running =3D IOC_STOP; @@ -2820,15 +2818,6 @@ static void ioc_rqos_exit(struct rq_qos *rqos) kfree(ioc); } =20 -static struct rq_qos_ops ioc_rqos_ops =3D { - .throttle =3D ioc_rqos_throttle, - .merge =3D ioc_rqos_merge, - .done_bio =3D ioc_rqos_done_bio, - .done =3D ioc_rqos_done, - .queue_depth_changed =3D ioc_rqos_queue_depth_changed, - .exit =3D ioc_rqos_exit, -}; - static int blk_iocost_init(struct request_queue *q) { struct ioc *ioc; @@ -2856,10 +2845,7 @@ static int blk_iocost_init(struct request_queue *q) } =20 rqos =3D &ioc->rqos; - rqos->id =3D RQ_QOS_COST; - rqos->ops =3D &ioc_rqos_ops; - rqos->q =3D q; - + rq_qos_activate(q, rqos, &ioc_rqos_ops); spin_lock_init(&ioc->lock); timer_setup(&ioc->timer, ioc_timer_fn, 0); INIT_LIST_HEAD(&ioc->active_iocgs); @@ -2883,10 +2869,9 @@ static int blk_iocost_init(struct request_queue *q) * called before policy activation completion, can't assume that the * target bio has an iocg associated and need to test for NULL iocg. */ - rq_qos_add(q, rqos); ret =3D blkcg_activate_policy(q, &blkcg_policy_iocost); if (ret) { - rq_qos_del(q, rqos); + rq_qos_deactivate(rqos); free_percpu(ioc->pcpu_stat); kfree(ioc); return ret; @@ -2894,6 +2879,17 @@ static int blk_iocost_init(struct request_queue *q) return 0; } =20 +static struct rq_qos_ops ioc_rqos_ops =3D { + .name =3D "iocost", + .throttle =3D ioc_rqos_throttle, + .merge =3D ioc_rqos_merge, + .done_bio =3D ioc_rqos_done_bio, + .done =3D ioc_rqos_done, + .queue_depth_changed =3D ioc_rqos_queue_depth_changed, + .exit =3D ioc_rqos_exit, + .init =3D blk_iocost_init, +}; + static struct blkcg_policy_data *ioc_cpd_alloc(gfp_t gfp) { struct ioc_cgrp *iocc; @@ -2934,7 +2930,7 @@ static void ioc_pd_init(struct blkg_policy_data *pd) { struct ioc_gq *iocg =3D pd_to_iocg(pd); struct blkcg_gq *blkg =3D pd_to_blkg(&iocg->pd); - struct ioc *ioc =3D q_to_ioc(blkg->q); + struct ioc *ioc =3D rqos_to_ioc(rq_qos_get(blkg->q, ioc_rqos_ops.id)); struct ioc_now now; struct blkcg_gq *tblkg; unsigned long flags; @@ -2990,6 +2986,7 @@ static void ioc_pd_free(struct blkg_policy_data *pd) spin_unlock_irqrestore(&ioc->lock, flags); =20 hrtimer_cancel(&iocg->waitq_timer); + rq_qos_put(&ioc->rqos); } free_percpu(iocg->pcpu_stat); kfree(iocg); @@ -3162,6 +3159,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file = *of, char *input, size_t nbytes, loff_t off) { struct block_device *bdev; + struct rq_qos *rqos; struct ioc *ioc; u32 qos[NR_QOS_PARAMS]; bool enable, user; @@ -3172,14 +3170,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_fil= e *of, char *input, if (IS_ERR(bdev)) return PTR_ERR(bdev); =20 - ioc =3D q_to_ioc(bdev_get_queue(bdev)); - if (!ioc) { - ret =3D blk_iocost_init(bdev_get_queue(bdev)); - if (ret) - goto err; - ioc =3D q_to_ioc(bdev_get_queue(bdev)); + rqos =3D rq_qos_get(bdev_get_queue(bdev), ioc_rqos_ops.id); + if (!rqos) { + ret =3D -EOPNOTSUPP; + goto err; } - + ioc =3D rqos_to_ioc(rqos); spin_lock_irq(&ioc->lock); memcpy(qos, ioc->params.qos, sizeof(qos)); enable =3D ioc->enabled; @@ -3272,10 +3268,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_fil= e *of, char *input, ioc_refresh_params(ioc, true); spin_unlock_irq(&ioc->lock); =20 + rq_qos_put(rqos); blkdev_put_no_open(bdev); return nbytes; einval: ret =3D -EINVAL; + rq_qos_put(rqos); err: blkdev_put_no_open(bdev); return ret; @@ -3329,6 +3327,7 @@ static ssize_t ioc_cost_model_write(struct kernfs_ope= n_file *of, char *input, size_t nbytes, loff_t off) { struct block_device *bdev; + struct rq_qos *rqos; struct ioc *ioc; u64 u[NR_I_LCOEFS]; bool user; @@ -3339,14 +3338,12 @@ static ssize_t ioc_cost_model_write(struct kernfs_o= pen_file *of, char *input, if (IS_ERR(bdev)) return PTR_ERR(bdev); =20 - ioc =3D q_to_ioc(bdev_get_queue(bdev)); - if (!ioc) { - ret =3D blk_iocost_init(bdev_get_queue(bdev)); - if (ret) - goto err; - ioc =3D q_to_ioc(bdev_get_queue(bdev)); + rqos =3D rq_qos_get(bdev_get_queue(bdev), ioc_rqos_ops.id); + if (!rqos) { + ret =3D -EOPNOTSUPP; + goto err; } - + ioc =3D rqos_to_ioc(rqos); spin_lock_irq(&ioc->lock); memcpy(u, ioc->params.i_lcoefs, sizeof(u)); user =3D ioc->user_cost_model; @@ -3397,11 +3394,13 @@ static ssize_t ioc_cost_model_write(struct kernfs_o= pen_file *of, char *input, ioc_refresh_params(ioc, true); spin_unlock_irq(&ioc->lock); =20 + rq_qos_put(rqos); blkdev_put_no_open(bdev); return nbytes; =20 einval: ret =3D -EINVAL; + rq_qos_put(rqos); err: blkdev_put_no_open(bdev); return ret; @@ -3441,12 +3440,23 @@ static struct blkcg_policy blkcg_policy_iocost =3D { =20 static int __init ioc_init(void) { - return blkcg_policy_register(&blkcg_policy_iocost); + int ret; + + ret =3D rq_qos_register(&ioc_rqos_ops); + if (ret) + return ret; + + ret =3D blkcg_policy_register(&blkcg_policy_iocost); + if (ret) + rq_qos_unregister(&ioc_rqos_ops); + + return ret; } =20 static void __exit ioc_exit(void) { blkcg_policy_unregister(&blkcg_policy_iocost); + rq_qos_unregister(&ioc_rqos_ops); } =20 module_init(ioc_init); diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 102bc5814cda..27ca6185ad59 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -826,8 +826,6 @@ void blk_mq_debugfs_unregister_sched(struct request_que= ue *q) static const char *rq_qos_id_to_name(enum rq_qos_id id) { switch (id) { - case RQ_QOS_COST: - return "cost"; case RQ_QOS_IOPRIO: return "ioprio"; } diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index ecd1d1692a7d..ab95a366710d 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -14,7 +14,6 @@ struct blk_mq_debugfs_attr; =20 enum rq_qos_id { - RQ_QOS_COST, RQ_QOS_IOPRIO, }; =20 --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CC69EC433F5 for ; Thu, 24 Feb 2022 09:09:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232627AbiBXJJm (ORCPT ); Thu, 24 Feb 2022 04:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232542AbiBXJJJ (ORCPT ); Thu, 24 Feb 2022 04:09:09 -0500 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01C451A1281; Thu, 24 Feb 2022 01:08:37 -0800 (PST) Received: by mail-pg1-x534.google.com with SMTP id 132so1215412pga.5; Thu, 24 Feb 2022 01:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7D0XaFfUffPOg1PdRjYQovfR0/U/xSVfFKy5GYaOVfE=; b=Wbyhn4tMRWHYwy+0lhRYBa45FX7OdWdFBRWGV9p/65ZYYvpEWCA2L1yVRSQb6pg3S6 +88IPVYWHxluNfg7dXwIomEL5GFnKR7ev0KIlskq46enUDzil/QxI6NZF/JNx7Kn7l89 gWh5YIkPoIbspwuh4tesfC0u02YAszhwkRIbC31q9Emzb42+sL2HsiN+PvfIdoQorlZ2 LZDjDwV+QVoPaPDNM2ub1o76qnxpFW1Tdlx1OTiB4jO7Lh7fFR4uYj4iYEGt3zmGyirB 3A4l9H+BTBECD6zEgfjrueBR8lRkMXr+oGcdX7ErGRgxw+dTIbQb20Z6ZUJsrfHuCNZ1 A1pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7D0XaFfUffPOg1PdRjYQovfR0/U/xSVfFKy5GYaOVfE=; b=KjS2E0WdeZmyJLjyVAE8fPYDSQMxXGYUerDyh/s8Ofj2vOCOGTXaCnmBV+qgG3mjnt +XAMuGsFfAEUv0nbhtStoNvqvXbqKc7qJDc28Pn5bzV37XMRBhxRSjQ6HxsK9lOlJ/rs VvGTa7ND0pDx8MbTqYuwQTeVuL7LoiwdEe+dCXGvQ3yXRCx9lHLYXKDd/sZi6upqTKCZ wLXNTH4pJjj/obsnH2CSPDTvA2m/bF6S6sVkil3qe5YdzW8WWTSaBG/DyD8efCj1isho D8IeAVn1UaUj34DZn8u4FPHCVFqaVvKQ5XvWAxX07TFec4cY3dPbHvL6NHyhRluepCSJ aPBw== X-Gm-Message-State: AOAM533jvmBBCeavBXskoWkviu1G+q1DjyLa6mZVqAdQke3brzXqUBr+ xVLo9Ze6zkShVNHezduFLow= X-Google-Smtp-Source: ABdhPJy46BJAK9qEonIDnZ6kZGQbivQlaMLPE53RPC00SKgUCmrl8SP7ucl85Y6RAKEzY6h3CVmqSg== X-Received: by 2002:a63:8a4b:0:b0:340:47d6:4e6a with SMTP id y72-20020a638a4b000000b0034047d64e6amr1571599pgd.89.1645693716528; Thu, 24 Feb 2022 01:08:36 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:36 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 06/16] blk-ioprio: make ioprio pluggable Date: Thu, 24 Feb 2022 17:06:44 +0800 Message-Id: <20220224090654.54671-7-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Use new blk-rq-qos API to make blk-ioprio pluggable. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-cgroup.c | 5 ---- block/blk-ioprio.c | 53 ++++++++++++++++++++++++------------------ block/blk-ioprio.h | 19 --------------- block/blk-mq-debugfs.c | 4 ---- block/blk-rq-qos.c | 2 +- block/blk-rq-qos.h | 2 +- 6 files changed, 33 insertions(+), 52 deletions(-) delete mode 100644 block/blk-ioprio.h diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 3ae2aa557aef..f617f7ba311d 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -32,7 +32,6 @@ #include #include #include "blk.h" -#include "blk-ioprio.h" #include "blk-throttle.h" =20 /* @@ -1195,10 +1194,6 @@ int blkcg_init_queue(struct request_queue *q) if (preloaded) radix_tree_preload_end(); =20 - ret =3D blk_ioprio_init(q); - if (ret) - goto err_destroy_all; - ret =3D blk_throtl_init(q); if (ret) goto err_destroy_all; diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c index 2e7f10e1c03f..947aae54d295 100644 --- a/block/blk-ioprio.c +++ b/block/blk-ioprio.c @@ -17,7 +17,6 @@ #include #include #include -#include "blk-ioprio.h" #include "blk-rq-qos.h" =20 /** @@ -45,6 +44,7 @@ static const char *policy_name[] =3D { }; =20 static struct blkcg_policy ioprio_policy; +static struct rq_qos_ops blkcg_ioprio_ops; =20 /** * struct ioprio_blkg - Per (cgroup, request queue) data. @@ -216,15 +216,11 @@ static void blkcg_ioprio_exit(struct rq_qos *rqos) container_of(rqos, typeof(*blkioprio_blkg), rqos); =20 blkcg_deactivate_policy(rqos->q, &ioprio_policy); + rq_qos_deactivate(rqos); kfree(blkioprio_blkg); } =20 -static struct rq_qos_ops blkcg_ioprio_ops =3D { - .track =3D blkcg_ioprio_track, - .exit =3D blkcg_ioprio_exit, -}; - -int blk_ioprio_init(struct request_queue *q) +static int blk_ioprio_init(struct request_queue *q) { struct blk_ioprio *blkioprio_blkg; struct rq_qos *rqos; @@ -234,35 +230,48 @@ int blk_ioprio_init(struct request_queue *q) if (!blkioprio_blkg) return -ENOMEM; =20 + /* + * No need to worry ioprio_blkcg_from_css return NULL as + * the queue is frozen right now. + */ + rqos =3D &blkioprio_blkg->rqos; + rq_qos_activate(q, rqos, &blkcg_ioprio_ops); + ret =3D blkcg_activate_policy(q, &ioprio_policy); if (ret) { + rq_qos_deactivate(rqos); kfree(blkioprio_blkg); - return ret; } =20 - rqos =3D &blkioprio_blkg->rqos; - rqos->id =3D RQ_QOS_IOPRIO; - rqos->ops =3D &blkcg_ioprio_ops; - rqos->q =3D q; - - /* - * Registering the rq-qos policy after activating the blk-cgroup - * policy guarantees that ioprio_blkcg_from_bio(bio) !=3D NULL in the - * rq-qos callbacks. - */ - rq_qos_add(q, rqos); - - return 0; + return ret; } =20 +static struct rq_qos_ops blkcg_ioprio_ops =3D { + .name =3D "ioprio", + .track =3D blkcg_ioprio_track, + .exit =3D blkcg_ioprio_exit, + .init =3D blk_ioprio_init, +}; + static int __init ioprio_init(void) { - return blkcg_policy_register(&ioprio_policy); + int ret; + + ret =3D rq_qos_register(&blkcg_ioprio_ops); + if (ret) + return ret; + + ret =3D blkcg_policy_register(&ioprio_policy); + if (ret) + rq_qos_unregister(&blkcg_ioprio_ops); + + return ret; } =20 static void __exit ioprio_exit(void) { blkcg_policy_unregister(&ioprio_policy); + rq_qos_unregister(&blkcg_ioprio_ops); } =20 module_init(ioprio_init); diff --git a/block/blk-ioprio.h b/block/blk-ioprio.h deleted file mode 100644 index a7785c2f1aea..000000000000 --- a/block/blk-ioprio.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ - -#ifndef _BLK_IOPRIO_H_ -#define _BLK_IOPRIO_H_ - -#include - -struct request_queue; - -#ifdef CONFIG_BLK_CGROUP_IOPRIO -int blk_ioprio_init(struct request_queue *q); -#else -static inline int blk_ioprio_init(struct request_queue *q) -{ - return 0; -} -#endif - -#endif /* _BLK_IOPRIO_H_ */ diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 27ca6185ad59..a35f2d6dd422 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -825,10 +825,6 @@ void blk_mq_debugfs_unregister_sched(struct request_qu= eue *q) =20 static const char *rq_qos_id_to_name(enum rq_qos_id id) { - switch (id) { - case RQ_QOS_IOPRIO: - return "ioprio"; - } return "unknown"; } =20 diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index c43436c2ead1..03f2e654cd17 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -433,7 +433,7 @@ int rq_qos_register(struct rq_qos_ops *ops) goto out; } =20 - start =3D RQ_QOS_IOPRIO + 1; + start =3D 1; ret =3D idr_alloc(&rq_qos_idr, ops, start, INT_MAX, GFP_KERNEL); if (ret < 0) goto out; diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index ab95a366710d..5a26eb128456 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -14,7 +14,7 @@ struct blk_mq_debugfs_attr; =20 enum rq_qos_id { - RQ_QOS_IOPRIO, + RQ_QOS_UNUSED, }; =20 struct rq_wait { --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 718D4C433FE for ; Thu, 24 Feb 2022 09:09:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232562AbiBXJJq (ORCPT ); Thu, 24 Feb 2022 04:09:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232505AbiBXJJJ (ORCPT ); Thu, 24 Feb 2022 04:09:09 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64C501A1282; Thu, 24 Feb 2022 01:08:39 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id bx5so1440966pjb.3; Thu, 24 Feb 2022 01:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=AuluerhpzeQIcBXmxiBmKQ+X+SpLxPtw1drteUshKMY=; b=B2diqjSOxXtUCjEFhM9V1IP0uJtCxJ/TqFRZCDy2av2INUqUHZ1PxgCwcSIDErdVJf VDePKC4SNejNwqEI8EBvVTzNHqWQSSyAqZbLZdal2KKCxifyERQW0QsN8oNa1B82lV44 Z8XqIgBlONPQm5L/N2CGxKpV4VFeFsdGV+Zc8zSG6SWo+tniMocR1T5OiccJhiEsQozi 3CrWr1cR676duJPQIsEcTEv7tFu/mPiAov4OEubS2y5ZrNexWCkPfV6ID1CsAQkDSDcb yMsIH3imLIysxfuUL90osoYoUSMZplP9NP54UYy6jzV1etkv4h2w6EZr52g0M88R8VI2 O0iA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=AuluerhpzeQIcBXmxiBmKQ+X+SpLxPtw1drteUshKMY=; b=QmWkpnz8fJfpb+moKLmH2Fa9kzYxXP5TS9x4xjTsgNOeF5AkEkedA63Qzt2l0tPwDq Z3tH15w9XK0J9t78A4h0QVGnmX7FBSj/Xv9Pr/4YFiegfRuw6nnR/qbnCBfRHN9Sf9bM 8ZIqFB7pWz2gIc+7td0Hj6MuuNHP0ZSPsy+AHoizIsfS/Z8lciDyAtP1y+o0CG3lsugc 4Rgdk9BQLv6wgnPG75x+dswKkdes9TkvLwBU4yb/lRdW6un+Tasp96Q7dVn6Qv/G4jiL uXFjxxTFu2sTSsuOjRI05dg6GRqnqN/4yqZ/jnZM4zpA1vUJNMMzf7xI33plCm9iRB6o jrqw== X-Gm-Message-State: AOAM5319sUlK7xiA/f3tTD9FVG1/Uuha9hCylWR8F2sIMPcrWcXCW91P J49U0zuulL+dTV5QheCUpyI= X-Google-Smtp-Source: ABdhPJyKcGQ/MMv3EJApvBJPC0uD3mXlsGUvdxgYc5F8cVlPdCxKX9Nli4oqtFUeeuG9L/bm7W+tfQ== X-Received: by 2002:a17:902:e883:b0:14f:fa85:2af2 with SMTP id w3-20020a170902e88300b0014ffa852af2mr1629520plg.40.1645693718789; Thu, 24 Feb 2022 01:08:38 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:38 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 07/16] blk/rq-qos: get rid of unused interfaces of rqos Date: Thu, 24 Feb 2022 17:06:45 +0800 Message-Id: <20220224090654.54671-8-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" No functional changes here Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-mq-debugfs.c | 13 +-------- block/blk-rq-qos.h | 63 +----------------------------------------- 2 files changed, 2 insertions(+), 74 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index a35f2d6dd422..7e3c3cc1b1a9 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -823,11 +823,6 @@ void blk_mq_debugfs_unregister_sched(struct request_qu= eue *q) q->sched_debugfs_dir =3D NULL; } =20 -static const char *rq_qos_id_to_name(enum rq_qos_id id) -{ - return "unknown"; -} - void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) { debugfs_remove_recursive(rqos->debugfs_dir); @@ -837,12 +832,6 @@ void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqo= s) void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) { struct request_queue *q =3D rqos->q; - const char *dir_name; - - if (rqos->ops->name) - dir_name =3D rqos->ops->name; - else - dir_name =3D rq_qos_id_to_name(rqos->id); =20 if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) return; @@ -851,7 +840,7 @@ void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) q->rqos_debugfs_dir =3D debugfs_create_dir("rqos", q->debugfs_dir); =20 - rqos->debugfs_dir =3D debugfs_create_dir(dir_name, + rqos->debugfs_dir =3D debugfs_create_dir(rqos->ops->name, rqos->q->rqos_debugfs_dir); =20 debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs); diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 5a26eb128456..58aba16c7d32 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -13,10 +13,6 @@ =20 struct blk_mq_debugfs_attr; =20 -enum rq_qos_id { - RQ_QOS_UNUSED, -}; - struct rq_wait { wait_queue_head_t wait; atomic_t inflight; @@ -25,7 +21,7 @@ struct rq_wait { struct rq_qos { const struct rq_qos_ops *ops; struct request_queue *q; - enum rq_qos_id id; + int id; refcount_t ref; wait_queue_head_t waitq; bool dying; @@ -62,69 +58,12 @@ struct rq_depth { unsigned int default_depth; }; =20 -static inline struct rq_qos *rq_qos_id(struct request_queue *q, - enum rq_qos_id id) -{ - struct rq_qos *rqos; - for (rqos =3D q->rq_qos; rqos; rqos =3D rqos->next) { - if (rqos->id =3D=3D id) - break; - } - return rqos; -} - static inline void rq_wait_init(struct rq_wait *rq_wait) { atomic_set(&rq_wait->inflight, 0); init_waitqueue_head(&rq_wait->wait); } =20 -static inline void rq_qos_add(struct request_queue *q, struct rq_qos *rqos) -{ - /* - * No IO can be in-flight when adding rqos, so freeze queue, which - * is fine since we only support rq_qos for blk-mq queue. - * - * Reuse ->queue_lock for protecting against other concurrent - * rq_qos adding/deleting - */ - blk_mq_freeze_queue(q); - - spin_lock_irq(&q->queue_lock); - rqos->next =3D q->rq_qos; - q->rq_qos =3D rqos; - spin_unlock_irq(&q->queue_lock); - - blk_mq_unfreeze_queue(q); - - if (rqos->ops->debugfs_attrs) - blk_mq_debugfs_register_rqos(rqos); -} - -static inline void rq_qos_del(struct request_queue *q, struct rq_qos *rqos) -{ - struct rq_qos **cur; - - /* - * See comment in rq_qos_add() about freezing queue & using - * ->queue_lock. - */ - blk_mq_freeze_queue(q); - - spin_lock_irq(&q->queue_lock); - for (cur =3D &q->rq_qos; *cur; cur =3D &(*cur)->next) { - if (*cur =3D=3D rqos) { - *cur =3D rqos->next; - break; - } - } - spin_unlock_irq(&q->queue_lock); - - blk_mq_unfreeze_queue(q); - - blk_mq_debugfs_unregister_rqos(rqos); -} - int rq_qos_register(struct rq_qos_ops *ops); void rq_qos_unregister(struct rq_qos_ops *ops); void rq_qos_activate(struct request_queue *q, --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8950C433F5 for ; Thu, 24 Feb 2022 09:09:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232601AbiBXJJt (ORCPT ); Thu, 24 Feb 2022 04:09:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232545AbiBXJJL (ORCPT ); Thu, 24 Feb 2022 04:09:11 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C328B19DEBD; Thu, 24 Feb 2022 01:08:41 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id h17-20020a17090acf1100b001bc68ecce4aso5136076pju.4; Thu, 24 Feb 2022 01:08:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zpTkLEmJvFxi4VKhdqLWNaYMcorcu60fImPOUFH7K6M=; b=NMcz+1BsNPWq6mNOwq3KuY3XBZGPyq29cK8/rlh9MjKfPSKBz9IzXsF9YlJEyLKwB8 3liAc7Iuv7pyktDY7+6A5XowXB0raAkuNkHhR49nKs/K6qnAapEj0vpSwE0xnpxRwAhS kKlSfWh77COtdXCIPk5Y0CPqlrsnucdHvJwSHzB0N2wV7PdT4OHoir/KUu3cd91EpcMu FMKyLNtFKMLphu8NcQrGYO5gZuUJBiPhaT8+ZJiMSqCwBzwPpzqt2CGu7s3Hwxfba2gE 0uX1tJGo5fVGqde5YcyuOaWpSaY4MJ6TkoV9IftVMEtWVTA96uhHyJbPTDkOZg9cBZWk L7sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zpTkLEmJvFxi4VKhdqLWNaYMcorcu60fImPOUFH7K6M=; b=BdvHt8Npm0hxLQbX4Ul1YgB9ixySeYuNfZpb1e7oBZVswAFafbJpyWsSoN6ZeaXnjO iny5ObWSuj+p1vq9u8peHVJFzfOsRdYkkoTZHinlZPZQloQEFUnGnqMxRAKyOXExB75o JSWhJR4i+Qrn3U3WimGaDqE+SCGuLkEUNXhkFx6b65UofMa0B3Hn1GKLk+bu5hSk4YMg 4vUElsu1Pfv0/8S7f7hZP71rzG6BIRD0U9YxGmDTSj1+gEI98r5Qs9/ucEDZTV9AiSTk cEedxRXjspf9xou3FQWqDxedNMT1EyGLxsbflNi4GSHozFCrYqYYVYfqV2z5PdbwhUTh MOkQ== X-Gm-Message-State: AOAM530gC9o2niI4saLYW/NEIllboa0fg3/4XiA5O+soCkxtgd4v8uaG tv7ctef2kE4gxf5q1HcSLsk= X-Google-Smtp-Source: ABdhPJzDOiWYTFTN5CiYmYR350ZHz6g66bstb69UeiBp+sSPiTpA6JK9JjxTPhR49xgrrLO992IsQQ== X-Received: by 2002:a17:902:7b8d:b0:14f:f1c2:9ff4 with SMTP id w13-20020a1709027b8d00b0014ff1c29ff4mr1644281pll.54.1645693721140; Thu, 24 Feb 2022 01:08:41 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:40 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 08/16] blk/rq-qos: export the sysfs for switching qos Date: Thu, 24 Feb 2022 17:06:46 +0800 Message-Id: <20220224090654.54671-9-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" All of the blk-rq-qos policies has been changed to use the new interfaces. Thus we can export the sysfs interface, namely /sys/block/xxx/queue/qos Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-sysfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index c713d6b305cc..052b5f03fc73 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -572,6 +572,7 @@ QUEUE_RO_ENTRY(queue_max_segments, "max_segments"); QUEUE_RO_ENTRY(queue_max_integrity_segments, "max_integrity_segments"); QUEUE_RO_ENTRY(queue_max_segment_size, "max_segment_size"); QUEUE_RW_ENTRY(elv_iosched, "scheduler"); +QUEUE_RW_ENTRY(queue_qos, "qos"); =20 QUEUE_RO_ENTRY(queue_logical_block_size, "logical_block_size"); QUEUE_RO_ENTRY(queue_physical_block_size, "physical_block_size"); @@ -631,6 +632,7 @@ static struct attribute *queue_attrs[] =3D { &queue_max_integrity_segments_entry.attr, &queue_max_segment_size_entry.attr, &elv_iosched_entry.attr, + &queue_qos_entry.attr, &queue_hw_sector_size_entry.attr, &queue_logical_block_size_entry.attr, &queue_physical_block_size_entry.attr, --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6662DC433EF for ; Thu, 24 Feb 2022 09:09:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232605AbiBXJJv (ORCPT ); Thu, 24 Feb 2022 04:09:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52422 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232556AbiBXJJO (ORCPT ); Thu, 24 Feb 2022 04:09:14 -0500 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 301CD19E735; Thu, 24 Feb 2022 01:08:44 -0800 (PST) Received: by mail-pj1-x1032.google.com with SMTP id gi6so1456566pjb.1; Thu, 24 Feb 2022 01:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zmbcy8aiObBrWmKB+z0WqF9bDwGnayIFUcTM4Axg/fA=; b=LcNwVTnKozs+rJz/BMRG8xRvtwNcoVmqfMhAjUJh4orXsGpK2VOUDowIyx9TLZ7aMx cSLJ9GFHHplDBLZFFOU4RSsBUEED9+drOUOuBsRYiG/GwqHJhQeG3AlJkW1Ug7v6nRF0 Kdsm5CzR+hiwuZojBg3/hE7R81kGJacnyFI6/7iTWfr7iQs4JVGPQOyNqVFqVyZqrynk /kJxSTh2dj/N5zUzIbq0w8PNIsaPGiR+IfBgi8Ma0IqxMzR6mQztd3TakvBqzP+Fwr7V eKpwuCG1vZlegNyBlXiqj1smP1HPYjvGOtlmQl3OGE5q0QIYguv4vEfQeL8yI+z2orGl GLFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zmbcy8aiObBrWmKB+z0WqF9bDwGnayIFUcTM4Axg/fA=; b=Zf8gHDDJcwOaGH1IjYn3tMHO0CksPNgqjA7ioMAngaT/U7Witc644S+/u/23lMWh2/ zWRxowl7maBvWEq/XV5hKiXchwUiNGM6blFOj7Akrmu7GjDJ9ZuRmsPoL7FiSCS3Amwf qb9HsPSnawVhtRxhbzHbdeun/pwFAxyf8SCTDqTsJce//P9umLAsEoHTwiiyE0rhnJns EG0k9X/Dzz5u8B6F5LD0plBzT+cPZKi18CNpu5bs4JfjoXdevSVNB62F1Tk2ltEsyK3X wxCONOWId8lJ3Qos8Tm9fvET4aJIsmOsKlA/rfU6KLWvoTlLp/94hs6gzqvwuAiJWho7 YQeA== X-Gm-Message-State: AOAM5319gCUvv3LaF/hai6shWobtAdbSzpvNmusczvx53wwjkfAt51S0 4OV5Iv20aXt8D3G657RLItQ= X-Google-Smtp-Source: ABdhPJxCUvbTuavaIhEhy8khMEBaD44S/0B9g7uGRZ5bUJZ7Kr9SQZAN4J47OJOfWFvPjJ4Gsalr8w== X-Received: by 2002:a17:902:8d84:b0:14f:83f2:8c0d with SMTP id v4-20020a1709028d8400b0014f83f28c0dmr1752840plo.110.1645693723630; Thu, 24 Feb 2022 01:08:43 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:43 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 09/16] blk-wbt: show wbt_lat_us sysfs interface only when wbt is opened Date: Thu, 24 Feb 2022 17:06:47 +0800 Message-Id: <20220224090654.54671-10-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add 'wbt_lat_us' to block device' queue sysfs only when we open 'wbt' blk-rq-qos policy. And do some code cleanup as we needn't to export those wbt interfaces. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-sysfs.c | 71 ---------------- block/blk-wbt.c | 201 +++++++++++++++++++++++++++------------------- block/blk-wbt.h | 28 ------- block/blk.h | 6 ++ 4 files changed, 125 insertions(+), 181 deletions(-) diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 052b5f03fc73..1b321edd7ba7 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -20,12 +20,6 @@ #include "blk-wbt.h" #include "blk-throttle.h" =20 -struct queue_sysfs_entry { - struct attribute attr; - ssize_t (*show)(struct request_queue *, char *); - ssize_t (*store)(struct request_queue *, const char *, size_t); -}; - static ssize_t queue_var_show(unsigned long var, char *page) { @@ -47,19 +41,6 @@ queue_var_store(unsigned long *var, const char *page, si= ze_t count) return count; } =20 -static ssize_t queue_var_store64(s64 *var, const char *page) -{ - int err; - s64 v; - - err =3D kstrtos64(page, 10, &v); - if (err < 0) - return err; - - *var =3D v; - return 0; -} - static ssize_t queue_requests_show(struct request_queue *q, char *page) { return queue_var_show(q->nr_requests, page); @@ -461,56 +442,6 @@ static ssize_t queue_io_timeout_store(struct request_q= ueue *q, const char *page, return count; } =20 -static ssize_t queue_wb_lat_show(struct request_queue *q, char *page) -{ - if (!wbt_opened(q)) - return -EINVAL; - - return sprintf(page, "%llu\n", div_u64(wbt_get_min_lat(q), 1000)); -} - -static ssize_t queue_wb_lat_store(struct request_queue *q, const char *pag= e, - size_t count) -{ - ssize_t ret; - s64 val; - - ret =3D queue_var_store64(&val, page); - if (ret < 0) - return ret; - if (val < -1) - return -EINVAL; - - if (!wbt_opened(q)) { - ret =3D wbt_init(q); - if (ret) - return ret; - } - - if (val =3D=3D -1) - val =3D wbt_default_latency_nsec(q); - else if (val >=3D 0) - val *=3D 1000ULL; - - if (wbt_get_min_lat(q) =3D=3D val) - return count; - - /* - * Ensure that the queue is idled, in case the latency update - * ends up either enabling or disabling wbt completely. We can't - * have IO inflight if that happens. - */ - blk_mq_freeze_queue(q); - blk_mq_quiesce_queue(q); - - wbt_set_min_lat(q, val); - - blk_mq_unquiesce_queue(q); - blk_mq_unfreeze_queue(q); - - return count; -} - static ssize_t queue_wc_show(struct request_queue *q, char *page) { if (test_bit(QUEUE_FLAG_WC, &q->queue_flags)) @@ -604,7 +535,6 @@ QUEUE_RW_ENTRY(queue_wc, "write_cache"); QUEUE_RO_ENTRY(queue_fua, "fua"); QUEUE_RO_ENTRY(queue_dax, "dax"); QUEUE_RW_ENTRY(queue_io_timeout, "io_timeout"); -QUEUE_RW_ENTRY(queue_wb_lat, "wbt_lat_usec"); QUEUE_RO_ENTRY(queue_virt_boundary_mask, "virt_boundary_mask"); =20 #ifdef CONFIG_BLK_DEV_THROTTLING_LOW @@ -661,7 +591,6 @@ static struct attribute *queue_attrs[] =3D { &queue_wc_entry.attr, &queue_fua_entry.attr, &queue_dax_entry.attr, - &queue_wb_lat_entry.attr, &queue_poll_delay_entry.attr, &queue_io_timeout_entry.attr, #ifdef CONFIG_BLK_DEV_THROTTLING_LOW diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 44a920d83475..bbec3b394273 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -24,7 +24,9 @@ #include #include #include +#include =20 +#include "blk.h" #include "blk-wbt.h" #include "blk-rq-qos.h" =20 @@ -38,15 +40,6 @@ static inline struct rq_qos *wbt_rq_qos(struct request_q= ueue *q) return rq_qos_get(q, wbt_rqos_ops.id); } =20 -bool wbt_opened(struct request_queue *q) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - - rq_qos_put(rqos); - - return !!rqos; -} - static inline void wbt_clear_state(struct request *rq) { rq->wbt_flags =3D 0; @@ -438,33 +431,6 @@ static void wbt_update_limits(struct rq_wb *rwb) rwb_wake_all(rwb); } =20 -u64 wbt_get_min_lat(struct request_queue *q) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - u64 nsec; - - if (!rqos) - return 0; - - nsec =3D RQWB(rqos)->min_lat_nsec; - rq_qos_put(rqos); - - return nsec; -} - -void wbt_set_min_lat(struct request_queue *q, u64 val) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - - if (!rqos) - return; - RQWB(rqos)->min_lat_nsec =3D val; - RQWB(rqos)->enable_state =3D WBT_STATE_ON_MANUAL; - wbt_update_limits(RQWB(rqos)); - rq_qos_put(rqos); -} - - static bool close_io(struct rq_wb *rwb) { const unsigned long now =3D jiffies; @@ -660,32 +626,7 @@ void wbt_set_write_cache(struct request_queue *q, bool= write_cache_on) } } =20 -/* - * Enable wbt if defaults are configured that way - */ -void wbt_enable_default(struct request_queue *q) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - - /* Throttling already enabled? */ - if (rqos) { - if (RQWB(rqos)->enable_state =3D=3D WBT_STATE_OFF_DEFAULT) - RQWB(rqos)->enable_state =3D 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); - -u64 wbt_default_latency_nsec(struct request_queue *q) +static u64 wbt_default_latency_nsec(struct request_queue *q) { /* * We default to 2msec for non-rotational storage, and 75msec @@ -716,7 +657,67 @@ static void wbt_queue_depth_changed(struct rq_qos *rqo= s) wbt_update_limits(RQWB(rqos)); } =20 -static void wbt_exit(struct rq_qos *rqos) +static ssize_t wbt_lat_show(struct request_queue *q, char *page) +{ + struct rq_qos *rqos =3D wbt_rq_qos(q); + ssize_t ret; + + ret =3D sprintf(page, "%llu\n", div_u64(RQWB(rqos)->min_lat_nsec, 1000)); + + rq_qos_put(rqos); + + return ret; +} + +static ssize_t wbt_lat_store(struct request_queue *q, const char *page, + size_t count) +{ + struct rq_qos *rqos; + struct rq_wb *rwb; + ssize_t ret; + s64 val; + + ret =3D kstrtos64(page, 10, &val); + if (ret < 0) + return ret; + + if (val < -1) + return -EINVAL; + + if (val =3D=3D -1) + val =3D wbt_default_latency_nsec(q); + else if (val >=3D 0) + val *=3D 1000ULL; + + rqos =3D wbt_rq_qos(q); + rwb =3D RQWB(rqos); + + if (rwb->min_lat_nsec =3D=3D val) + goto out; + /* + * Ensure that the queue is idled, in case the latency update + * ends up either enabling or disabling wbt completely. We can't + * have IO inflight if that happens. + */ + blk_mq_freeze_queue(q); + blk_mq_quiesce_queue(q); + + rwb->min_lat_nsec =3D val; + rwb->enable_state =3D WBT_STATE_ON_MANUAL; + wbt_update_limits(rwb); + + blk_mq_unquiesce_queue(q); + blk_mq_unfreeze_queue(q); + +out: + rq_qos_put(rqos); + return count; +} + +static struct queue_sysfs_entry wbt_attr =3D + __ATTR(wbt_lat_usec, 0644, wbt_lat_show, wbt_lat_store); + +static void __wbt_exit(struct rq_qos *rqos) { struct rq_wb *rwb =3D RQWB(rqos); struct request_queue *q =3D rqos->q; @@ -727,6 +728,12 @@ static void wbt_exit(struct rq_qos *rqos) kfree(rwb); } =20 +static void wbt_exit(struct rq_qos *rqos) +{ + sysfs_remove_file(&rqos->q->kobj, &wbt_attr.attr); + __wbt_exit(rqos); +} + /* * Disable wbt, if enabled by default. */ @@ -835,26 +842,10 @@ static const struct blk_mq_debugfs_attr wbt_debugfs_a= ttrs[] =3D { }; #endif =20 -static struct rq_qos_ops wbt_rqos_ops =3D { - .name =3D "wbt", - .throttle =3D wbt_wait, - .issue =3D wbt_issue, - .track =3D wbt_track, - .requeue =3D wbt_requeue, - .done =3D wbt_done, - .cleanup =3D wbt_cleanup, - .queue_depth_changed =3D wbt_queue_depth_changed, - .exit =3D wbt_exit, - .init =3D wbt_init, -#ifdef CONFIG_BLK_DEBUG_FS - .debugfs_attrs =3D wbt_debugfs_attrs, -#endif -}; - -int wbt_init(struct request_queue *q) +static int wbt_init(struct request_queue *q) { struct rq_wb *rwb; - int i; + int i, ret; =20 rwb =3D kzalloc(sizeof(*rwb), GFP_KERNEL); if (!rwb) @@ -886,9 +877,54 @@ int wbt_init(struct request_queue *q) wbt_queue_depth_changed(&rwb->rqos); wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); =20 - return 0; + ret =3D sysfs_create_file(&q->kobj, &wbt_attr.attr); + if (ret < 0) + __wbt_exit(&rwb->rqos); + + return ret; } =20 +static struct rq_qos_ops wbt_rqos_ops =3D { + .name =3D "wbt", + .throttle =3D wbt_wait, + .issue =3D wbt_issue, + .track =3D wbt_track, + .requeue =3D wbt_requeue, + .done =3D wbt_done, + .cleanup =3D wbt_cleanup, + .queue_depth_changed =3D wbt_queue_depth_changed, + .exit =3D wbt_exit, + .init =3D wbt_init, +#ifdef CONFIG_BLK_DEBUG_FS + .debugfs_attrs =3D wbt_debugfs_attrs, +#endif +}; + +/* + * Enable wbt if defaults are configured that way + */ +void wbt_enable_default(struct request_queue *q) +{ + struct rq_qos *rqos =3D wbt_rq_qos(q); + + /* Throttling already enabled? */ + if (rqos) { + if (RQWB(rqos)->enable_state =3D=3D WBT_STATE_OFF_DEFAULT) + RQWB(rqos)->enable_state =3D 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); @@ -898,5 +934,6 @@ static __exit void wbt_mod_exit(void) { return rq_qos_unregister(&wbt_rqos_ops); } + module_init(wbt_mod_init); module_exit(wbt_mod_exit); diff --git a/block/blk-wbt.h b/block/blk-wbt.h index f128dcf662db..b9ed3f373b5a 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -88,32 +88,16 @@ static inline unsigned int wbt_inflight(struct rq_wb *r= wb) =20 #ifdef CONFIG_BLK_WBT =20 -bool wbt_opened(struct request_queue *q); -int wbt_init(struct request_queue *); void wbt_disable_default(struct request_queue *); void wbt_enable_default(struct request_queue *); =20 -u64 wbt_get_min_lat(struct request_queue *q); -void wbt_set_min_lat(struct request_queue *q, u64 val); - void wbt_set_write_cache(struct request_queue *, bool); =20 -u64 wbt_default_latency_nsec(struct request_queue *); - #else =20 -bool wbt_opened(struct request_queue *q) -{ - return false; -} - static inline void wbt_track(struct request *rq, enum wbt_flags flags) { } -static inline int wbt_init(struct request_queue *q) -{ - return -EINVAL; -} static inline void wbt_disable_default(struct request_queue *q) { } @@ -123,18 +107,6 @@ static inline void wbt_enable_default(struct request_q= ueue *q) static inline void wbt_set_write_cache(struct request_queue *q, bool wc) { } -static inline u64 wbt_get_min_lat(struct request_queue *q) -{ - return 0; -} -static inline void wbt_set_min_lat(struct request_queue *q, u64 val) -{ -} -static inline u64 wbt_default_latency_nsec(struct request_queue *q) -{ - return 0; -} - #endif /* CONFIG_BLK_WBT */ =20 #endif diff --git a/block/blk.h b/block/blk.h index 1a314257b6a3..2ec7510c080c 100644 --- a/block/blk.h +++ b/block/blk.h @@ -14,6 +14,12 @@ struct elevator_type; =20 extern struct dentry *blk_debugfs_root; =20 +struct queue_sysfs_entry { + struct attribute attr; + ssize_t (*show)(struct request_queue *, char *); + ssize_t (*store)(struct request_queue *, const char *, size_t); +}; + struct blk_flush_queue { unsigned int flush_pending_idx:1; unsigned int flush_running_idx:1; --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20E30C4332F for ; Thu, 24 Feb 2022 09:09:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232628AbiBXJJ6 (ORCPT ); Thu, 24 Feb 2022 04:09:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232587AbiBXJJW (ORCPT ); Thu, 24 Feb 2022 04:09:22 -0500 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C53541A02B8; Thu, 24 Feb 2022 01:08:46 -0800 (PST) Received: by mail-pj1-x1031.google.com with SMTP id ge19-20020a17090b0e1300b001bcca16e2e7so716745pjb.3; Thu, 24 Feb 2022 01:08:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zLpZo5QCnWe/V5DcsLs28NYLJFV4odvnBRSD6UeNM/k=; b=OF46hEzKbJzGkAj4LQoG5UF+FfqdwWxtgkEjFPUrwxsFza0+Vl/4gUMqQ60whMF5Lh LGF86o9/iSw5LpN1Ho8zMgIis3bKWqat8gPpF5QJfP7v53nTpGRSzuMR7sUoOIAIVRCK T/ko1ank720shMFRAJe5KJfM4b8zU1utgR1Z4dileRtVb+96EO9x2/ZpFMjw1gbt+wWI 4ng2klWDKTGyYw/NlOy86X0PEw6PwuwW7EuVkcb9r0MqP/Zu2Cizgw1TJVpv+V0+oaXm iNcHgpRyt7GKbEih4K+6Vi/e0lhbr6XIe4ED6pbRZqhZ4h2PjtwmaIAjSrf2DhdEUtPW i5bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zLpZo5QCnWe/V5DcsLs28NYLJFV4odvnBRSD6UeNM/k=; b=r0jD/rFF+39YBfU5+yGIrj8m/cs1WZxb8N51r6TqrKvqTPwHJM2wJwqI9ndNhp1I9Y bpPMV8Y1iPlSO+VHGRORaPl/UVE6tFLIPUna5lzJ76kO/GUJ72j6TR0VhC2h33/4GZDZ sM7JQ5DxhkSqtpz5Dx38hMWoyqA7DxN+/CGwKRaRaCP5Pm5YFQS4LXB0zHbtYrmFbCwA 7osh+iBSLcLXpfPYj1/J6NlcS3IKqkYtdcLLTtai9wC4RcRmYZl3DxaY3M+WYINhGCWi 43pLHLTC/t09uHkJbJ5MpL06zhecVosJk8GKrjqKeVUYXysxmCJ1L1uutqgNGP5eelUK T4oQ== X-Gm-Message-State: AOAM5314ye399mySlbFb/KjF9YJPbNEOblTvxG4Gp5jV3APmqa+PrKXq RGfgCUlQ8CFU/7G6xf3607Y= X-Google-Smtp-Source: ABdhPJzUm7Qb9J3IkPsDs5/peIEyz+A8FOydKrLVSPohYNN7luJgq+EMSFe97grVj6mM502usgOqTQ== X-Received: by 2002:a17:902:854a:b0:14e:e053:c8b3 with SMTP id d10-20020a170902854a00b0014ee053c8b3mr1936118plo.8.1645693726272; Thu, 24 Feb 2022 01:08:46 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:45 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 10/16] blk-wbt: get rid of wbt_enable/disable_default() Date: Thu, 24 Feb 2022 17:06:48 +0800 Message-Id: <20220224090654.54671-11-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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) --- 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" =20 #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, st= ruct elevator_type *e) bfq_init_root_group(bfqd->root_group, bfqd); bfq_init_entity(&bfqd->oom_bfqq.entity, bfqd->root_group); =20 - wbt_disable_default(q); return 0; =20 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" =20 static ssize_t queue_var_show(unsigned long var, char *page) @@ -810,7 +810,6 @@ int blk_register_queue(struct gendisk *disk) } =20 blk_queue_flag_set(QUEUE_FLAG_REGISTERED, q); - wbt_enable_default(q); blk_throtl_register_queue(q); =20 /* 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 { =20 static inline bool rwb_enabled(struct rq_wb *rwb) { - return rwb && rwb->enable_state !=3D WBT_STATE_OFF_DEFAULT && - rwb->wb_normal !=3D 0; + return rwb && rwb->wb_normal !=3D 0; } =20 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, c= onst char *page, blk_mq_quiesce_queue(q); =20 rwb->min_lat_nsec =3D val; - rwb->enable_state =3D WBT_STATE_ON_MANUAL; wbt_update_limits(rwb); =20 blk_mq_unquiesce_queue(q); @@ -734,26 +732,6 @@ static void wbt_exit(struct rq_qos *rqos) __wbt_exit(rqos); } =20 -/* - * Disable wbt, if enabled by default. - */ -void wbt_disable_default(struct request_queue *q) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - struct rq_wb *rwb; - - if (!rqos) - return; - - rwb =3D RQWB(rqos); - if (rwb->enable_state =3D=3D WBT_STATE_ON_DEFAULT) { - blk_stat_deactivate(rwb->cb); - rwb->enable_state =3D 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 s= eq_file *m) return 0; } =20 -static int wbt_enabled_show(void *data, struct seq_file *m) -{ - struct rq_qos *rqos =3D data; - struct rq_wb *rwb =3D 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 =3D data; @@ -831,7 +800,6 @@ static int wbt_background_show(void *data, struct seq_f= ile *m) =20 static const struct blk_mq_debugfs_attr wbt_debugfs_attrs[] =3D { {"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) =20 rwb->last_comp =3D rwb->last_issue =3D jiffies; rwb->win_nsec =3D RWB_WINDOW_NSEC; - rwb->enable_state =3D WBT_STATE_ON_DEFAULT; rwb->wc =3D 1; rwb->rq_depth.default_depth =3D RWB_DEF_DEPTH; =20 @@ -900,31 +867,6 @@ static struct rq_qos_ops wbt_rqos_ops =3D { #endif }; =20 -/* - * Enable wbt if defaults are configured that way - */ -void wbt_enable_default(struct request_queue *q) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - - /* Throttling already enabled? */ - if (rqos) { - if (RQWB(rqos)->enable_state =3D=3D WBT_STATE_OFF_DEFAULT) - RQWB(rqos)->enable_state =3D 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, }; =20 -/* - * Enable states. Either off, or on by default (done at init time), - * or on through manual setup in sysfs. - */ -enum { - WBT_STATE_ON_DEFAULT =3D 1, - WBT_STATE_ON_MANUAL =3D 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 */ =20 - 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 *rw= b) return ret; } =20 - #ifdef CONFIG_BLK_WBT =20 -void wbt_disable_default(struct request_queue *); -void wbt_enable_default(struct request_queue *); - void wbt_set_write_cache(struct request_queue *, bool); =20 #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" =20 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); =20 e->registered =3D 0; - /* Re-enable throttling in case elevator disabled it */ - wbt_enable_default(q); } } =20 --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE6B5C433EF for ; Thu, 24 Feb 2022 09:09:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231548AbiBXJKC (ORCPT ); Thu, 24 Feb 2022 04:10:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232594AbiBXJJX (ORCPT ); Thu, 24 Feb 2022 04:09:23 -0500 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C8571A12B9; Thu, 24 Feb 2022 01:08:48 -0800 (PST) Received: by mail-pj1-x1035.google.com with SMTP id m22so1481892pja.0; Thu, 24 Feb 2022 01:08:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pzQXvbfFL7dPzEr5ZOm4Q64kxcQtnZEvdiaZ7+tJ8ec=; b=Mn9liH/ZVdqXmUvXSP/ACWUY8hIIjhlf3+QrTVNAfYWtfdOXvMevFq6rZgpe//EIm0 ic6v3nLgBh7km/UHTNz7BwMZ/jY62XfL0wcZm5tEhcqlQLgbtdcHPOFzLUC6JZN0WhGu 9Hv05jH9aM5V+5pZgJCRVfLxx5dVReZDKfbqhWfnbvABFqmA0T11LJJKIqfBp+gR4RUV LzH4h9Ga8hYBxvUXwRvX3kxxnk2+GHnXipl7fMVd0v66CEkfbWCZU8nItK3O36bd8/I4 oOllakomcY2Z2d3qZeHSbBb2ThbT6VMHoPZrVlBS27QVpfgVoQ8cwRAMBwX18fXh4wSl DXnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pzQXvbfFL7dPzEr5ZOm4Q64kxcQtnZEvdiaZ7+tJ8ec=; b=1eZDHuZGFPqr5p4K0rMdW5QKS/1/r6dxU6njxABcFMP0OukdkcVv9QGwoG1sQaFEnJ GHGJb2JgKeqwNYs24/s0Gx5mUBInaw25WKNx15MqKCg0vBKiNcnWrDP6azjkfKAh9brS FkB2GTYuA+h1AythN5B26em6nsRcBLfQMTZdFJCizH0TR+sPTKckRF3zZZ2dKm/Lu+BL brL+geRdthYdLn+EmKtxg+GHGNmF6Uumw2iNQQ8I+xMCjMdnnhD84xC+36Oddd4nSygO U/7oYaOrtthSVA62UFoEIUBoCmICfOfWAixbx1WWKV2ccL3Vb1MahvBIRIIBFG0vMzX2 wRgA== X-Gm-Message-State: AOAM530O7vyuDcSUtB/YJdOnmHYSipqRHZkI8GDlJtl+A9ELBnEJjHIP KwsYtmsjJrIVWV+N4P9Zx5iP3CH51ALxmg== X-Google-Smtp-Source: ABdhPJxFxz7XSxjsfqBQvxvGQ05DxwfhH16OKljzey8Xcmjvsy6YbvLehwBhjb97e+SnQH3nqlXfDw== X-Received: by 2002:a17:903:2311:b0:14e:eb4f:4559 with SMTP id d17-20020a170903231100b0014eeb4f4559mr1900727plh.138.1645693728573; Thu, 24 Feb 2022 01:08:48 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:48 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 11/16] blk/rq-qos: get rid of debugfs register in blk_mq_debugfs_register Date: Thu, 24 Feb 2022 17:06:49 +0800 Message-Id: <20220224090654.54671-12-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is not any enabled rqos policy when queue is initialized, get rid of the coding for registering debugfs. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-mq-debugfs.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 7e3c3cc1b1a9..4c9dafd16a08 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -726,18 +726,6 @@ void blk_mq_debugfs_register(struct request_queue *q) if (q->elevator && !hctx->sched_debugfs_dir) blk_mq_debugfs_register_sched_hctx(q, hctx); } - - if (q->rq_qos) { - struct rq_qos *rqos =3D q->rq_qos; - /* - * Queue has not been registered right now, it is safe to - * iterate the rqos w/o lock - */ - while (rqos) { - blk_mq_debugfs_register_rqos(rqos); - rqos =3D rqos->next; - } - } } =20 void blk_mq_debugfs_unregister(struct request_queue *q) --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7A0FC433F5 for ; Thu, 24 Feb 2022 09:09:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232716AbiBXJKL (ORCPT ); Thu, 24 Feb 2022 04:10:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232643AbiBXJJo (ORCPT ); Thu, 24 Feb 2022 04:09:44 -0500 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B82E11A58EA; Thu, 24 Feb 2022 01:08:51 -0800 (PST) Received: by mail-pl1-x632.google.com with SMTP id e13so1150060plh.3; Thu, 24 Feb 2022 01:08:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=vmaXXXHQ/i9EKjoTmBwkF1G8tSqW4N88V6hDi2C1HD4=; b=WllXDIs36ZGrqgYryRhKFoGDVLxNIPINwv2Zi90yrKkz5EbSNgByCMuJ+sgA59vqnp 5dx71I2ov1cHh0W7QNsCqVRE8Q9JnYKrh/F4pygfB6qbbZkY9SmB46DUyet8jcxwOsVx nJIUnA6CAkb65lMkE1fWgVZjn+rA3AcTY/a1abM0nZy4J5oRSLdOjmc8nM++SxdkdgMR lY4EFIv+mROsTXCNymkXFsob7MpIFXWd6HvnrkJWvRPM0RFiG2E60cu29EvHuw8O4Xk9 sbmRKBW6arYUHzX8MBV8/S980aftF+d1PZEJTXB+6tQjnJlObjAA6Mp04BNQ1cHSluKx lE6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=vmaXXXHQ/i9EKjoTmBwkF1G8tSqW4N88V6hDi2C1HD4=; b=K0SD9+g5Xlyt6YCfRYfLex6BWN0gFXf7kW0lW1hiYDszDk29mCV8HV0wuvnRWL6VzX apKZhHR/xor+AxXsaKGFxsrZGjqkYoTU7jadjKz4/P2ibg9fR8oMFU2qEwBoN6uEcbqQ OaS6gW9HCELDQr7oLY6H+PQbzvS3xEnm6wXppQnXd2sMTkoKv4fJSd667ErRRi2a+M71 ncL7zF7U7JKCGimg8gVFmIdVbjqLfOaLSgvivtnqERg+fmmoEbqyppIm54DUzvUDkBs4 f3s+WK7vh9+S9OmDJW3mmV7X6nB89t66ufv7TqPRJ52hiv6AW74RFv/+5tAoIY/34Pa9 ykqw== X-Gm-Message-State: AOAM531X+msPq3wHsDn6Mn1QTlkJ2I3PoqrQDo+BskNkV8mkwJRKfSYa XFfCVoXMyd/NCAMUkXE2CIaLEn3wwuXZyA== X-Google-Smtp-Source: ABdhPJyZ5JcKXcufTNixaR7yYQQ8MLaW9hd9LGIlINMFtjycdxiT3SSTgVnP9PPAF8kueMeyYylhHQ== X-Received: by 2002:a17:902:d88f:b0:14d:696e:949f with SMTP id b15-20020a170902d88f00b0014d696e949fmr1651500plz.8.1645693731092; Thu, 24 Feb 2022 01:08:51 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:50 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 12/16] blk/rq-qos: change queue_depth_changed to setting_changed Date: Thu, 24 Feb 2022 17:06:50 +0800 Message-Id: <20220224090654.54671-13-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Change the callback .queue_depth_changed() to .setting_changed(). Then all of the queue setting changes can be involved. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-iocost.c | 4 ++-- block/blk-rq-qos.c | 6 +++--- block/blk-rq-qos.h | 8 ++++---- block/blk-settings.c | 2 +- block/blk-wbt.c | 12 +++++++----- 5 files changed, 17 insertions(+), 15 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 886c03383444..ad1d4d9762bd 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -2793,7 +2793,7 @@ static void ioc_rqos_done(struct rq_qos *rqos, struct= request *rq) put_cpu_ptr(ccs); } =20 -static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos) +static void ioc_rqos_setting_changed(struct rq_qos *rqos) { struct ioc *ioc =3D rqos_to_ioc(rqos); =20 @@ -2885,7 +2885,7 @@ static struct rq_qos_ops ioc_rqos_ops =3D { .merge =3D ioc_rqos_merge, .done_bio =3D ioc_rqos_done_bio, .done =3D ioc_rqos_done, - .queue_depth_changed =3D ioc_rqos_queue_depth_changed, + .setting_changed =3D ioc_rqos_setting_changed, .exit =3D ioc_rqos_exit, .init =3D blk_iocost_init, }; diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 03f2e654cd17..236ecb2af845 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -104,11 +104,11 @@ void __rq_qos_done_bio(struct rq_qos *rqos, struct bi= o *bio) } while (rqos); } =20 -void __rq_qos_queue_depth_changed(struct rq_qos *rqos) +void __rq_qos_setting_changed(struct rq_qos *rqos) { do { - if (rqos->ops->queue_depth_changed) - rqos->ops->queue_depth_changed(rqos); + if (rqos->ops->setting_changed) + rqos->ops->setting_changed(rqos); rqos =3D rqos->next; } while (rqos); } diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 58aba16c7d32..3d7df14edde3 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -42,7 +42,7 @@ struct rq_qos_ops { void (*done)(struct rq_qos *, struct request *); void (*done_bio)(struct rq_qos *, struct bio *); void (*cleanup)(struct rq_qos *, struct bio *); - void (*queue_depth_changed)(struct rq_qos *); + void (*setting_changed)(struct rq_qos *); void (*exit)(struct rq_qos *); int (*init)(struct request_queue *); const struct blk_mq_debugfs_attr *debugfs_attrs; @@ -94,7 +94,7 @@ void __rq_qos_throttle(struct rq_qos *rqos, struct bio *b= io); void __rq_qos_track(struct rq_qos *rqos, struct request *rq, struct bio *b= io); void __rq_qos_merge(struct rq_qos *rqos, struct request *rq, struct bio *b= io); void __rq_qos_done_bio(struct rq_qos *rqos, struct bio *bio); -void __rq_qos_queue_depth_changed(struct rq_qos *rqos); +void __rq_qos_setting_changed(struct rq_qos *rqos); =20 static inline void rq_qos_cleanup(struct request_queue *q, struct bio *bio) { @@ -152,7 +152,7 @@ static inline void rq_qos_merge(struct request_queue *q= , struct request *rq, __rq_qos_merge(q->rq_qos, rq, bio); } =20 -static inline void rq_qos_queue_depth_changed(struct request_queue *q) +static inline void rq_qos_setting_changed(struct request_queue *q) { /* * It is called by external module, protect the rqos list with @@ -160,7 +160,7 @@ static inline void rq_qos_queue_depth_changed(struct re= quest_queue *q) */ mutex_lock(&q->sysfs_lock); if (q->rq_qos) - __rq_qos_queue_depth_changed(q->rq_qos); + __rq_qos_setting_changed(q->rq_qos); mutex_unlock(&q->sysfs_lock); } =20 diff --git a/block/blk-settings.c b/block/blk-settings.c index b880c70e22e4..bceb1925e978 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -777,7 +777,7 @@ EXPORT_SYMBOL(blk_queue_update_dma_alignment); void blk_set_queue_depth(struct request_queue *q, unsigned int depth) { q->queue_depth =3D depth; - rq_qos_queue_depth_changed(q); + rq_qos_setting_changed(q); } EXPORT_SYMBOL(blk_set_queue_depth); =20 diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 6c0a85ddb107..3a3a683009c4 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -650,10 +650,12 @@ static int wbt_data_dir(const struct request *rq) return -1; } =20 -static void wbt_queue_depth_changed(struct rq_qos *rqos) +static void wbt_setting_changed(struct rq_qos *rqos) { - RQWB(rqos)->rq_depth.queue_depth =3D blk_queue_depth(rqos->q); - wbt_update_limits(RQWB(rqos)); + if (RQWB(rqos)->rq_depth.queue_depth !=3D blk_queue_depth(rqos->q)) { + RQWB(rqos)->rq_depth.queue_depth =3D blk_queue_depth(rqos->q); + wbt_update_limits(RQWB(rqos)); + } } =20 static ssize_t wbt_lat_show(struct request_queue *q, char *page) @@ -841,7 +843,7 @@ static int wbt_init(struct request_queue *q) =20 rwb->min_lat_nsec =3D wbt_default_latency_nsec(q); =20 - wbt_queue_depth_changed(&rwb->rqos); + wbt_setting_changed(&rwb->rqos); wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); =20 ret =3D sysfs_create_file(&q->kobj, &wbt_attr.attr); @@ -859,7 +861,7 @@ static struct rq_qos_ops wbt_rqos_ops =3D { .requeue =3D wbt_requeue, .done =3D wbt_done, .cleanup =3D wbt_cleanup, - .queue_depth_changed =3D wbt_queue_depth_changed, + .setting_changed =3D wbt_setting_changed, .exit =3D wbt_exit, .init =3D wbt_init, #ifdef CONFIG_BLK_DEBUG_FS --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2ED7C433EF for ; Thu, 24 Feb 2022 09:09:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232675AbiBXJKG (ORCPT ); Thu, 24 Feb 2022 04:10:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232651AbiBXJJo (ORCPT ); Thu, 24 Feb 2022 04:09:44 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E3E819E0A5; Thu, 24 Feb 2022 01:08:54 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id z16so1328493pfh.3; Thu, 24 Feb 2022 01:08:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hDQsn9Et1mc617/JcmOs/nm/EITJxazgEKeIY7DZHEc=; b=AYqn9zvsWXt6SlmmpusdHONKfDhXfLeTtIgNOIRE8rITdkQMmJa6InC1EOUvTFCBGJ f1t23LHEkeHf/OrcyXv+05XVM2mTSe60zxf+RAM+Cjn5P1DA8qNwhuh6FZ1l+Q+EgpYB 66k6/8SU9a9Ef3U1HxMZVi5RH2cmALp34/P4If0BBXCoP8exsKircnskxezz70Ya2xCx R9IXFaayHQWbD1fuAopsMeOcNqieW4uuvE8wtrb8re011UvLI5CDTcpuTPpge3avPfUy mkriR9ntBZjgCWEAYoARFoO+Ohb+24cy5SEQd/gNlTB70Jb3PRrxPJMcwzGUDk3SRkfJ RZnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hDQsn9Et1mc617/JcmOs/nm/EITJxazgEKeIY7DZHEc=; b=xTiYs8cH3McGhpYqmAxJqJD+FULFcyFValf17hdPks8f3ETU1yJRCksULg0oFO8tWD +84cOodJVniprQx9N4nFzWc4RNdYWZGZUvb926dv3EEB3y0ZJ2VhiM+RwOUgQ4N42WPo wM8WpDf+fP5pVosl7+P7wvllryF5AyTf0tcyPHv/hm1qIfHm5xN9iuu1jqExt4M1m3+9 +nST9td2daMBkyCxQ5Fnl/U/a7vdTRFYW/Yv04s28JEvM2Au+cyMfG84jvSusEvwkN0b Tf/CyS/jIVfEB/S0saeViZrtTWXI646dOHF95C+VwJ0ZFsnJTHL+OzS8vjRr3xxD2G6G SF/A== X-Gm-Message-State: AOAM530TaGHTlpYzVGjl2YWoUrvWmoLZnW3UMAoa41ErG1G5RVNyuLo6 7QkCD8rRmJceoCniqqqIc60= X-Google-Smtp-Source: ABdhPJzxPBzdZB7shuFUOj6z0/OMnu1A/4jYFIhVA0x1FOsKqiDw74qlk8e6Fk58UvQMiSxuH71FuA== X-Received: by 2002:a62:e112:0:b0:4e1:301e:9faa with SMTP id q18-20020a62e112000000b004e1301e9faamr1956157pfh.56.1645693733778; Thu, 24 Feb 2022 01:08:53 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:53 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 13/16] blk-wbt: move cache setting to rq_qos_setting_changed() Date: Thu, 24 Feb 2022 17:06:51 +0800 Message-Id: <20220224090654.54671-14-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Move cache setting to rq_qos_setting_changed then we can avoid to export a standalone wbt interface to blk_queue_write_cache(). Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-settings.c | 4 ++-- block/blk-wbt.c | 13 ++----------- block/blk-wbt.h | 7 ------- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index bceb1925e978..124bf5cc623f 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -16,7 +16,7 @@ #include =20 #include "blk.h" -#include "blk-wbt.h" +#include "blk-rq-qos.h" =20 void blk_queue_rq_timeout(struct request_queue *q, unsigned int timeout) { @@ -800,7 +800,7 @@ void blk_queue_write_cache(struct request_queue *q, boo= l wc, bool fua) else blk_queue_flag_clear(QUEUE_FLAG_FUA, q); =20 - wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); + rq_qos_setting_changed(q); } EXPORT_SYMBOL_GPL(blk_queue_write_cache); =20 diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 3a3a683009c4..83e05417e25f 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -615,16 +615,6 @@ static void wbt_requeue(struct rq_qos *rqos, struct re= quest *rq) } } =20 -void wbt_set_write_cache(struct request_queue *q, bool write_cache_on) -{ - struct rq_qos *rqos =3D wbt_rq_qos(q); - - if (rqos) { - RQWB(rqos)->wc =3D write_cache_on; - rq_qos_put(rqos); - } -} - static u64 wbt_default_latency_nsec(struct request_queue *q) { /* @@ -656,6 +646,7 @@ static void wbt_setting_changed(struct rq_qos *rqos) RQWB(rqos)->rq_depth.queue_depth =3D blk_queue_depth(rqos->q); wbt_update_limits(RQWB(rqos)); } + RQWB(rqos)->wc =3D test_bit(QUEUE_FLAG_WC, &rqos->q->queue_flags); } =20 static ssize_t wbt_lat_show(struct request_queue *q, char *page) @@ -844,7 +835,7 @@ static int wbt_init(struct request_queue *q) rwb->min_lat_nsec =3D wbt_default_latency_nsec(q); =20 wbt_setting_changed(&rwb->rqos); - wbt_set_write_cache(q, test_bit(QUEUE_FLAG_WC, &q->queue_flags)); + rwb->wc =3D test_bit(QUEUE_FLAG_WC, &q->queue_flags); =20 ret =3D sysfs_create_file(&q->kobj, &wbt_attr.attr); if (ret < 0) diff --git a/block/blk-wbt.h b/block/blk-wbt.h index fe26f78390bd..eb837dfd0ace 100644 --- a/block/blk-wbt.h +++ b/block/blk-wbt.h @@ -74,17 +74,10 @@ static inline unsigned int wbt_inflight(struct rq_wb *r= wb) } =20 #ifdef CONFIG_BLK_WBT - -void wbt_set_write_cache(struct request_queue *, bool); - #else - static inline void wbt_track(struct request *rq, enum wbt_flags flags) { } -static inline void wbt_set_write_cache(struct request_queue *q, bool wc) -{ -} #endif /* CONFIG_BLK_WBT */ =20 #endif --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 28ADEC433EF for ; Thu, 24 Feb 2022 09:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232683AbiBXJKR (ORCPT ); Thu, 24 Feb 2022 04:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232676AbiBXJJx (ORCPT ); Thu, 24 Feb 2022 04:09:53 -0500 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 992481B0BC8; Thu, 24 Feb 2022 01:08:56 -0800 (PST) Received: by mail-pf1-x42c.google.com with SMTP id p8so1307523pfh.8; Thu, 24 Feb 2022 01:08:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=C5LQ0vUCXrLQKiuwNSoC6HsUyh1U+MQASgrQFLzUvi8=; b=qSKqIz22gAesE14btwMqqMk/I4MTlibsgaxjj/yZsOfASCoxeDJzZeUmRrRcBuH6Fh N+lOjpOQcMzAbH1DIhIxTw13te56Xiv+bY7Jgp9ldF2X19Z7Tt6fsf02eZi1bHnKAYMz b2elipX+xsxW58edL4wAvv2fp+L75ir8GM1AKdj4kr45dPnRP7nyiudr68DdhbuyF5u5 H566aIZzpxnD+TW2JOktv8tJaJhM8bUx3nlZFqfMk8YyKTEDMY55mxDnG0DgAaiUH4lU kRxpH8ZOIjz0QmQTr1okdCbU69KkSpVgNQT+YCyR1a+dxEpelvem9/8vo34hQ0I7KYYZ vb9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=C5LQ0vUCXrLQKiuwNSoC6HsUyh1U+MQASgrQFLzUvi8=; b=NHspGRf2G3Uum7/+7yBNwlpnv6KXpaODPplrgCeiR82lXL5W0++DuLdzZopMJyL71m MYgBtQxYolnglKkvtcuCc1skKNDJryp0dbtFsq6XkmEwm6/KCrku9NmEI5HzEwookwXG aKggZPboLk/xvDaNiW0gUDoTJR6lJcps/cfQc9Y8GdASYE0wCgq2xY2ooDXn5LSK4Vcu pLseXWOoSCNUqQqhjgyCliV6qf42px+/ARBvBDsUvC8FU7nieQ2om0qlIFnaQs2cMi7C ppnFXTu3DLkwK++9DFJxhY/bJK6qdOSpC5jdg3bYm/mwsItNhq8hUCqtRRyuKntjSgZm IxKA== X-Gm-Message-State: AOAM5309MsUxjpIZVN6ZypPM9vLPtek6mjPng3p/wC80EwU0qeQ1YfEC QNfj4gE5QU5/pGUnxnbJjZI= X-Google-Smtp-Source: ABdhPJx6l+Ss2YtFSbAU/kp7rnEFu2KH73NSNDW9rsL0T3+pglueK9n1QooLrnKRRY9pMI2+076k+Q== X-Received: by 2002:a05:6a00:1a04:b0:4e1:786c:cce3 with SMTP id g4-20020a056a001a0400b004e1786ccce3mr1899906pfv.81.1645693736002; Thu, 24 Feb 2022 01:08:56 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:55 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 14/16] blk-wbt: cleanup the blk-wbt.h Date: Thu, 24 Feb 2022 17:06:52 +0800 Message-Id: <20220224090654.54671-15-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" There is not any wbt functions that need to be external, cleanup the blk-wbt.h Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-iocost.c | 1 - block/blk-mq-sched.c | 1 - block/blk-wbt.c | 64 ++++++++++++++++++++++++++++- block/blk-wbt.h | 83 -------------------------------------- include/trace/events/wbt.h | 3 +- 5 files changed, 65 insertions(+), 87 deletions(-) delete mode 100644 block/blk-wbt.h diff --git a/block/blk-iocost.c b/block/blk-iocost.c index ad1d4d9762bd..c7142b60bb1a 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -183,7 +183,6 @@ #include #include "blk-rq-qos.h" #include "blk-stat.h" -#include "blk-wbt.h" =20 #ifdef CONFIG_TRACEPOINTS =20 diff --git a/block/blk-mq-sched.c b/block/blk-mq-sched.c index 55488ba97823..25f65a5d5bb7 100644 --- a/block/blk-mq-sched.c +++ b/block/blk-mq-sched.c @@ -16,7 +16,6 @@ #include "blk-mq-debugfs.h" #include "blk-mq-sched.h" #include "blk-mq-tag.h" -#include "blk-wbt.h" =20 /* * Mark a hardware queue as needing a restart. For shared queues, maintain diff --git a/block/blk-wbt.c b/block/blk-wbt.c index 83e05417e25f..33072118929f 100644 --- a/block/blk-wbt.c +++ b/block/blk-wbt.c @@ -27,14 +27,76 @@ #include =20 #include "blk.h" -#include "blk-wbt.h" +#include "blk-stat.h" #include "blk-rq-qos.h" =20 #define CREATE_TRACE_POINTS #include =20 +enum wbt_flags { + WBT_TRACKED =3D 1, /* write, tracked for throttling */ + WBT_READ =3D 2, /* read */ + WBT_KSWAPD =3D 4, /* write, from kswapd */ + WBT_DISCARD =3D 8, /* discard */ + + WBT_NR_BITS =3D 4, /* number of bits */ +}; + +enum { + WBT_RWQ_BG =3D 0, + WBT_RWQ_KSWAPD, + WBT_RWQ_DISCARD, + WBT_NUM_RWQ, +}; + +struct rq_wb { + /* + * Settings that govern how we throttle + */ + unsigned int wb_background; /* background writeback */ + unsigned int wb_normal; /* normal writeback */ + + /* + * Number of consecutive periods where we don't have enough + * information to make a firm scale up/down decision. + */ + unsigned int unknown_cnt; + + u64 win_nsec; /* default window size */ + u64 cur_win_nsec; /* current window size */ + + struct blk_stat_callback *cb; + + u64 sync_issue; + void *sync_cookie; + + unsigned int wc; + + unsigned long last_issue; /* last non-throttled issue */ + unsigned long last_comp; /* last non-throttled comp */ + unsigned long min_lat_nsec; + struct rq_qos rqos; + struct rq_wait rq_wait[WBT_NUM_RWQ]; + struct rq_depth rq_depth; +}; + static struct rq_qos_ops wbt_rqos_ops; =20 +static inline struct rq_wb *RQWB(struct rq_qos *rqos) +{ + return container_of(rqos, struct rq_wb, rqos); +} + +static inline unsigned int wbt_inflight(struct rq_wb *rwb) +{ + unsigned int i, ret =3D 0; + + for (i =3D 0; i < WBT_NUM_RWQ; i++) + ret +=3D atomic_read(&rwb->rq_wait[i].inflight); + + return ret; +} + static inline struct rq_qos *wbt_rq_qos(struct request_queue *q) { return rq_qos_get(q, wbt_rqos_ops.id); diff --git a/block/blk-wbt.h b/block/blk-wbt.h deleted file mode 100644 index eb837dfd0ace..000000000000 --- a/block/blk-wbt.h +++ /dev/null @@ -1,83 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef WB_THROTTLE_H -#define WB_THROTTLE_H - -#include -#include -#include -#include -#include - -#include "blk-stat.h" -#include "blk-rq-qos.h" - -enum wbt_flags { - WBT_TRACKED =3D 1, /* write, tracked for throttling */ - WBT_READ =3D 2, /* read */ - WBT_KSWAPD =3D 4, /* write, from kswapd */ - WBT_DISCARD =3D 8, /* discard */ - - WBT_NR_BITS =3D 4, /* number of bits */ -}; - -enum { - WBT_RWQ_BG =3D 0, - WBT_RWQ_KSWAPD, - WBT_RWQ_DISCARD, - WBT_NUM_RWQ, -}; - -struct rq_wb { - /* - * Settings that govern how we throttle - */ - unsigned int wb_background; /* background writeback */ - unsigned int wb_normal; /* normal writeback */ - - /* - * Number of consecutive periods where we don't have enough - * information to make a firm scale up/down decision. - */ - unsigned int unknown_cnt; - - u64 win_nsec; /* default window size */ - u64 cur_win_nsec; /* current window size */ - - struct blk_stat_callback *cb; - - u64 sync_issue; - void *sync_cookie; - - unsigned int wc; - - unsigned long last_issue; /* last non-throttled issue */ - unsigned long last_comp; /* last non-throttled comp */ - unsigned long min_lat_nsec; - struct rq_qos rqos; - struct rq_wait rq_wait[WBT_NUM_RWQ]; - struct rq_depth rq_depth; -}; - -static inline struct rq_wb *RQWB(struct rq_qos *rqos) -{ - return container_of(rqos, struct rq_wb, rqos); -} - -static inline unsigned int wbt_inflight(struct rq_wb *rwb) -{ - unsigned int i, ret =3D 0; - - for (i =3D 0; i < WBT_NUM_RWQ; i++) - ret +=3D atomic_read(&rwb->rq_wait[i].inflight); - - return ret; -} - -#ifdef CONFIG_BLK_WBT -#else -static inline void wbt_track(struct request *rq, enum wbt_flags flags) -{ -} -#endif /* CONFIG_BLK_WBT */ - -#endif diff --git a/include/trace/events/wbt.h b/include/trace/events/wbt.h index 9c66e59d859c..b62e623ed067 100644 --- a/include/trace/events/wbt.h +++ b/include/trace/events/wbt.h @@ -6,7 +6,8 @@ #define _TRACE_WBT_H =20 #include -#include "../../../block/blk-wbt.h" +#include "../../../block/blk-stat.h" +#include "../../../block/blk-rq-qos.h" =20 /** * wbt_stat - trace stats for blk_wb --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29B4AC433F5 for ; Thu, 24 Feb 2022 09:09:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232665AbiBXJKZ (ORCPT ); Thu, 24 Feb 2022 04:10:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231938AbiBXJJ6 (ORCPT ); Thu, 24 Feb 2022 04:09:58 -0500 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11381B0C60; Thu, 24 Feb 2022 01:08:58 -0800 (PST) Received: by mail-pf1-x42d.google.com with SMTP id y11so1317590pfa.6; Thu, 24 Feb 2022 01:08:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=fr1oc9aiM5IuazGXh8FH+9jR6J4CALktC/QzvGySMfM=; b=EzVYR5sLz7ZtycsqAOHYPCP4Y8VM+OtxWJWvVO/hdJmQHZxZ/IGq7ltR7jhP+IqNPZ o6LD0XssBNbTw9wB4PDX8r5MpRs1+BZtVFJdVfplaTouXeJJtWGyL+0vFVTtCTwgD79P AdcXUB6VjplvCjR6M5OOnE0GsHd84TL0CAFW5ITFQXnhjchDXcRyfue+/XEqwCEV924b hMRhBK94K1TabPCgbsGNPmwe6ifZdziZFATWiMSl6kUCGlY8VXe12bsnla+vc2SEmdFy yFDZrLgX7uTBhmv49tThNgISdOVaEuNFmr0Txbtqyef6XD3nwrvyUMT348NwtwrZKCIq aVGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=fr1oc9aiM5IuazGXh8FH+9jR6J4CALktC/QzvGySMfM=; b=gBI+OfiTtXEXz+fe0879luTPmj+F7tDw61eR2Giq2iUaC7lqJ7UY0Y9qhcGshP/ay1 dJvB2fXa0ZLsl0O+lFr6VKulwR1r55tDTkzUZHHTkb4cog0tCdTDcQ+KIOfj9jX8Bopu akKnz56bnBR4rO9aKcHT4qdTJrue4g9t1reiYMFTWTfsnPYhrXsdkX/0Kotly/i2+dyb Sfyx6DExWONNa/7JzcHPwHS6NB1wH7Gp5kOlfUFwpyIIBIo6UpIQu9/L6O5pQiDpdCkC MNUEjdbUDiUrphVxbs6CSNYccUtj3BiiHKY+TgXouJ15CYVJFQZ94y4MWuf0MKlbvHzh 7sVA== X-Gm-Message-State: AOAM533KU8k6fp6dO4FBhvvsYTBlegKa8olDievDxFzT7+Po9YRu99gZ ZiExl8H0CeqIaaL2BTHtL50= X-Google-Smtp-Source: ABdhPJwMVtV5k8X6K+5G7sf39AG2sl6lVFr7fy6wo+LNUKWKjgH03Sv7m2rbaXW8ESgDG9m3YkJmlg== X-Received: by 2002:a63:5f42:0:b0:373:d440:496e with SMTP id t63-20020a635f42000000b00373d440496emr1563283pgb.529.1645693738216; Thu, 24 Feb 2022 01:08:58 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:08:57 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 15/16] blk/rq-qos: move the rqos debugfs code to blk-rq-qos.c Date: Thu, 24 Feb 2022 17:06:53 +0800 Message-Id: <20220224090654.54671-16-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This is no functional change in this patch. Signed-off-by: Wang Jianchao (Kuaishou) --- block/blk-mq-debugfs.c | 42 ++++++------------------------------------ block/blk-mq-debugfs.h | 17 ++++------------- block/blk-rq-qos.c | 38 +++++++++++++++++++++++++++++++++++--- block/blk-rq-qos.h | 1 + 4 files changed, 46 insertions(+), 52 deletions(-) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 4c9dafd16a08..71e6a097361b 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -13,7 +13,6 @@ #include "blk-mq-debugfs.h" #include "blk-mq-sched.h" #include "blk-mq-tag.h" -#include "blk-rq-qos.h" =20 static void print_stat(struct seq_file *m, struct blk_rq_stat *stat) { @@ -691,7 +690,7 @@ static const struct blk_mq_debugfs_attr blk_mq_debugfs_= ctx_attrs[] =3D { {}, }; =20 -static void debugfs_create_files(struct dentry *parent, void *data, +void blk_mq_debugfs_create_files(struct dentry *parent, void *data, const struct blk_mq_debugfs_attr *attr) { if (IS_ERR_OR_NULL(parent)) @@ -709,7 +708,7 @@ void blk_mq_debugfs_register(struct request_queue *q) struct blk_mq_hw_ctx *hctx; int i; =20 - debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs); + blk_mq_debugfs_create_files(q->debugfs_dir, q, blk_mq_debugfs_queue_attrs= ); =20 /* * blk_mq_init_sched() attempted to do this already, but q->debugfs_dir @@ -742,7 +741,7 @@ static void blk_mq_debugfs_register_ctx(struct blk_mq_h= w_ctx *hctx, snprintf(name, sizeof(name), "cpu%u", ctx->cpu); ctx_dir =3D debugfs_create_dir(name, hctx->debugfs_dir); =20 - debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs); + blk_mq_debugfs_create_files(ctx_dir, ctx, blk_mq_debugfs_ctx_attrs); } =20 void blk_mq_debugfs_register_hctx(struct request_queue *q, @@ -755,7 +754,7 @@ void blk_mq_debugfs_register_hctx(struct request_queue = *q, snprintf(name, sizeof(name), "hctx%u", hctx->queue_num); hctx->debugfs_dir =3D debugfs_create_dir(name, q->debugfs_dir); =20 - debugfs_create_files(hctx->debugfs_dir, hctx, blk_mq_debugfs_hctx_attrs); + blk_mq_debugfs_create_files(hctx->debugfs_dir, hctx, blk_mq_debugfs_hctx_= attrs); =20 hctx_for_each_ctx(hctx, ctx, i) blk_mq_debugfs_register_ctx(hctx, ctx); @@ -802,7 +801,7 @@ void blk_mq_debugfs_register_sched(struct request_queue= *q) =20 q->sched_debugfs_dir =3D debugfs_create_dir("sched", q->debugfs_dir); =20 - debugfs_create_files(q->sched_debugfs_dir, q, e->queue_debugfs_attrs); + blk_mq_debugfs_create_files(q->sched_debugfs_dir, q, e->queue_debugfs_att= rs); } =20 void blk_mq_debugfs_unregister_sched(struct request_queue *q) @@ -811,35 +810,6 @@ void blk_mq_debugfs_unregister_sched(struct request_qu= eue *q) q->sched_debugfs_dir =3D NULL; } =20 -void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) -{ - debugfs_remove_recursive(rqos->debugfs_dir); - rqos->debugfs_dir =3D NULL; -} - -void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) -{ - struct request_queue *q =3D rqos->q; - - if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) - return; - - if (!q->rqos_debugfs_dir) - q->rqos_debugfs_dir =3D debugfs_create_dir("rqos", - q->debugfs_dir); - - rqos->debugfs_dir =3D debugfs_create_dir(rqos->ops->name, - rqos->q->rqos_debugfs_dir); - - debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_attrs); -} - -void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q) -{ - debugfs_remove_recursive(q->rqos_debugfs_dir); - q->rqos_debugfs_dir =3D NULL; -} - void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx) { @@ -858,7 +828,7 @@ void blk_mq_debugfs_register_sched_hctx(struct request_= queue *q, =20 hctx->sched_debugfs_dir =3D debugfs_create_dir("sched", hctx->debugfs_dir); - debugfs_create_files(hctx->sched_debugfs_dir, hctx, + blk_mq_debugfs_create_files(hctx->sched_debugfs_dir, hctx, e->hctx_debugfs_attrs); } =20 diff --git a/block/blk-mq-debugfs.h b/block/blk-mq-debugfs.h index a68aa6041a10..ed805dca934c 100644 --- a/block/blk-mq-debugfs.h +++ b/block/blk-mq-debugfs.h @@ -31,10 +31,8 @@ void blk_mq_debugfs_unregister_sched(struct request_queu= e *q); void blk_mq_debugfs_register_sched_hctx(struct request_queue *q, struct blk_mq_hw_ctx *hctx); void blk_mq_debugfs_unregister_sched_hctx(struct blk_mq_hw_ctx *hctx); - -void blk_mq_debugfs_register_rqos(struct rq_qos *rqos); -void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos); -void blk_mq_debugfs_unregister_queue_rqos(struct request_queue *q); +void blk_mq_debugfs_create_files(struct dentry *parent, void *data, + const struct blk_mq_debugfs_attr *attr); #else static inline void blk_mq_debugfs_register(struct request_queue *q) { @@ -78,15 +76,8 @@ static inline void blk_mq_debugfs_unregister_sched_hctx(= struct blk_mq_hw_ctx *hc { } =20 -static inline void blk_mq_debugfs_register_rqos(struct rq_qos *rqos) -{ -} - -static inline void blk_mq_debugfs_unregister_rqos(struct rq_qos *rqos) -{ -} - -static inline void blk_mq_debugfs_unregister_queue_rqos(struct request_que= ue *q) +void blk_mq_debugfs_create_files(struct dentry *parent, void *data, + const struct blk_mq_debugfs_attr *attr) { } #endif diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 236ecb2af845..0572dd584c53 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -295,6 +295,31 @@ void rq_qos_wait(struct rq_wait *rqw, void *private_da= ta, finish_wait(&rqw->wait, &data.wq); } =20 +#ifdef CONFIG_BLK_DEBUG_FS +static void rq_qos_debugfs_unregister(struct rq_qos *rqos) +{ + debugfs_remove_recursive(rqos->debugfs_dir); + rqos->debugfs_dir =3D NULL; +} + +static void rq_qos_debugfs_register(struct rq_qos *rqos) +{ + struct request_queue *q =3D rqos->q; + + if (rqos->debugfs_dir || !rqos->ops->debugfs_attrs) + return; + + if (!q->rqos_debugfs_dir) + q->rqos_debugfs_dir =3D debugfs_create_dir("rqos", + q->debugfs_dir); + + rqos->debugfs_dir =3D debugfs_create_dir(rqos->ops->name, + rqos->q->rqos_debugfs_dir); + + blk_mq_debugfs_create_files(rqos->debugfs_dir, rqos, rqos->ops->debugfs_a= ttrs); +} +#endif + void rq_qos_exit(struct request_queue *q) { /* @@ -306,7 +331,10 @@ void rq_qos_exit(struct request_queue *q) q->rq_qos =3D rqos->next; rqos->ops->exit(rqos); } - blk_mq_debugfs_unregister_queue_rqos(q); +#ifdef CONFIG_BLK_DEBUG_FS + debugfs_remove_recursive(q->rqos_debugfs_dir); + q->rqos_debugfs_dir =3D NULL; +#endif } =20 static struct rq_qos *rq_qos_by_name(struct request_queue *q, @@ -383,8 +411,10 @@ void rq_qos_activate(struct request_queue *q, } spin_unlock_irq(&q->rqos_lock); =20 +#ifdef CONFIG_BLK_DEBUG_FS if (rqos->ops->debugfs_attrs) - blk_mq_debugfs_register_rqos(rqos); + rq_qos_debugfs_register(rqos); +#endif } =20 void rq_qos_deactivate(struct rq_qos *rqos) @@ -406,7 +436,9 @@ void rq_qos_deactivate(struct rq_qos *rqos) } } spin_unlock_irq(&q->rqos_lock); - blk_mq_debugfs_unregister_rqos(rqos); +#ifdef CONFIG_BLK_DEBUG_FS + rq_qos_debugfs_unregister(rqos); +#endif } =20 static struct rq_qos_ops *rq_qos_op_find(const char *name) diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 3d7df14edde3..463c64d28e8b 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -8,6 +8,7 @@ #include #include #include +#include =20 #include "blk-mq-debugfs.h" =20 --=20 2.17.1 From nobody Thu Jun 4 18:01:46 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6198DC433F5 for ; Thu, 24 Feb 2022 09:10:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229962AbiBXJK2 (ORCPT ); Thu, 24 Feb 2022 04:10:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232638AbiBXJJ7 (ORCPT ); Thu, 24 Feb 2022 04:09:59 -0500 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043D21B372A; Thu, 24 Feb 2022 01:09:01 -0800 (PST) Received: by mail-pg1-x52d.google.com with SMTP id 195so1214826pgc.6; Thu, 24 Feb 2022 01:09:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5lC/QRqanujut9YVkFlgqgARRMRZBexuuSYRLcGbZXQ=; b=HJMY322fGBraD+Lri+RbvpNXBMNETrF9CoduJ2S1CFuUx7CMrSm3ENOeauE6dhqxAM dXnXz5Jz2wlIoePlV09JO9MJ4bfHaGe70b2PCjuov1gmCMzkbsFug776tAimBuhfx2Sl iIjRN73Tok5EVFyQ0IdEKYYFxrKuzgygJKt9o9j9Z4B4GgQrTdvaEjH4atr+SfJdy8JM lyrVlRCiRSS/yWL3e9IUriqzp9u1Ci0nH1UNQ8syu4+FztaIVBPtmSN59AidBKCMfAWQ Ksm0YKazBy2Ememh97Iw+gW7DfxvqRV4/fzspAuUlkQVugguzzLR+aGGxbDqpG5nKVpF Xp7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5lC/QRqanujut9YVkFlgqgARRMRZBexuuSYRLcGbZXQ=; b=0GT8DFUHiB0NA+4pTjBfvvfSqZQZP/Xqb5ijcAVHh3PNPRqPU+J+rhfqEJ8EB+8Gg+ z60h5+qFYaTOAxChjv2AxZSxKB6YVTU/pRkufGh/P3Deznv8zEoDfijUXLVTAHK+m6So 4t38033gbvch5O9BoGphUjTYjduWHodtrCCy1e98xcVIn2uTE3EUgbnvpRxwr6bOmQlD 5h43sRGngnIURvDhlUuy3v2FvYXIvdTHZpWjsTF+56eeKnWAAW/EI0LoZD+U9XxHvfQn YP5wyCs5bm1C5R8LNF1ptSetcOqn/ldufnmRObJxzI5e/v4fIMA/M+7a9nfFjiaNEOGi Ygbw== X-Gm-Message-State: AOAM533AhTvX/8PCIqECGq3iYhmoHu+MQI6eveFf984EHjB8wWYvtP0B FIMoceaG76+ZqnMMaXDimXU= X-Google-Smtp-Source: ABdhPJyr7UgIZcW5glKz4gMUjz8dogEypUmez6QS/YMM5Hx3YpB3bmXHY7kGT8F5/xrtP77xCxjCzg== X-Received: by 2002:a62:8895:0:b0:4e1:78b:5ab7 with SMTP id l143-20020a628895000000b004e1078b5ab7mr1985830pfd.67.1645693740481; Thu, 24 Feb 2022 01:09:00 -0800 (PST) Received: from localhost.localdomain ([162.219.34.248]) by smtp.gmail.com with ESMTPSA id nn14sm2023999pjb.45.2022.02.24.01.08.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 01:09:00 -0800 (PST) From: "Wang Jianchao (Kuaishou)" To: Jens Axboe Cc: Josef Bacik , Tejun Heo , Bart Van Assche , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC V5 16/16] blk/rq-qos: add config to control the whole blk-rq-qos framework Date: Thu, 24 Feb 2022 17:06:54 +0800 Message-Id: <20220224090654.54671-17-jianchao.wan9@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220224090654.54671-1-jianchao.wan9@gmail.com> References: <20220224090654.54671-1-jianchao.wan9@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch makes the whole blk-rq-qos framework be able to be configured by CONFIG_BLK_RQ_QOS. There is no functional changes in this patch. Signed-off-by: Wang Jianchao (Kuaishou) --- block/Kconfig | 7 +++++++ block/Makefile | 3 ++- block/blk-mq.c | 4 +--- block/blk-rq-qos.c | 1 + block/blk-rq-qos.h | 16 ++++++++++++++++ block/blk-sysfs.c | 4 ++++ include/linux/blkdev.h | 6 ++++-- 7 files changed, 35 insertions(+), 6 deletions(-) diff --git a/block/Kconfig b/block/Kconfig index d5d4197b7ed2..b9d2a2dcbe56 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -38,6 +38,9 @@ config BLK_DEV_BSG_COMMON config BLK_ICQ bool =20 +config BLK_RQ_QOS + bool + config BLK_DEV_BSGLIB bool "Block layer SG support v4 helper lib" select BLK_DEV_BSG_COMMON @@ -99,6 +102,7 @@ config BLK_DEV_THROTTLING_LOW =20 config BLK_WBT bool "Enable support for block device writeback throttling" + select BLK_RQ_QOS help Enabling this option enables the block layer to throttle buffered background writeback from the VM, making it more smooth and having @@ -116,6 +120,7 @@ config BLK_WBT_MQ config BLK_CGROUP_IOLATENCY bool "Enable support for latency based cgroup IO protection" depends on BLK_CGROUP + select BLK_RQ_QOS help Enabling this option enables the .latency interface for IO throttling. The IO controller will attempt to maintain average IO latencies below @@ -138,6 +143,7 @@ config BLK_CGROUP_IOCOST depends on BLK_CGROUP select BLK_RQ_IO_DATA_LEN select BLK_RQ_ALLOC_TIME + select BLK_RQ_QOS help Enabling this option enables the .weight interface for cost model based proportional IO control. The IO controller @@ -147,6 +153,7 @@ config BLK_CGROUP_IOCOST config BLK_CGROUP_IOPRIO bool "Cgroup I/O controller for assigning an I/O priority class" depends on BLK_CGROUP + select BLK_RQ_QOS help Enable the .prio interface for assigning an I/O priority class to requests. The I/O priority class affects the order in which an I/O diff --git a/block/Makefile b/block/Makefile index f38eaa612929..07af1b2f6fe0 100644 --- a/block/Makefile +++ b/block/Makefile @@ -8,9 +8,10 @@ obj-y :=3D bdev.o fops.o bio.o elevator.o blk-core.o blk-= sysfs.o \ blk-merge.o blk-timeout.o \ blk-lib.o blk-mq.o blk-mq-tag.o blk-stat.o \ blk-mq-sysfs.o blk-mq-cpumap.o blk-mq-sched.o ioctl.o \ - genhd.o ioprio.o badblocks.o partitions/ blk-rq-qos.o \ + genhd.o ioprio.o badblocks.o partitions/ \ disk-events.o blk-ia-ranges.o =20 +obj-$(CONFIG_BLK_RQ_QOS) +=3D blk-rq-qos.o obj-$(CONFIG_BOUNCE) +=3D bounce.o obj-$(CONFIG_BLK_DEV_BSG_COMMON) +=3D bsg.o obj-$(CONFIG_BLK_DEV_BSGLIB) +=3D bsg-lib.o diff --git a/block/blk-mq.c b/block/blk-mq.c index 3c1cd32c72fd..9780bfb25046 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -1248,12 +1248,10 @@ EXPORT_SYMBOL(blk_execute_rq); =20 static void __blk_mq_requeue_request(struct request *rq) { - struct request_queue *q =3D rq->q; - blk_mq_put_driver_tag(rq); =20 trace_block_rq_requeue(rq); - rq_qos_requeue(q, rq); + rq_qos_requeue(rq->q, rq); =20 if (blk_mq_request_started(rq)) { WRITE_ONCE(rq->state, MQ_RQ_IDLE); diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index 0572dd584c53..92df1dca74cc 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 =20 +#include #include "blk-rq-qos.h" =20 static DEFINE_IDR(rq_qos_idr); diff --git a/block/blk-rq-qos.h b/block/blk-rq-qos.h index 463c64d28e8b..dc7071139247 100644 --- a/block/blk-rq-qos.h +++ b/block/blk-rq-qos.h @@ -2,6 +2,8 @@ #ifndef RQ_QOS_H #define RQ_QOS_H =20 +#ifdef CONFIG_BLK_RQ_QOS + #include #include #include @@ -167,4 +169,18 @@ static inline void rq_qos_setting_changed(struct reque= st_queue *q) =20 void rq_qos_exit(struct request_queue *); =20 +#else + +#define rq_qos_cleanup(q, bio) +#define rq_qos_done(q, rq) +#define rq_qos_issue(q, rq) +#define rq_qos_requeue(q, rq) +#define rq_qos_done_bio(q, bio) +#define rq_qos_throttle(q, bio) +#define rq_qos_track(q, rq, bio) +#define rq_qos_merge(q, rq, bio) +#define rq_qos_setting_changed(q) +#define rq_qos_exit(q) + +#endif /* CONFIG_BLK_RQ_QOS */ #endif diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c index 4563283dae07..784b4d8416d5 100644 --- a/block/blk-sysfs.c +++ b/block/blk-sysfs.c @@ -503,7 +503,9 @@ QUEUE_RO_ENTRY(queue_max_segments, "max_segments"); QUEUE_RO_ENTRY(queue_max_integrity_segments, "max_integrity_segments"); QUEUE_RO_ENTRY(queue_max_segment_size, "max_segment_size"); QUEUE_RW_ENTRY(elv_iosched, "scheduler"); +#ifdef CONFIG_BLK_RQ_QOS QUEUE_RW_ENTRY(queue_qos, "qos"); +#endif =20 QUEUE_RO_ENTRY(queue_logical_block_size, "logical_block_size"); QUEUE_RO_ENTRY(queue_physical_block_size, "physical_block_size"); @@ -562,7 +564,9 @@ static struct attribute *queue_attrs[] =3D { &queue_max_integrity_segments_entry.attr, &queue_max_segment_size_entry.attr, &elv_iosched_entry.attr, +#ifdef CONFIG_BLK_RQ_QOS &queue_qos_entry.attr, +#endif &queue_hw_sector_size_entry.attr, &queue_logical_block_size_entry.attr, &queue_physical_block_size_entry.attr, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 126aac824ccc..8d6dff40fe73 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -194,8 +194,9 @@ struct request_queue { struct percpu_ref q_usage_counter; =20 struct blk_queue_stats *stats; +#ifdef CONFIG_BLK_RQ_QOS struct rq_qos *rq_qos; - +#endif const struct blk_mq_ops *mq_ops; =20 /* sw queues */ @@ -230,8 +231,9 @@ struct request_queue { int id; =20 spinlock_t queue_lock; +#ifdef CONFIG_BLK_RQ_QOS spinlock_t rqos_lock; - +#endif struct gendisk *disk; =20 /* --=20 2.17.1