From patchwork Mon Nov 28 15:44:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 26824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp5750224wrr; Mon, 28 Nov 2022 07:28:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf4YhuXNr89w4TI6VdteepuX4SmolDdKUiY0cHDIQ8HkgNeHtA06Ug75zglokJgZgtAcTgH7 X-Received: by 2002:a17:906:f189:b0:7ae:3fa3:d7c6 with SMTP id gs9-20020a170906f18900b007ae3fa3d7c6mr41717438ejb.494.1669649291426; Mon, 28 Nov 2022 07:28:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669649291; cv=none; d=google.com; s=arc-20160816; b=An3oqIgKAA5EcipIqbs2FuXuzedoNl3tkn+DdZ9erJnym2TaNbr8bqD7E3y6tF7YRp WlJKg51oEGqn2mIfEpDy5INDb8VG4r0gxLQ97Rc/hhP6EO/sQ5bZS5WNNAGcXEurVwYW u92wlrg9abgmjIDQXwm0/iVtuHo0m9xEv5RRdTBJ+Cn65JbWhwWMj7X/0+YdFvscg1Q2 oYVv+9pUomZoxQ4gZqHYjqMhWOtMjODx69NhfLVpR3S90ZoQaySezPguZT90JAwXLoq8 hLDRrEjsv/hlOfqCBYL4cjEwuV2NDbu8zriyV3nIa2fK4Ao/JiLGcXPLYF2NII35l6Qk OuPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=rKWtQPmqkoY/qkWVcqIndEq8FfU71DE9FG8AJqb9uaA=; b=COA3Kz9cFG8Zi5eIXI0QjhnpPe1+3nyqKRCi9L6qInlUFexz0Z3wqQOfSNnk16uzYU bv9G9fJLOoNoayyc+QIQkb5LmRPmqe5SJZJniSUEnb+4zKKkZqOHYT7viwU/EeUlDZKu 612ezsVM276CBlGaNe1SfLlyjlC4gvO1AxzDyzSFad1dnGriKsy6ahP1m+BhFvcTE7LN 3wDeF8KkE9vUPBMYfjWmHUmRklBK+D0B7gGvhCElvXHDKffjz2KKAtkydsa91uKsYLCy LUQHCh8eQ17Xk+gcR/QS3v6AiGZWhNaP+yGcQz8y30iKMMFz4Ug7boAoLTT+OJ6Ja2er aS2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a1709064fd100b007ae814af6aasi11824858ejw.87.2022.11.28.07.27.42; Mon, 28 Nov 2022 07:28:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231734AbiK1PXu (ORCPT + 99 others); Mon, 28 Nov 2022 10:23:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60150 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231447AbiK1PXc (ORCPT ); Mon, 28 Nov 2022 10:23:32 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B341E59; Mon, 28 Nov 2022 07:23:31 -0800 (PST) Received: from dggpeml500024.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NLTk31BpDzRpG4; Mon, 28 Nov 2022 23:22:51 +0800 (CST) Received: from dggpeml500003.china.huawei.com (7.185.36.200) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 28 Nov 2022 23:23:28 +0800 Received: from huawei.com (10.175.127.227) by dggpeml500003.china.huawei.com (7.185.36.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 28 Nov 2022 23:23:28 +0800 From: Li Nan To: , , CC: , , , , , Subject: [PATCH -next 4/8] blk-iocost: read params inside lock in sysfs apis Date: Mon, 28 Nov 2022 23:44:30 +0800 Message-ID: <20221128154434.4177442-5-linan122@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221128154434.4177442-1-linan122@huawei.com> References: <20221128154434.4177442-1-linan122@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpeml500003.china.huawei.com (7.185.36.200) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1750754175356008043?= X-GMAIL-MSGID: =?utf-8?q?1750754175356008043?= From: Yu Kuai Otherwise, user might get abnormal values if params is updated concurrently. Signed-off-by: Yu Kuai Signed-off-by: Li Nan --- block/blk-iocost.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index 2bfecc511dd9..a645184aba4a 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3125,6 +3125,7 @@ static u64 ioc_qos_prfill(struct seq_file *sf, struct blkg_policy_data *pd, if (!dname) return 0; + spin_lock_irq(&ioc->lock); seq_printf(sf, "%s enable=%d ctrl=%s rpct=%u.%02u rlat=%u wpct=%u.%02u wlat=%u min=%u.%02u max=%u.%02u\n", dname, ioc->enabled, ioc->user_qos_params ? "user" : "auto", ioc->params.qos[QOS_RPPM] / 10000, @@ -3137,6 +3138,7 @@ static u64 ioc_qos_prfill(struct seq_file *sf, struct blkg_policy_data *pd, ioc->params.qos[QOS_MIN] % 10000 / 100, ioc->params.qos[QOS_MAX] / 10000, ioc->params.qos[QOS_MAX] % 10000 / 100); + spin_unlock_irq(&ioc->lock); return 0; } @@ -3319,12 +3321,14 @@ static u64 ioc_cost_model_prfill(struct seq_file *sf, if (!dname) return 0; + spin_lock_irq(&ioc->lock); seq_printf(sf, "%s ctrl=%s model=linear " "rbps=%llu rseqiops=%llu rrandiops=%llu " "wbps=%llu wseqiops=%llu wrandiops=%llu\n", dname, ioc->user_cost_model ? "user" : "auto", u[I_LCOEF_RBPS], u[I_LCOEF_RSEQIOPS], u[I_LCOEF_RRANDIOPS], u[I_LCOEF_WBPS], u[I_LCOEF_WSEQIOPS], u[I_LCOEF_WRANDIOPS]); + spin_unlock_irq(&ioc->lock); return 0; }