From patchwork Wed Nov 30 13:21:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Nan X-Patchwork-Id: 27782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp908962wrr; Wed, 30 Nov 2022 05:01:44 -0800 (PST) X-Google-Smtp-Source: AA0mqf4WqmgktBdxdZheKQHysYFn6Qt/o6SfBrQidh8jrPUhTQM5v0MQGViK+Q0eJlF3EjDvTynk X-Received: by 2002:a17:90a:d34d:b0:218:a0ce:9d5e with SMTP id i13-20020a17090ad34d00b00218a0ce9d5emr54757347pjx.96.1669813304603; Wed, 30 Nov 2022 05:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669813304; cv=none; d=google.com; s=arc-20160816; b=WaH9ZcEGWfKa72V2cwiGTeETq07MtyGQd3+VD1TW4cAtk2VrJTqhkrcID8PUwjfyXz dn0IDZojuPXylQf2ryQbxZO93wk4tsRmJF0L3Prfs4f/WKlrJc2cZ0arpNNb/G+bWUAN Oev13XpIs+KqiwWcdb4dvgVkyZJGJX0uONg9PvnPcns0edjvpdNzlGy9XB2zsDjvebPu jLNRuakRNJtaAmmhTMEY7iKMYNcocI4zhcCcYkgdDQKm/POf06bMsLetUbtODM4HjBZy XSQ+Xn02LLAiQoxy6OmqJGcbojGxiiB5vdQ5BB4eyHke1U8OjF9iPUrimJp1p0WwE4Es gwSg== 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=zO4jYYKRQsPemUQc8y7lZXqTFrEF9fekid4csQmKyfk=; b=Bu/0+jPafuF7UwVdGO4RxuI8M4e5jARc32q6f6xJSovfuQe5Iw+m7T4uClB99ll8/a 4q9MD85bfDhRjU0Cuv54hHPbH1MXWNQMXzeNTUH9O24XgAKroSi4u034LmxTKVUwA4al VwadAmmq50jtF3qgK1D3tEiKBv/ck20+rihd3tBvS+smnFNT8dIJ6fN5w/swIoH11u+Q 7/tqA4jJUq3BlQHzBjencgvq06rQLFRzu26PDa+5jjXRLYKieWVCb/XBAz8s9QKjzYYg zuuF1KCPtPuOcWTgVAhiE6rTbzrZLwxZURXS57fs1MhDGVdDdPni0vkwr4tTLk/JXMEk 6+GA== 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 il11-20020a17090b164b00b0020d4f9a4b4dsi1654797pjb.49.2022.11.30.05.01.31; Wed, 30 Nov 2022 05:01:44 -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 S235577AbiK3NBG (ORCPT + 99 others); Wed, 30 Nov 2022 08:01:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232822AbiK3NA4 (ORCPT ); Wed, 30 Nov 2022 08:00:56 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E8C429B1; Wed, 30 Nov 2022 05:00:54 -0800 (PST) Received: from dggpeml500026.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NMfSX2sz3zRpdX; Wed, 30 Nov 2022 21:00:12 +0800 (CST) Received: from dggpeml500003.china.huawei.com (7.185.36.200) by dggpeml500026.china.huawei.com (7.185.36.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 30 Nov 2022 21:00:52 +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; Wed, 30 Nov 2022 21:00:52 +0800 From: Li Nan To: , , CC: , , , , , Subject: [PATCH -next v2 4/9] blk-iocost: read params inside lock in sysfs apis Date: Wed, 30 Nov 2022 21:21:51 +0800 Message-ID: <20221130132156.2836184-5-linan122@huawei.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20221130132156.2836184-1-linan122@huawei.com> References: <20221130132156.2836184-1-linan122@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.127.227] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) 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?1750926155394162347?= X-GMAIL-MSGID: =?utf-8?q?1750926155394162347?= From: Yu Kuai Otherwise, user might get abnormal values if params is updated concurrently. Signed-off-by: Yu Kuai Signed-off-by: Li Nan Acked-by: Tejun Heo --- block/blk-iocost.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index bc6522bb314d..3a96cd557c47 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; }