Received: by 2002:a05:6358:700f:b0:131:369:b2a3 with SMTP id 15csp3207422rwo; Fri, 4 Aug 2023 00:42:50 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEYp/wqjsBvCTPnimLT/TRYQ3udCyw4erghzGZr1XB9CR7BUUoK7DbNHyUpj1XKVEebBX6K X-Received: by 2002:a17:906:29c:b0:957:1df0:9cbf with SMTP id 28-20020a170906029c00b009571df09cbfmr787182ejf.19.1691134970643; Fri, 04 Aug 2023 00:42:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691134970; cv=none; d=google.com; s=arc-20160816; b=t2brmFXSjKCiu8nXZ54Og7In/9FmOuAwREsmmOaoULcTcunstGNkwuwVlgY54NVnm8 EILuOZL4E5q7w7jID5Di7YpsFebReoRwYIKBcl1IxUIsIJLTxDfMCS8NwEhRnp42be0x EhzNCMbUimXDbqta0JjCvybD9471hfHgGQL9SRIs2+Vz/26l8YPKw+d7T6ntBwrDHHf3 w/DwoUBN9GCl9EF+l8kLM6Ql/rpWU6JfaTfK+0VUNnGTysoIQCKvxCCp0vCyHMNOHfcH BXxmIKaXPLBOCjY89PJRj4YYCMcl1GFT0sG9Zut6VGBfk1XtLztKR3ZmoQ1WqJlLB3mZ XGBA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=N+PDNOldMLpWe69wkWNroeRQ0YSGNugCwYgD/y+ooro=; fh=rbyAJ3ME9g2AsrDBd2CuGS+Z44kd8C7olZkunm5Y8wc=; b=cUpe8YwQTorzVuyqKKzwECKZBuJz48TYaAVst8mudcQPYQc2Zn5EPWZA+Q5cBTByx4 774uDhRb3rB6Oi5iUybc63dK9FnwtxHvSubPjZwkRiuoalXgigRTiKV7bXyXb33RUmX/ PsVHDqG4wdpNH8aK7T+4nTa0DX5LnOyJ/AONd1CmzuhDoC9xiifUI6mD7WzgcMUzkYFt zs+nAPVJEh2ww1VADMXUYFLUKblb4RXUDDztpmNC4EhzLfQOcv4qOtjfPjRZbaCDo9N9 zvlNMVeS40X8C68949i6pTH7LcUfV++5mQXeYbSNwGU024CmHQv99YfIKkusc2/fAMOO pxEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=wWYdynmW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a1709067d9200b00993629db66csi26903ejo.226.2023.08.04.00.42.18; Fri, 04 Aug 2023 00:42:50 -0700 (PDT) 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; dkim=pass header.i=@linux.dev header.s=key1 header.b=wWYdynmW; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233969AbjHDHGs (ORCPT + 99 others); Fri, 4 Aug 2023 03:06:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233957AbjHDHGr (ORCPT ); Fri, 4 Aug 2023 03:06:47 -0400 Received: from out-90.mta1.migadu.com (out-90.mta1.migadu.com [95.215.58.90]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1AD621724; Fri, 4 Aug 2023 00:06:46 -0700 (PDT) X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1691132804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=N+PDNOldMLpWe69wkWNroeRQ0YSGNugCwYgD/y+ooro=; b=wWYdynmWr8j2Zpj7xMyOAs3ezXwF7tkwWlomyVRAePrtrisQ9F1QoabhoFgJiY2j1udwyP YjkEZ127YkooBA7JmZZVq+cy9rtCJLeEdG5gnmzrq/dxIwl+TGD24r+BppOHvGctzkLEnC S3lZWg0en8KKb6y+Rr3NBbobqsJqMWQ= From: chengming.zhou@linux.dev To: tj@kernel.org, axboe@kernel.dk, josef@toxicpanda.com Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, zhouchengming@bytedance.com Subject: [PATCH] blk-iocost: fix queue stats accounting Date: Fri, 4 Aug 2023 15:06:09 +0800 Message-ID: <20230804070609.31623-1-chengming.zhou@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: Chengming Zhou The q->stats->accounting is not only used by iocost, but iocost only increase this counter, never decrease it. So queue stats accounting will always enabled after using iocost once. Signed-off-by: Chengming Zhou --- block/blk-iocost.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/blk-iocost.c b/block/blk-iocost.c index dd64e2066f01..089fcb9cfce3 100644 --- a/block/blk-iocost.c +++ b/block/blk-iocost.c @@ -3301,11 +3301,12 @@ static ssize_t ioc_qos_write(struct kernfs_open_file *of, char *input, if (qos[QOS_MIN] > qos[QOS_MAX]) goto einval; - if (enable) { + if (enable && !ioc->enabled) { blk_stat_enable_accounting(disk->queue); blk_queue_flag_set(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); ioc->enabled = true; - } else { + } else if (!enable && ioc->enabled) { + blk_stat_disable_accounting(disk->queue); blk_queue_flag_clear(QUEUE_FLAG_RQ_ALLOC_TIME, disk->queue); ioc->enabled = false; } -- 2.41.0