From patchwork Tue Jun 18 03:17:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701749 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E3A51E4A1; Tue, 18 Jun 2024 03:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680730; cv=none; b=nipu2xBRQhK2Y+X0fPY4YDtcYu/3xwJmi1Lkbuxsm83z2itx7MFcHfYjiiZ4PsZXneDhEJohNoha9zaSej6ZuL2b1FHFQ1MAyYzAr9bq+de99t8wroTgMWTZAQqvpBbpHnOOoHusp3w6krjeKgSgLwl6qmR6qLHWPlQt1Ym2xtg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680730; c=relaxed/simple; bh=LOjXU7KK/APac/FwqT39JdQc8LBfPrxyolvIwG8s1aE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rXtYQ1H6733U8OHjlQ2KaxXDtKYKm1p/yl/JXvK2PpjCsJ+cx0oAxtKoMykrKGa0dzq4tIW/uNq3Ma2eBll35iKC7uDIfo/6xljuXBNiHmBgaEomhH9sCpNgbyNEr4/l2sAc8xJq/AVnb2euXqCh1iDIhuynXRILNfzge2zWnfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4W3Bm56djYz4f3jYM; Tue, 18 Jun 2024 11:18:29 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 4384D1A016E; Tue, 18 Jun 2024 11:18:40 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S5; Tue, 18 Jun 2024 11:18:39 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 1/7] blk-cgroup: add a new helper pr_cont_blkg_path() Date: Tue, 18 Jun 2024 11:17:45 +0800 Message-Id: <20240618031751.3470464-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S5 X-Coremail-Antispam: 1UD129KBjvJXoW7ur4xXrWkXw13Jw4rXFWDurg_yoW8ZFW3pa 9rWr1Yk342gFsav3WFga42q34Fya1vgrWft393X3yYkr17Jr1fZF10yr4kC3yrZF4ayrs8 XryFyry8Kr1jkw7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUBE14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_Jr4l82xGYIkIc2 x26xkF7I0E14v26r4j6ryUM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Gr0_Cr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMI IF0xvEx4A2jsIEc7CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x0JU4T5dUUUUU = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai To print blkg path in iocost, and prepare to build iocost as kernel module. Signed-off-by: Yu Kuai --- block/blk-cgroup.c | 6 ++++++ block/blk-cgroup.h | 1 + block/blk-iocost.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 37e6cc91d576..4da70fc7775e 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -2196,5 +2196,11 @@ bool blk_cgroup_congested(void) return ret; } +void pr_cont_blkg_path(struct blkcg_gq *blkg) +{ + return pr_cont_cgroup_path(blkg->blkcg->css.cgroup); +} +EXPORT_SYMBOL_GPL(pr_cont_blkg_path); + module_param(blkcg_debug_stats, bool, 0644); MODULE_PARM_DESC(blkcg_debug_stats, "True if you want debug stats, false if not"); diff --git a/block/blk-cgroup.h b/block/blk-cgroup.h index 90b3959d88cf..25833221a12b 100644 --- a/block/blk-cgroup.h +++ b/block/blk-cgroup.h @@ -220,6 +220,7 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx); int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol, struct blkg_conf_ctx *ctx); void blkg_conf_exit(struct blkg_conf_ctx *ctx); +void pr_cont_blkg_path(struct blkcg_gq *blkg); /** * bio_issue_as_root_blkg - see if this bio needs to be issued as root blkg diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 690ca99dfaca..ca72a62bc9c0 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -1954,7 +1954,7 @@ static void transfer_surpluses(struct list_head *surpluses, struct ioc_now *now) iocg->hweight_donating <= 1 || iocg->hweight_after_donation == 0)) { pr_warn("iocg: invalid donation weights in "); - pr_cont_cgroup_path(iocg_to_blkg(iocg)->blkcg->css.cgroup); + pr_cont_blkg_path(iocg_to_blkg(iocg)); pr_cont(": active=%u donating=%u after=%u\n", iocg->hweight_active, iocg->hweight_donating, iocg->hweight_after_donation); From patchwork Tue Jun 18 03:17:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701750 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19B8F19B3FF; Tue, 18 Jun 2024 03:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680731; cv=none; b=qvUnpUmnKK6ZjJa3+xbRrpw1o3LYfdzlqYUgvgU8pCIOpWzq9/ijgZ7KUEye3D2RFbQ5yqM9rpmXR6tXMO9cyzR7ekqFyv0UKe4R1qXUPTZmID6KdVGhd1dW83/fXm72UdRArzDkjw+xWl6ektzaFo0d4DjXAFs2nj7BWCSVzZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680731; c=relaxed/simple; bh=37FNoyThb91+k69BH2A2XMi5p5DkUSGVuJLuAHPERM0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=SvXhkBlD4XoYCEUBkR+l34MXmzRUc+6IVfkJID+i5b/OMoK/aoOUW+cACphwVA1ghHVmBAQmedDNMNvzBAqOAtzVTZX9kh7MC5Ku8TdC/keP9U7o5m+ZlzSAbx1g2kDpJQhUcRGwEcqK0zhwi0oxpURWWyOVLI7P+Y67FABzkfo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4W3Bm63cljz4f3jsP; Tue, 18 Jun 2024 11:18:30 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id D15111A0181; Tue, 18 Jun 2024 11:18:40 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S6; Tue, 18 Jun 2024 11:18:40 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 2/7] cgroup: export cgroup_parse_float Date: Tue, 18 Jun 2024 11:17:46 +0800 Message-Id: <20240618031751.3470464-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S6 X-Coremail-Antispam: 1UD129KBjvdXoWruryUXryxGFy3Jw4Duw15urg_yoWxZFX_Aw 1DWry0grWxA3ZF934qqws3Xayv9w4rKFWqv34UJFyUAF1DJF95JwnIqr15trsxCan7tryU uF9xurn7tr4DGjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb6AFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUXwA2048vs2IY02 0Ec7CjxVAFwI0_Xr0E3s1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUbdOz7UUUUU= = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai The symbol is used by iocost, prepare to build iocost as kernel module. Signed-off-by: Yu Kuai --- kernel/cgroup/cgroup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 4abd817b0c7c..81b579495f8c 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -6966,6 +6966,7 @@ int cgroup_parse_float(const char *input, unsigned dec_shift, s64 *v) *v = whole * power_of_ten(dec_shift) + frac; return 0; } +EXPORT_SYMBOL_GPL(cgroup_parse_float); /* * sock->sk_cgrp_data handling. For more info, see sock_cgroup_data From patchwork Tue Jun 18 03:17:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701746 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A52401DFEB; Tue, 18 Jun 2024 03:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680729; cv=none; b=eOXwJVqIQ3v4Jm7RZp9F1wiKoI0FOJmovhYAg/iLKXrZykp5ya6k4J3qqKNHStQAN7nHXdphkQJ1eXyaWleMqHl9RyW1bNTpBZWKJckDEoeAUSzy5QQ1lWYxxl8twUZAd004G/mke+EKIEaAzdT/Yu4/8XamGj+3Z9TFrN7yRmY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680729; c=relaxed/simple; bh=pfvHTHzdUCIl+hRpW773wrPRnhPjCezpB1JoG51Z9Jk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HfKZh+F37//ytSu2K09Gx0Q1LHtZQbyIMCoWm+rVabUbpKnM/yz8vr+2d3RdJUpNHee/3yrwY7yx9SFE8ZBEZYTcAkOCcu/L+fhy0+obKtkWeTUU8KsTcZ/Hssf16SSNHWJyh8oGmCTrxo4xoJBS1tFAghRPOwnch5v4MjWcW7Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4W3BmB4gfqz4f3jQX; Tue, 18 Jun 2024 11:18:34 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 6E9D31A0181; Tue, 18 Jun 2024 11:18:41 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S7; Tue, 18 Jun 2024 11:18:41 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 3/7] block: export some API Date: Tue, 18 Jun 2024 11:17:47 +0800 Message-Id: <20240618031751.3470464-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S7 X-Coremail-Antispam: 1UD129KBjvJXoW7ur4xXF17Jr4rKF13tw4UXFb_yoW8ZF4Dpa 17KF43C3yjgFnrZa13W3WrX34ftrWkKF4fJ395ArWSkFsrur1fuFnYy3WkGrySyF93AFs3 AFyY9FyUArW8Ca7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPj14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JrWl82xGYIkIc2 x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2z4x0 Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F4UJw A2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq3wAS 0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2 IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0 Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2kIc2 xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v2 6r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIxkGc2 Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAFwI0_ Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8Jw CI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUojjgUUUU U X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai These APIs are used in iocost, prepare to build iocost as kernel module. Signed-off-by: Yu Kuai --- block/blk-cgroup.c | 4 ++++ block/blk-rq-qos.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 4da70fc7775e..787e3023a366 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -57,6 +57,7 @@ static struct blkcg_policy *blkcg_policy[BLKCG_MAX_POLS]; static LIST_HEAD(all_blkcgs); /* protected by blkcg_pol_mutex */ bool blkcg_debug_stats = false; +EXPORT_SYMBOL_GPL(blkcg_debug_stats); static DEFINE_RAW_SPINLOCK(blkg_stat_lock); @@ -688,6 +689,7 @@ const char *blkg_dev_name(struct blkcg_gq *blkg) return NULL; return bdi_dev_name(blkg->q->disk->bdi); } +EXPORT_SYMBOL_GPL(blkg_dev_name); /** * blkcg_print_blkgs - helper for printing per-blkg data @@ -815,6 +817,7 @@ int blkg_conf_open_bdev(struct blkg_conf_ctx *ctx) ctx->bdev = bdev; return 0; } +EXPORT_SYMBOL_GPL(blkg_conf_open_bdev); /** * blkg_conf_prep - parse and prepare for per-blkg config update @@ -2011,6 +2014,7 @@ void blkcg_schedule_throttle(struct gendisk *disk, bool use_memdelay) current->use_memdelay = use_memdelay; set_notify_resume(current); } +EXPORT_SYMBOL_GPL(blkcg_schedule_throttle); /** * blkcg_add_delay - add delay to this blkg diff --git a/block/blk-rq-qos.c b/block/blk-rq-qos.c index dd7310c94713..c3fdf91ddf8d 100644 --- a/block/blk-rq-qos.c +++ b/block/blk-rq-qos.c @@ -332,6 +332,7 @@ int rq_qos_add(struct rq_qos *rqos, struct gendisk *disk, enum rq_qos_id id, blk_mq_unfreeze_queue(q); return -EBUSY; } +EXPORT_SYMBOL_GPL(rq_qos_add); void rq_qos_del(struct rq_qos *rqos) { @@ -353,3 +354,4 @@ void rq_qos_del(struct rq_qos *rqos) blk_mq_debugfs_unregister_rqos(rqos); mutex_unlock(&q->debugfs_mutex); } +EXPORT_SYMBOL_GPL(rq_qos_del); From patchwork Tue Jun 18 03:17:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701751 Received: from dggsgout12.his.huawei.com (dggsgout12.his.huawei.com [45.249.212.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1B92A19B583; Tue, 18 Jun 2024 03:18:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680731; cv=none; b=rVzAb+a7231Z0n+8pazHQH6Yv5TxGuveDwbDlVixj1NckxSQEj/uvqEdTSQrM+ueK49tfFTV4QDn+KEnoROVoXYfo1WULU1/HaLrJiVKHxibsSv1czw5+4Tj3F7e6Y1Xh+DZeBp2csq7GJBUk2fvItmMDux86jKQoAPUMs+cXaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680731; c=relaxed/simple; bh=8FkKb2IxhXKwp8e6NYIbRGJXuNHO73+pWQXAZFUWoA0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=o5CHQP6/5z/qo9HXPuhxx8Nki82/tVy1ldeH5OGhVqVVEE0XUGNIN8uOyOOKN3MID2RGeDQkoteaNv0qDkd7LIK9sSY7t4Wrh8tilWpqNOhs/hD+uXIFxntNCXaUaHgk7jOazqZZoIYfd1/8IQvrktHaJKbfKKbqiHS+ICIEeCI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.235]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4W3Bm74nVSz4f3jXb; Tue, 18 Jun 2024 11:18:31 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 04A0D1A0572; Tue, 18 Jun 2024 11:18:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S8; Tue, 18 Jun 2024 11:18:41 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 4/7] blk-iocost: factor out helpers to handle params from ioc_qos_write() Date: Tue, 18 Jun 2024 11:17:48 +0800 Message-Id: <20240618031751.3470464-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S8 X-Coremail-Antispam: 1UD129KBjvJXoW3JFy7Jr4DZw4xtFW7Cw1UAwb_yoWxGryxpF Wru3sxt3y8Xrs29r1Iqr4xA3WYk397Wrs7GFWfGrySqr12yrnYq3W8CFy8uFWrJrZ3Gr1U JFWrtF4DGrZ7CrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUOBTY UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Currently the procedures are: 1) parse input disk and open the disk; 2) get ioc, if this is the first writer, init iocost; 3) init qos params, by copying from ioc; 4) parse input qos params; 5) update qos params to ioc; This patch just factor out step 3-5 into separate helpers, there are no functional changes, and prepare for fulture optimizations: - move step 3-4 before setp 2, and don't init iocost for invalid input qos params; - add a new input, and support to free iocost after step 4; - support to build iocost as kernel module; Signed-off-by: Yu Kuai --- block/blk-iocost.c | 155 ++++++++++++++++++++++++++------------------- 1 file changed, 91 insertions(+), 64 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index ca72a62bc9c0..07f7f49b61b3 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3206,45 +3206,24 @@ static const match_table_t qos_tokens = { { NR_QOS_PARAMS, NULL }, }; -static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, - size_t nbytes, loff_t off) -{ - struct blkg_conf_ctx ctx; - struct gendisk *disk; - struct ioc *ioc; +struct ioc_qos_params { u32 qos[NR_QOS_PARAMS]; - bool enable, user; - char *body, *p; - int ret; - - blkg_conf_init(&ctx, input); - - ret = blkg_conf_open_bdev(&ctx); - if (ret) - goto err; - - body = ctx.body; - disk = ctx.bdev->bd_disk; - if (!queue_is_mq(disk->queue)) { - ret = -EOPNOTSUPP; - goto err; - } - - ioc = q_to_ioc(disk->queue); - if (!ioc) { - ret = blk_iocost_init(disk); - if (ret) - goto err; - ioc = q_to_ioc(disk->queue); - } + bool enable; + bool user; +}; - blk_mq_freeze_queue(disk->queue); - blk_mq_quiesce_queue(disk->queue); +static void ioc_qos_params_init(struct ioc *ioc, struct ioc_qos_params *params) +{ + memcpy(params->qos, ioc->params.qos, sizeof(params->qos)); + params->enable = ioc->enabled; + params->user = ioc->user_qos_params; +} - spin_lock_irq(&ioc->lock); - memcpy(qos, ioc->params.qos, sizeof(qos)); - enable = ioc->enabled; - user = ioc->user_qos_params; +static int ioc_qos_params_parse(struct blkg_conf_ctx *ctx, + struct ioc_qos_params *params) +{ + char *body = ctx->body; + char *p; while ((p = strsep(&body, " \t\n"))) { substring_t args[MAX_OPT_ARGS]; @@ -3258,17 +3237,17 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, switch (match_token(p, qos_ctrl_tokens, args)) { case QOS_ENABLE: if (match_u64(&args[0], &v)) - goto einval; - enable = v; + return -EINVAL; + params->enable = v; continue; case QOS_CTRL: match_strlcpy(buf, &args[0], sizeof(buf)); if (!strcmp(buf, "auto")) - user = false; + params->user = false; else if (!strcmp(buf, "user")) - user = true; + params->user = true; else - goto einval; + return -EINVAL; continue; } @@ -3278,61 +3257,110 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, case QOS_WPPM: if (match_strlcpy(buf, &args[0], sizeof(buf)) >= sizeof(buf)) - goto einval; + return -EINVAL; if (cgroup_parse_float(buf, 2, &v)) - goto einval; + return -EINVAL; if (v < 0 || v > 10000) - goto einval; - qos[tok] = v * 100; + return -EINVAL; + params->qos[tok] = v * 100; break; case QOS_RLAT: case QOS_WLAT: if (match_u64(&args[0], &v)) - goto einval; - qos[tok] = v; + return -EINVAL; + params->qos[tok] = v; break; case QOS_MIN: case QOS_MAX: if (match_strlcpy(buf, &args[0], sizeof(buf)) >= sizeof(buf)) - goto einval; + return -EINVAL; if (cgroup_parse_float(buf, 2, &v)) - goto einval; + return -EINVAL; if (v < 0) - goto einval; - qos[tok] = clamp_t(s64, v * 100, - VRATE_MIN_PPM, VRATE_MAX_PPM); + return -EINVAL; + params->qos[tok] = clamp_t(s64, v * 100, + VRATE_MIN_PPM, + VRATE_MAX_PPM); break; default: - goto einval; + return -EINVAL; } - user = true; + params->user = true; } - if (qos[QOS_MIN] > qos[QOS_MAX]) - goto einval; + if (params->qos[QOS_MIN] > params->qos[QOS_MAX]) + return -EINVAL; + + return 0; +} - if (enable && !ioc->enabled) { +static void ioc_qos_params_update(struct gendisk *disk, struct ioc *ioc, + struct ioc_qos_params *params) +{ + if (params->enable && !ioc->enabled) { blk_stat_enable_accounting(disk->queue); blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); ioc->enabled = true; - } else if (!enable && ioc->enabled) { + } else if (!params->enable && ioc->enabled) { blk_stat_disable_accounting(disk->queue); blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); ioc->enabled = false; } - if (user) { - memcpy(ioc->params.qos, qos, sizeof(qos)); + if (params->user) { + memcpy(ioc->params.qos, params->qos, sizeof(params->qos)); ioc->user_qos_params = true; } else { ioc->user_qos_params = false; } ioc_refresh_params(ioc, true); +} + +static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, + size_t nbytes, loff_t off) +{ + struct ioc_qos_params params; + struct blkg_conf_ctx ctx; + struct gendisk *disk; + struct ioc *ioc; + int ret; + + blkg_conf_init(&ctx, input); + + ret = blkg_conf_open_bdev(&ctx); + if (ret) + goto err; + + disk = ctx.bdev->bd_disk; + if (!queue_is_mq(disk->queue)) { + ret = -EOPNOTSUPP; + goto err; + } + + ioc = q_to_ioc(disk->queue); + if (!ioc) { + ret = blk_iocost_init(disk); + if (ret) + goto err; + ioc = q_to_ioc(disk->queue); + } + + blk_mq_freeze_queue(disk->queue); + blk_mq_quiesce_queue(disk->queue); + + spin_lock_irq(&ioc->lock); + ioc_qos_params_init(ioc, ¶ms); + + ret = ioc_qos_params_parse(&ctx, ¶ms); + if (ret) + goto err_parse; + + ioc_qos_params_update(disk, ioc, ¶ms); spin_unlock_irq(&ioc->lock); - if (enable) + if (params.enable) wbt_disable_default(disk); else wbt_enable_default(disk); @@ -3342,13 +3370,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, blkg_conf_exit(&ctx); return nbytes; -einval: + +err_parse: spin_unlock_irq(&ioc->lock); blk_mq_unquiesce_queue(disk->queue); blk_mq_unfreeze_queue(disk->queue); - - ret = -EINVAL; err: blkg_conf_exit(&ctx); return ret; From patchwork Tue Jun 18 03:17:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701748 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2F951B94F; Tue, 18 Jun 2024 03:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680730; cv=none; b=Bgtep+NwnzD+konuBA+ZMGRF+rfMnNAeHVvNEjWMxpyz+VYpa5s0DGXASOtfEKn41vnH6okg8OKRYU3h9MHNvK4mARwio+OULQlXm2nkIPEkjokDtLq4pvoj0dX1HDeTA8v3wfpDBPc2eqxzMxpyE+9geyxlZSjt90AsxIf9XjI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680730; c=relaxed/simple; bh=bmHk7tGjSCw5cD+4JO/hVOvpGolxrKBjvosGvh0boiU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eox5g+2k/UL4CK6Q310C4bUPJJU3iMRzetnzCZ73AUSH8g7kPRp+DRglWrihE8jshH7guN3FeVQKh3VKeYvSom3qXdvA0JyvARZAVnwU6mMV6T0A1edfVYubnykFerw2zZpMsQDwQH4fdPDRLZ3RSD0M6SF6HM5XOQ8vI498YT8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4W3Bm6690fz4f3kw4; Tue, 18 Jun 2024 11:18:30 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 953F01A0181; Tue, 18 Jun 2024 11:18:42 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S9; Tue, 18 Jun 2024 11:18:42 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 5/7] blk-iocost: parse params before initializing iocost Date: Tue, 18 Jun 2024 11:17:49 +0800 Message-Id: <20240618031751.3470464-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S9 X-Coremail-Antispam: 1UD129KBjvJXoWxCF4rGFW7KryDXrWfJF4DCFg_yoW5Aw4fp3 WS93sxt3yUJrs3Zr1aqr40q3W3A34Igr1fZr17Gr95Jr17Cr1Fya4DCr109FW5Ja93AayD tFZ8Jr4UKr4xCFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPF14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Cr0_Gr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUOBTY UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai On the one hand prevent to initialize iocost for invalid input, on the ohter hand prepare to add a new input to free iocost. Signed-off-by: Yu Kuai --- block/blk-iocost.c | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 07f7f49b61b3..34dcf4cdfadb 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3214,9 +3214,20 @@ struct ioc_qos_params { static void ioc_qos_params_init(struct ioc *ioc, struct ioc_qos_params *params) { - memcpy(params->qos, ioc->params.qos, sizeof(params->qos)); - params->enable = ioc->enabled; - params->user = ioc->user_qos_params; + if (ioc) { + memcpy(params->qos, ioc->params.qos, sizeof(params->qos)); + params->enable = ioc->enabled; + params->user = ioc->user_qos_params; + } else { + params->qos[QOS_RPPM] = 0; + params->qos[QOS_RLAT] = 0; + params->qos[QOS_WPPM] = 0; + params->qos[QOS_WLAT] = 0; + params->qos[QOS_MIN] = VRATE_MIN_PPM; + params->qos[QOS_MAX] = VRATE_MAX_PPM; + params->enable = false; + params->user = false; + } } static int ioc_qos_params_parse(struct blkg_conf_ctx *ctx, @@ -3309,7 +3320,16 @@ static void ioc_qos_params_update(struct gendisk *disk, struct ioc *ioc, } if (params->user) { - memcpy(ioc->params.qos, params->qos, sizeof(params->qos)); + if (params->qos[QOS_RPPM]) + ioc->params.qos[QOS_RPPM] = params->qos[QOS_RPPM]; + if (params->qos[QOS_RLAT]) + ioc->params.qos[QOS_RLAT] = params->qos[QOS_RLAT]; + if (params->qos[QOS_WPPM]) + ioc->params.qos[QOS_RPPM] = params->qos[QOS_WPPM]; + if (params->qos[QOS_WLAT]) + ioc->params.qos[QOS_WLAT] = params->qos[QOS_WLAT]; + ioc->params.qos[QOS_MIN] = params->qos[QOS_MIN]; + ioc->params.qos[QOS_MAX] = params->qos[QOS_MAX]; ioc->user_qos_params = true; } else { ioc->user_qos_params = false; @@ -3340,6 +3360,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, } ioc = q_to_ioc(disk->queue); + ioc_qos_params_init(ioc, ¶ms); + + ret = ioc_qos_params_parse(&ctx, ¶ms); + if (ret) + goto err; + if (!ioc) { ret = blk_iocost_init(disk); if (ret) @@ -3351,11 +3377,6 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, blk_mq_quiesce_queue(disk->queue); spin_lock_irq(&ioc->lock); - ioc_qos_params_init(ioc, ¶ms); - - ret = ioc_qos_params_parse(&ctx, ¶ms); - if (ret) - goto err_parse; ioc_qos_params_update(disk, ioc, ¶ms); spin_unlock_irq(&ioc->lock); @@ -3371,11 +3392,6 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, blkg_conf_exit(&ctx); return nbytes; -err_parse: - spin_unlock_irq(&ioc->lock); - - blk_mq_unquiesce_queue(disk->queue); - blk_mq_unfreeze_queue(disk->queue); err: blkg_conf_exit(&ctx); return ret; From patchwork Tue Jun 18 03:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701745 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2F56256D; Tue, 18 Jun 2024 03:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680729; cv=none; b=jsWpDVHd+/TlKZBd0q87Kf9jJ75i2kqR1+gn/AkXBBGYT75BXk6sHV7Y2SLYPwjnBR9+UOa5w7nPqPWV0UAxUDXhM9OLP8x1/jccQ1wh3LXRmCXA5111UaDPlRwEcnABDNYnDcEqZdgTbT0nT5J/+w9LEQ3y0DsADkoMHtcb+uA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680729; c=relaxed/simple; bh=e7+vDoIEVL1RlGQ3D7xQBG+dbRRC33wLqhnC22LJoPc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UjCqGIvRCaEZrJsnnvbxqMoxaGRpDxKTxDCPBuZdtqfSQrEb8C2utvMIB7wC9cCtzqE7MGgJe1Ce+rSjAlsoMsJBWpU5lg0w7pLGaWH/IZi5k5rUywHeJDdOaH1gnGuXFYEutHS2D/QqEdfcjKdzffyd1fdEIEeTi3Oa7l2atGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.93.142]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4W3BmD2dswz4f3jQd; Tue, 18 Jun 2024 11:18:36 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id 2840E1A016E; Tue, 18 Jun 2024 11:18:43 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S10; Tue, 18 Jun 2024 11:18:42 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 6/7] blk-iocost: support to free iocost Date: Tue, 18 Jun 2024 11:17:50 +0800 Message-Id: <20240618031751.3470464-7-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S10 X-Coremail-Antispam: 1UD129KBjvJXoWxGry5Kr4DCFWfuFy7KF43GFg_yoW5KFy7pa 1ruw1akayqqrs7urnxXr42vw1Skws2gryxJ3yfG34ftrnFkr1FqF1kCry8CFy5JFZ5Ar4a vFZ5trW7Gr48ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai Currently if iocost is initialized, it can never be freed until the disk is deleted. A new param "free" is added to the blk-io cgroup api "io.cost.qos", and user can use it to free iocost. On the one hand prevent overhead from fast path, on the other hand prepare to build iocost as kernel module. Signed-off-by: Yu Kuai --- block/blk-iocost.c | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 34dcf4cdfadb..9765c988113f 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -324,6 +324,7 @@ enum ioc_running { enum { QOS_ENABLE, QOS_CTRL, + QOS_FREE, NR_QOS_CTRL_PARAMS, }; @@ -2847,11 +2848,9 @@ static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos) spin_unlock_irq(&ioc->lock); } -static void ioc_rqos_exit(struct rq_qos *rqos) +static void __ioc_exit(struct ioc *ioc) { - struct ioc *ioc = rqos_to_ioc(rqos); - - blkcg_deactivate_policy(rqos->disk, &blkcg_policy_iocost); + blkcg_deactivate_policy(ioc->rqos.disk, &blkcg_policy_iocost); spin_lock_irq(&ioc->lock); ioc->running = IOC_STOP; @@ -2862,6 +2861,13 @@ static void ioc_rqos_exit(struct rq_qos *rqos) kfree(ioc); } +static void ioc_rqos_exit(struct rq_qos *rqos) +{ + struct ioc *ioc = rqos_to_ioc(rqos); + + __ioc_exit(ioc); +} + static const struct rq_qos_ops ioc_rqos_ops = { .throttle = ioc_rqos_throttle, .merge = ioc_rqos_merge, @@ -3193,6 +3199,7 @@ static int ioc_qos_show(struct seq_file *sf, void *v) static const match_table_t qos_ctrl_tokens = { { QOS_ENABLE, "enable=%u" }, { QOS_CTRL, "ctrl=%s" }, + { QOS_FREE, "free" }, { NR_QOS_CTRL_PARAMS, NULL }, }; @@ -3210,6 +3217,7 @@ struct ioc_qos_params { u32 qos[NR_QOS_PARAMS]; bool enable; bool user; + bool free; }; static void ioc_qos_params_init(struct ioc *ioc, struct ioc_qos_params *params) @@ -3228,6 +3236,8 @@ static void ioc_qos_params_init(struct ioc *ioc, struct ioc_qos_params *params) params->enable = false; params->user = false; } + + params->free = false; } static int ioc_qos_params_parse(struct blkg_conf_ctx *ctx, @@ -3260,6 +3270,9 @@ static int ioc_qos_params_parse(struct blkg_conf_ctx *ctx, else return -EINVAL; continue; + case QOS_FREE: + params->free = true; + continue; } tok = match_token(p, qos_tokens, args); @@ -3338,6 +3351,15 @@ static void ioc_qos_params_update(struct gendisk *disk, struct ioc *ioc, ioc_refresh_params(ioc, true); } +static void ioc_free(struct ioc *ioc) +{ + if (!ioc) + return; + + rq_qos_del(&ioc->rqos); + __ioc_exit(ioc); +} + static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, size_t nbytes, loff_t off) { @@ -3366,7 +3388,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, if (ret) goto err; - if (!ioc) { + if (!params.free && !ioc) { ret = blk_iocost_init(disk); if (ret) goto err; @@ -3376,6 +3398,11 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, blk_mq_freeze_queue(disk->queue); blk_mq_quiesce_queue(disk->queue); + if (params.free) { + ioc_free(ioc); + goto out; + } + spin_lock_irq(&ioc->lock); ioc_qos_params_update(disk, ioc, ¶ms); @@ -3386,6 +3413,7 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, else wbt_enable_default(disk); +out: blk_mq_unquiesce_queue(disk->queue); blk_mq_unfreeze_queue(disk->queue); From patchwork Tue Jun 18 03:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13701747 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2FF41CD35; Tue, 18 Jun 2024 03:18:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680729; cv=none; b=r5sjqLHPygH0dLJvWsOt8mV2tHHnXlud6m3J8SwakWEopTQ5DAA9NTBVdGieQknxWqg08Ha0CgZlpknzp+r0/1a+sqZxpVxuIY0wKW0EQ7IJGRaSI1vEdyXuQr6Mj5PU93ebKTM0XkLsX7K3On7fQLRq39hJZzwEbCyaCi6agnU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718680729; c=relaxed/simple; bh=1w2uBjaaCYiqkDeJ8zIZEjj4QVSb+MXZMKyM2t9/Q68=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mWEBsU6ycY1uKqIwT47F8/mjlH++CJV5dW3iqlN8hefsw4aGFoC1qKWFMrIywRlTHb3kH4Kzn01Aru4ff9bRrcvDL08J4eCqyqp0u3fU9E0ljLUhVo7Dtt/zLpcNmrf/bUJ8fUGBFATPgVsA+kTpenNtmyDWMH/9/5lWhjNOPSw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com; spf=pass smtp.mailfrom=huaweicloud.com; arc=none smtp.client-ip=45.249.212.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=huaweicloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huaweicloud.com Received: from mail.maildlp.com (unknown [172.19.163.216]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4W3Bm76yzWz4f3kvv; Tue, 18 Jun 2024 11:18:31 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.128]) by mail.maildlp.com (Postfix) with ESMTP id B2ED01A0FC7; Tue, 18 Jun 2024 11:18:43 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP4 (Coremail) with SMTP id gCh0CgCXAQ+N_HBmFJj8AA--.12964S11; Tue, 18 Jun 2024 11:18:43 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, gregkh@linuxfoundation.org, bvanassche@acm.org, hch@infradead.org, josef@toxicpanda.com, lizefan.x@bytedance.com, hannes@cmpxchg.org Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, yukuai3@huawei.com, yukuai1@huaweicloud.com, yi.zhang@huawei.com, yangerkun@huawei.com Subject: [PATCH RFC v2 7/7] blk-iocost: support to build iocost as kernel module Date: Tue, 18 Jun 2024 11:17:51 +0800 Message-Id: <20240618031751.3470464-8-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240618031751.3470464-1-yukuai1@huaweicloud.com> References: <20240618031751.3470464-1-yukuai1@huaweicloud.com> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CM-TRANSID: gCh0CgCXAQ+N_HBmFJj8AA--.12964S11 X-Coremail-Antispam: 1UD129KBjvJXoWxCr1xCr43AF4xCr1xAFy7Wrg_yoW5CF48pF s8Ww1Yyay7KFsIgayfGwn7Xr1fJa92gFWrWa43W3sYv3yayw1xZ3WkJryrXFy8ZF43Zr43 XFW0qrWakFyUArDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUPI14x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr1j6F 4UJwA2z4x0Y4vEx4A2jsIE14v26rxl6s0DM28EF7xvwVC2z280aVCY1x0267AKxVW0oVCq 3wAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7 IYx2IY67AKxVWUJVWUGwAv7VC2z280aVAFwI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4U M4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwACI402YVCY1x02628vn2 kIc2xKxwCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E 14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_Jw0_GFylIx kGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAF wI0_Gr1j6F4UJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr 0_Gr1lIxAIcVC2z280aVCY1x0267AKxVW8Jr0_Cr1UYxBIdaVFxhVjvjDU0xZFpf9x0JUQ SdkUUUUU= X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai The motivation is that iocost is not used widely in our production, and some customers don't want to increase kernel size to enable iocost that they will never use, and it'll be painful to maintain a new downstream kernel version. Hence it'll be beneficially to build iocost as kernel module: - Kernel Size and Resource Usage, modules are loaded only when their specific functionality is required. - Flexibility and Maintainability, allows for dynamic loading and unloading of modules at runtime without the need to recompile and restart the kernel, for example we can just replace blk-iocost.ko to fix iocost CVE in our production environment. Signed-off-by: Yu Kuai --- 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 9765c988113f..33ab6e436af2 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