[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240613014937.1326020-8-yukuai1@huaweicloud.com>
Date: Thu, 13 Jun 2024 09:49:37 +0800
From: Yu Kuai <yukuai1@...weicloud.com>
To: axboe@...nel.dk,
tj@...nel.org,
josef@...icpanda.com,
gregkh@...uxfoundation.org,
lizefan.x@...edance.com,
hannes@...xchg.org
Cc: linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org,
cgroups@...r.kernel.org,
yukuai3@...wei.com,
yukuai1@...weicloud.com,
yi.zhang@...wei.com,
yangerkun@...wei.com
Subject: [PATCH RFC -next 7/7] blk-iocost: support to build iocost as kernel module
From: Yu Kuai <yukuai3@...wei.com>
Signed-off-by: Yu Kuai <yukuai3@...wei.com>
---
block/Kconfig | 2 +-
block/blk-iocost.c | 14 +++++++++++++-
include/linux/blk_types.h | 2 +-
3 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/block/Kconfig b/block/Kconfig
index dc12af58dbae..b94b93158e57 100644
--- a/block/Kconfig
+++ b/block/Kconfig
@@ -156,7 +156,7 @@ config BLK_CGROUP_FC_APPID
application specific identification into the FC frame.
config BLK_CGROUP_IOCOST
- bool "Enable support for cost model based cgroup IO controller"
+ tristate "Enable support for cost model based cgroup IO controller"
depends on BLK_CGROUP
select BLK_RQ_ALLOC_TIME
help
diff --git a/block/blk-iocost.c b/block/blk-iocost.c
index 708a43a7c6a0..2a69db547045 100644
--- a/block/blk-iocost.c
+++ b/block/blk-iocost.c
@@ -2850,6 +2850,7 @@ static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos)
static void __ioc_exit(struct ioc *ioc)
{
+ module_put(THIS_MODULE);
blkcg_deactivate_policy(ioc->rqos.disk, &blkcg_policy_iocost);
spin_lock_irq(&ioc->lock);
@@ -2882,13 +2883,19 @@ static int blk_iocost_init(struct gendisk *disk)
struct ioc *ioc;
int i, cpu, ret;
+ if (!try_module_get(THIS_MODULE))
+ return -ENODEV;
+
ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
- if (!ioc)
+ if (!ioc) {
+ module_put(THIS_MODULE);
return -ENOMEM;
+ }
ioc->pcpu_stat = alloc_percpu(struct ioc_pcpu_stat);
if (!ioc->pcpu_stat) {
kfree(ioc);
+ module_put(THIS_MODULE);
return -ENOMEM;
}
@@ -2938,6 +2945,7 @@ static int blk_iocost_init(struct gendisk *disk)
rq_qos_del(&ioc->rqos);
err_free_ioc:
free_percpu(ioc->pcpu_stat);
+ module_put(THIS_MODULE);
kfree(ioc);
return ret;
}
@@ -3616,3 +3624,7 @@ static void __exit ioc_exit(void)
module_init(ioc_init);
module_exit(ioc_exit);
+
+MODULE_AUTHOR("Tejun Heo");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Cost model based cgroup IO controller");
diff --git a/include/linux/blk_types.h b/include/linux/blk_types.h
index 781c4500491b..8da12ebc7777 100644
--- a/include/linux/blk_types.h
+++ b/include/linux/blk_types.h
@@ -234,7 +234,7 @@ struct bio {
*/
struct blkcg_gq *bi_blkg;
struct bio_issue bi_issue;
-#ifdef CONFIG_BLK_CGROUP_IOCOST
+#if IS_ENABLED(CONFIG_BLK_CGROUP_IOCOST)
u64 bi_iocost_cost;
#endif
#endif
--
2.39.2
Powered by blists - more mailing lists