From patchwork Thu Jun 13 01:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695850 Received: from dggsgout11.his.huawei.com (unknown [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 56F2015E83; Thu, 13 Jun 2024 01:50:17 +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=1718243418; cv=none; b=p7dwCwf03L74kAGNA71fZjK4Mv+HL5GB8g9WJuZdLM0iD3YzzEU24qKWs8v8cU25JcbVob2TOfMuDEw9WvlQXdocmcxTKiLPj834+0KM2lkPgO78kieJvyFMZibRwMU8KQxLdeE/nZUyIs1W584wi3VHqVl7xNLh8YnF39T4hXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243418; c=relaxed/simple; bh=YIvPD7brCk1ohgELzPqSstLRQ3OgyZ58vBlizoogkBY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fIvOELUzek3T6/mHl5AW7J/peTxTq9JR0bgzRgCvdLl7fU92J8YL69iliRoM2l5avYSHIOM6GiuZLyozECE+kuiikZUTm1Tx5PNZ5FVkYfSBQNvAKtedZISSV7cYMwykEasbKOVPObVyLNC2WSHEnxktgXyA2ZWEmxKgMAkAMF4= 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 4W052K2shGz4f3kKj; Thu, 13 Jun 2024 09:50:01 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 0253F1A0EFE; Thu, 13 Jun 2024 09:50:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S5; Thu, 13 Jun 2024 09:50:07 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 1/7] kernfs: export pr_cont_kernfs_path() Date: Thu, 13 Jun 2024 09:49:31 +0800 Message-Id: <20240613014937.1326020-2-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S5 X-Coremail-Antispam: 1UD129KBjvdXoWrXF1xXFyrJr1rZr47Zr1kKrg_yoWxGFc_JF 1kG348Kw13WFy7Arn8AwsxtryF9as3uF4Fyay3Ca90yFn0ya4rJrZay3Z8ZrnxWFyjg3s3 ZFn0grZFvrW2vjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb6AFF20E14v26rWj6s0DM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28IrcIa0xkI8VA2jI8067AKxVWUGwA2048vs2IY02 0Ec7CjxVAFwI0_Gr0_Xr1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxSw2x7M28EF7xv wVC0I7IYx2IY67AKxVWDJVCq3wA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxVW8Jr0_Cr1UM2 8EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0DM2AI xVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20x vE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xv r2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2IY04 v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_ Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc40Y0x 0EwIxGrwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8 JVWxJwCI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIx AIcVC2z280aVCY1x0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7VUjFdgJUUUUU= = X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai This helper is used in iocost, prepare to build iocost as kernel module. Signed-off-by: Yu Kuai --- fs/kernfs/dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c index 458519e416fe..84ad163a4281 100644 --- a/fs/kernfs/dir.c +++ b/fs/kernfs/dir.c @@ -279,6 +279,7 @@ void pr_cont_kernfs_path(struct kernfs_node *kn) out: spin_unlock_irqrestore(&kernfs_pr_cont_lock, flags); } +EXPORT_SYMBOL_GPL(pr_cont_kernfs_path); /** * kernfs_get_parent - determine the parent node and pin it From patchwork Thu Jun 13 01:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695852 Received: from dggsgout11.his.huawei.com (unknown [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 56F84168D0; Thu, 13 Jun 2024 01:50:17 +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=1718243419; cv=none; b=aCFFRIfmRMYQ3Qxd0mA7G8+8v6nKov8yxcXGzhKO6jajdPcll5KtJgA8Zwgw8tAa6fhVt9I6dvqZH8GTqc8RS01r+IMDh55eT1+0gsbIeNUZ73OumB1ir0Q6I4vJm6N5VBt3tPJG3+p+Qe9tJv+trAUvMSTJnhwsXmUV85yxrIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243419; c=relaxed/simple; bh=37FNoyThb91+k69BH2A2XMi5p5DkUSGVuJLuAHPERM0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YZTbt+unZII6xbZt+6JNFGvRg/q4Sw+SiFHhfeOhtWD/1e3hljym2rGh4tIR3noD/MA5IFoPvz10775OgtwIG/SlKe1xe+RqUZsMLXQwVlWvejkMhMeDQIPteWf58R1A3tlw5kYRq+qDTT4kZmgOJjQD+KbF6mc86j5/yG7QCY4= 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.235]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4W052K6rY8z4f3kJs; Thu, 13 Jun 2024 09:50:01 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 876CF1A058E; Thu, 13 Jun 2024 09:50:08 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S6; Thu, 13 Jun 2024 09:50:08 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 2/7] cgroup: export cgroup_parse_float Date: Thu, 13 Jun 2024 09:49:32 +0800 Message-Id: <20240613014937.1326020-3-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S6 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 Thu Jun 13 01:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695854 Received: from dggsgout11.his.huawei.com (unknown [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 DAB737F9; Thu, 13 Jun 2024 01:50:18 +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=1718243420; cv=none; b=iD4zEMtrGx11E0yHEuIK7zCQXMzH2u/qTvrTY2hjBfV/tT+T5tRxaHGgzRwmEaP3FWEex4q4yKT3NniiKPFniw/EUdQ0k3i2y/AIiI0RjYotloO5AxES8Y+an+yt9GKnySKMq1+uucRAE1RdJxWrlTKSP3UvZd6AfbAP5wkkdy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243420; c=relaxed/simple; bh=oe8QNMwnW8SyIeciEKe/CjObH5mtNI7ifXaXJlFI0lE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X4Hr2iJKl4znUy9tDB69pC1bOcFYT8Z86v5u5D2Thsl7uFO4PXBzEpmBjA/vqWTZ4GD4RLSCdGR3JKp8InhnERYhovVgsiA8pMHDkUEPuujYEQVG0VCqOOUyzdYcycPxylS2WdxKFHzZTwa1ygpNTSTTrQ+ZWXfQJqqUwrg9mOg= 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 4W052L3RDCz4f3kKY; Thu, 13 Jun 2024 09:50:02 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 175511A1130; Thu, 13 Jun 2024 09:50:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S7; Thu, 13 Jun 2024 09:50:08 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 3/7] block: export some API Date: Thu, 13 Jun 2024 09:49:33 +0800 Message-Id: <20240613014937.1326020-4-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S7 X-Coremail-Antispam: 1UD129KBjvJXoW7ur4fWFyDuw1UXr13KrWfZrb_yoW8ZF4DpF 47Kr4fC3yjgFnrZay3W3WrX34ftw4kKF1fJ393ZrWSkFsrur1fZFnYy3WkGrySyF93AFs3 AFyY9FyUAry8Ca7anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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 37e6cc91d576..6171e546ea9f 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 Thu Jun 13 01:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695855 Received: from dggsgout12.his.huawei.com (unknown [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 610462942A; Thu, 13 Jun 2024 01:50:19 +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=1718243421; cv=none; b=BvWOduqaGKwu3Glv5ZAQ5bSdlypRDLXWTUCEL1XFAlQV2wdespRS09QMNuunp4r/N/aeNx7zDVqA3aLq8oiTlW58P2lisb2da7wLvvqmnFpkzmkakiF8lbQ5cWk+pwkajjNu30Icu4sgMFd3UR1sukiAhhC3a4zNMRU8iQhuJPo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243421; c=relaxed/simple; bh=tZUIxhOq1oKPyDJOnOD+wPtc0ZFLCgzV17pH25xpNdI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DIX5OMzLwkzXgXrkWiUF/KXssmSZNUuA6gA3MkJA3LERze0Wv0UNCJf4sF5WfIoTHT6TR4uxoGRCyRlGnndOoXPF3P2tG7mTAyWYuEtCzFkQnFvp+s+FvNIQGLzrvfkjXVrB0LTs/JqW1PNa1LDEgTQQqcBS73+pDCXs3vNhpuM= 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 4W052H47vdz4f3jXl; Thu, 13 Jun 2024 09:49:59 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 9D35C1A0572; Thu, 13 Jun 2024 09:50:09 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S8; Thu, 13 Jun 2024 09:50:09 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 4/7] blk-iocost: factor out helpers to handle params from ioc_qos_write() Date: Thu, 13 Jun 2024 09:49:34 +0800 Message-Id: <20240613014937.1326020-5-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S8 X-Coremail-Antispam: 1UD129KBjvJXoW3JrW5tr4DJw1kKF4kCF1kAFb_yoWxGryxpF Wru3sxt3y8Xrs29r1Iqr4xA3WYk397Wrn7JFWfGrySqr12yrnYq3W8CFy8uFWrJrZ3Gr1U JFWrtF4UGrWxCrJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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 690ca99dfaca..253143005086 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 Thu Jun 13 01:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695853 Received: from dggsgout11.his.huawei.com (unknown [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 DABA8ECC; Thu, 13 Jun 2024 01:50:18 +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=1718243420; cv=none; b=YgrB8RZ+OJTGUBliuQPjH08MPw+xVgVKb/2mbrMHlYJjGRK/bcK0wnlWOUfA41wWxSYaaPbD4GWRnFf2EWIzRj2mHb+NX+LaVFQ8AGtpw0z3TYlmO6bRbSUaCF/Qg0k1zpGG0Jzk8fF8OJaRDtY4Er0bvM/suiOyBy7YcoZpGjY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243420; c=relaxed/simple; bh=SWfRtPhP1+lMSHBO1po8Poq/MU5qZDtTVQnew3U+1OM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=X9EuUTi4TO2lGeq85QicVZSJxcW+ga+Ka1a7NiXI4VCi4H3unWUZ8oug+ZwOkkYAnv1DnHaHBLlsSAF9g41OfmMRdxGZo0O8X8AVNo1C9YLFFkZcTaRF9labflO0qIrRA8hdU7HLUQnJCL3nctdWfYTObt//sAbHYAmVev7ROi0= 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 4W052M3thsz4f3kKD; Thu, 13 Jun 2024 09:50:03 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 2768C1A1384; Thu, 13 Jun 2024 09:50:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S9; Thu, 13 Jun 2024 09:50:09 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 5/7] blk-iocost: parse params before initializing iocost Date: Thu, 13 Jun 2024 09:49:35 +0800 Message-Id: <20240613014937.1326020-6-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S9 X-Coremail-Antispam: 1UD129KBjvJXoWxCF45XFyDCFy5ZryxCrWDCFg_yoW5Aw4fp3 WS93sxt3yUJrs3Zr1aqr40q3W3Z34Igrn3Xr17Gr95Jr17Cr1Fya4DCry09FWrJa93AayD tFZ8JrWUKr4xCFDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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 253143005086..96a6f2292623 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 Thu Jun 13 01:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695857 Received: from dggsgout12.his.huawei.com (unknown [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 2440871B51; Thu, 13 Jun 2024 01:50:19 +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=1718243422; cv=none; b=AvSFjkkiGrfCSQuOZCXZqBE6G1k/5UpwTkAyfTnf6gqNbkWCG91gr1ItObk2sgdJIX3/6ObjBQ2laGDWsYeUl76+GShZX7VOpc6FrYyQFi5HO2d9HBE6CWZUCh0TqoKngBwvJ7PUMlSj/SYt8JkN6KBkqmPuapqfa0nGtKLoYBQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243422; c=relaxed/simple; bh=On52Isa8wUdYQHy7bPnfk+F9qQkgUd6wBqtHNXpaSP0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YyOJdomuSezy4c52KpGNL8yCEqdrkFFsdY0UKs47tAYg+NlqI61BUl5PWssIMGuy3u2vIFnEyt49diJWLgaucPWvCfKWPtUfVoOGfhwVlmp4uhMmHIfDsAFug+WTsD3DXyq+vosfOe9H9tGXYxOnVoHl2UdxNun8GnOqZjx35iQ= 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.216]) by dggsgout12.his.huawei.com (SkyGuard) with ESMTP id 4W052J4G9Gz4f3jXd; Thu, 13 Jun 2024 09:50:00 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id A4A921A1380; Thu, 13 Jun 2024 09:50:10 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S10; Thu, 13 Jun 2024 09:50:10 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 6/7] blk-iocost: support to free iocost Date: Thu, 13 Jun 2024 09:49:36 +0800 Message-Id: <20240613014937.1326020-7-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S10 X-Coremail-Antispam: 1UD129KBjvJXoWxGry5Kr4DCFWfuFy7KF43GFg_yoW5KFy7pa 1ruw1akayqqrs7urnxXr42vw1Skws2gryxG3yfG34fJrnFkr1FqF1kCryUCFy5JFZ5Zr4a vFZ5trW7Gr48ArJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 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 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 96a6f2292623..708a43a7c6a0 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 Thu Jun 13 01:49:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yu Kuai X-Patchwork-Id: 13695856 Received: from dggsgout11.his.huawei.com (unknown [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 4B0887E788; Thu, 13 Jun 2024 01:50:20 +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=1718243422; cv=none; b=pCpyC9oNL4X64C1BMB/p4fIOy2R7DP0m4bhHHOEhTWKdnV8FonOkG784GbmSI7bmOFhm1Vxq4VnKTPUaQWE6YoB/V9Y7LueuX2pfa/p36uQYA2GT9BLfMiPzH83/Kn5K+/xeAEM0198JsQY6wHSBslfQIqOsy6uV+z66KHI2WEg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718243422; c=relaxed/simple; bh=OfDv7R2e0Q9iiCmD3xqeT8MXD37MG2FQkk5TlDkCLos=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V/LLWwDDkrRK/jvdeIaPRzZUpnb1AWl7SQca/hE3WgFnoA7iYCvqFnZQfTEXgovBoYHjrRkbsxpmBQraaz2nQ3nrybSByN3ZXKB2aWf9fKr5U9VxqMi3oUg0VKodJG4JYxpS+n46e79GOZ7wogpAQawirtUt7PjLeySIFCsnENs= 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 4W052H55MYz4f3n64; Thu, 13 Jun 2024 09:49:59 +0800 (CST) Received: from mail02.huawei.com (unknown [10.116.40.112]) by mail.maildlp.com (Postfix) with ESMTP id 32C831A0185; Thu, 13 Jun 2024 09:50:11 +0800 (CST) Received: from huaweicloud.com (unknown [10.175.104.67]) by APP1 (Coremail) with SMTP id cCh0CgBXKBFNUGpm3eFSPQ--.6570S11; Thu, 13 Jun 2024 09:50:10 +0800 (CST) From: Yu Kuai To: axboe@kernel.dk, tj@kernel.org, josef@toxicpanda.com, gregkh@linuxfoundation.org, 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 -next 7/7] blk-iocost: support to build iocost as kernel module Date: Thu, 13 Jun 2024 09:49:37 +0800 Message-Id: <20240613014937.1326020-8-yukuai1@huaweicloud.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240613014937.1326020-1-yukuai1@huaweicloud.com> References: <20240613014937.1326020-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: cCh0CgBXKBFNUGpm3eFSPQ--.6570S11 X-Coremail-Antispam: 1UD129KBjvJXoW7tFyfJr4ftFy8AryfWryxAFb_yoW5Jr4UpF s8uw1Yya1UKFsIgFWfGwn7Xr1fCa4kKrWxWa43GwnYvFyaywn7Z3WkAryrXFy8ZFZxZr43 ZFW0gFsxCFyUA37anT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUUP214x267AKxVWrJVCq3wAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2048vs2IY020E87I2jVAFwI0_JF0E3s1l82xGYI kIc2x26xkF7I0E14v26ryj6s0DM28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8wA2 z4x0Y4vE2Ix0cI8IcVAFwI0_tr0E3s1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Cr1j6r xdM28EF7xvwVC2z280aVAFwI0_GcCE3s1l84ACjcxK6I8E87Iv6xkF7I0E14v26rxl6s0D M2AIxVAIcxkEcVAq07x20xvEncxIr21l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjx v20xvE14v26r1j6r18McIj6I8E87Iv67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1l F7xvr2IYc2Ij64vIr41lF7I21c0EjII2zVCS5cI20VAGYxC7M4IIrI8v6xkF7I0E8cxan2 IY04v7MxAIw28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAF wI0_Jr0_Jr4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUtVW8ZwCIc4 0Y0x0EwIxGrwCI42IY6xIIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AK xVW8Jr0_Cr1UMIIF0xvE42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJV W8JwCI42IY6I8E87Iv6xkF7I0E14v26r4UJVWxJrUvcSsGvfC2KfnxnUUI43ZEXa7VUbmZ X7UUUUU== X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ From: Yu Kuai 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 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