Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2320889rwb; Wed, 30 Nov 2022 05:21:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf6i7eKwUogsGcF8Qxgl7ORAOXiVYa9pdCzzhbREho3iR+kTKNzz8nNfuWDyxLnVp7amUJrb X-Received: by 2002:a65:6753:0:b0:477:91c5:f9ff with SMTP id c19-20020a656753000000b0047791c5f9ffmr36161477pgu.403.1669814475791; Wed, 30 Nov 2022 05:21:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669814475; cv=none; d=google.com; s=arc-20160816; b=geuONrIX69Wx296RaOMEC1okZS6/M5Zv3rBxCnqCBzewC21MyOGmNEadOozDD56S8A ubQTfR1plFpcjKEbCO1e7WIThaO35WIrRq4HcdmWOqT2j2aHjBVAoE4QTC+Vpv23xuIv 9oP1usRVUiuDRQ+yLgh7KQIUlGJBfy61Sx4+jGT+2dfndJeBNSx4jkaG98g8iaYhqVQL w+RdeCpaUci7SiebBAzWGSGVkUW0lG0ahspLV8m1RXoQX+7UgI2vKUy/IvIcdXflTpRD OhOKWo03nc37kzDDw2bPfxJNQZP5vVXjUhMM0R9xXcnfMi4xaYWLhL+67shaVk0JxY5T 7E8w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j70-20020a638049000000b00462f17e560csi1255938pgd.878.2022.11.30.05.21.03; Wed, 30 Nov 2022 05:21:15 -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 + 85 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 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII 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 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 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; } -- 2.31.1