From patchwork Mon Oct 10 02:38:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13002229 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 24F26C433FE for ; Mon, 10 Oct 2022 02:39:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231153AbiJJCjL (ORCPT ); Sun, 9 Oct 2022 22:39:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230403AbiJJCjH (ORCPT ); Sun, 9 Oct 2022 22:39:07 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBCB53ECDF; Sun, 9 Oct 2022 19:39:04 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mm30H13b5zVhrg; Mon, 10 Oct 2022 10:34:39 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 10 Oct 2022 10:39:01 +0800 From: Kemeng Shi To: , CC: , , , Subject: [PATCH 1/4] blk-cgroup: Remove unnecessary blk_ioprio_exit in blkcg_init_queue Date: Mon, 10 Oct 2022 10:38:56 +0800 Message-ID: <20221010023859.11896-2-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221010023859.11896-1-shikemeng@huawei.com> References: <20221010023859.11896-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Function blk_ioprio_init only alloc blkg_policy_data which will be freed in blkg_destroy_all, so no blk_ioprio_exit is called when blk_throtl_init is failed in blkcg_init_queue. Also blk_ioprio_exit is not called in blkcg_exit_queue for the same reason. Just remove blk_ioprio_exit to keep behavior consistent. Signed-off-by: Kemeng Shi --- block/blk-cgroup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 869af9d72bcf..bc4dec705572 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1302,7 +1302,6 @@ int blkcg_init_queue(struct request_queue *q) ret = blk_iolatency_init(q); if (ret) { blk_throtl_exit(q); - blk_ioprio_exit(q); goto err_destroy_all; } From patchwork Mon Oct 10 02:38:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13002227 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 63C1EC4332F for ; Mon, 10 Oct 2022 02:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231124AbiJJCjJ (ORCPT ); Sun, 9 Oct 2022 22:39:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230376AbiJJCjH (ORCPT ); Sun, 9 Oct 2022 22:39:07 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 560B34A82E; Sun, 9 Oct 2022 19:39:05 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.55]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Mm30729D2zmV93; Mon, 10 Oct 2022 10:34:31 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 10 Oct 2022 10:39:02 +0800 From: Kemeng Shi To: , CC: , , , Subject: [PATCH 2/4] blk-cgroup: correct comment for blk_alloc_queue and blk_exit_queue Date: Mon, 10 Oct 2022 10:38:57 +0800 Message-ID: <20221010023859.11896-3-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221010023859.11896-1-shikemeng@huawei.com> References: <20221010023859.11896-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Since commit 1059699f87eb("block: move blkcg initialization/destroy into disk allocation/release handler"), blk_alloc_queue and blk_exit_queue is called directly from gendisk. Update the corresponding comment. Signed-off-by: Kemeng Shi --- block/blk-cgroup.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index bc4dec705572..463c568d3e86 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1259,7 +1259,7 @@ static int blkcg_css_online(struct cgroup_subsys_state *css) * blkcg_init_queue - initialize blkcg part of request queue * @q: request_queue to initialize * - * Called from blk_alloc_queue(). Responsible for initializing blkcg + * Called from gendisk. Responsible for initializing blkcg * part of new request_queue @q. * * RETURNS: @@ -1321,7 +1321,7 @@ int blkcg_init_queue(struct request_queue *q) * blkcg_exit_queue - exit and release blkcg part of request_queue * @q: request_queue being released * - * Called from blk_exit_queue(). Responsible for exiting blkcg part. + * Called from gendisk. Responsible for exiting blkcg part. */ void blkcg_exit_queue(struct request_queue *q) { From patchwork Mon Oct 10 02:38:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13002226 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 059D6C433F5 for ; Mon, 10 Oct 2022 02:39:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230497AbiJJCjI (ORCPT ); Sun, 9 Oct 2022 22:39:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230202AbiJJCjH (ORCPT ); Sun, 9 Oct 2022 22:39:07 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 800014A82F; Sun, 9 Oct 2022 19:39:05 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mm2zf0m1jzHv7N; Mon, 10 Oct 2022 10:34:06 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 10 Oct 2022 10:39:03 +0800 From: Kemeng Shi To: , CC: , , , Subject: [PATCH 3/4] blk-cgroup: Add NULL check of pd_alloc_fn in blkcg_activate_policy Date: Mon, 10 Oct 2022 10:38:58 +0800 Message-ID: <20221010023859.11896-4-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221010023859.11896-1-shikemeng@huawei.com> References: <20221010023859.11896-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Function blkcg_policy_register only make sure pd_alloc_fn and pd_free_fn in pairs, so pd_alloc_fn could be NULL in registered blkcg_policy. Check NULL before use for pd_alloc_fn in blkcg_activate_policy to avoid protential NULL dereference. Signed-off-by: Kemeng Shi --- block/blk-cgroup.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index 463c568d3e86..fc083c35dc42 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -1404,6 +1404,9 @@ int blkcg_activate_policy(struct request_queue *q, if (blkcg_policy_enabled(q, pol)) return 0; + if (pol->pd_alloc_fn == NULL) + return -EINVAL; + if (queue_is_mq(q)) blk_mq_freeze_queue(q); retry: From patchwork Mon Oct 10 02:38:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kemeng Shi X-Patchwork-Id: 13002230 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 1F0CEC433F5 for ; Mon, 10 Oct 2022 02:39:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231158AbiJJCjM (ORCPT ); Sun, 9 Oct 2022 22:39:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230210AbiJJCjH (ORCPT ); Sun, 9 Oct 2022 22:39:07 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E37C4A839; Sun, 9 Oct 2022 19:39:06 -0700 (PDT) Received: from kwepemi500016.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4Mm2zf5KnMzHv7H; Mon, 10 Oct 2022 10:34:06 +0800 (CST) Received: from huawei.com (10.174.178.129) by kwepemi500016.china.huawei.com (7.221.188.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 10 Oct 2022 10:39:03 +0800 From: Kemeng Shi To: , CC: , , , Subject: [PATCH 4/4] blk-cgroup: Fix typo in comment Date: Mon, 10 Oct 2022 10:38:59 +0800 Message-ID: <20221010023859.11896-5-shikemeng@huawei.com> X-Mailer: git-send-email 2.14.1.windows.1 In-Reply-To: <20221010023859.11896-1-shikemeng@huawei.com> References: <20221010023859.11896-1-shikemeng@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.178.129] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemi500016.china.huawei.com (7.221.188.220) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Replace assocating with associating. Replace assocaited with associated. Signed-off-by: Kemeng Shi Acked-by: Tejun Heo --- block/blk-cgroup.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index fc083c35dc42..f723901ef9b9 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c @@ -205,7 +205,7 @@ static inline struct blkcg *blkcg_parent(struct blkcg *blkcg) * @q: request_queue the new blkg is associated with * @gfp_mask: allocation mask to use * - * Allocate a new blkg assocating @blkcg and @q. + * Allocate a new blkg associating @blkcg and @q. */ static struct blkcg_gq *blkg_alloc(struct blkcg *blkcg, struct request_queue *q, gfp_t gfp_mask) @@ -602,7 +602,7 @@ EXPORT_SYMBOL_GPL(blkcg_print_blkgs); * @pd: policy private data of interest * @v: value to print * - * Print @v to @sf for the device assocaited with @pd. + * Print @v to @sf for the device associated with @pd. */ u64 __blkg_prfill_u64(struct seq_file *sf, struct blkg_policy_data *pd, u64 v) { @@ -802,7 +802,7 @@ EXPORT_SYMBOL_GPL(blkg_conf_prep); /** * blkg_conf_finish - finish up per-blkg config update - * @ctx: blkg_conf_ctx intiailized by blkg_conf_prep() + * @ctx: blkg_conf_ctx initialized by blkg_conf_prep() * * Finish up after per-blkg config update. This function must be paired * with blkg_conf_prep().