From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FE65C07E95 for ; Mon, 19 Jul 2021 16:29:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 778D361934 for ; Mon, 19 Jul 2021 16:29:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347294AbhGSPsh (ORCPT ); Mon, 19 Jul 2021 11:48:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:46056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349411AbhGSPpE (ORCPT ); Mon, 19 Jul 2021 11:45:04 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id AE777613ED; Mon, 19 Jul 2021 16:24:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626711896; bh=hN3qtU0dLgxD/1mxx142hFxbzrWbDbvSfmOPg1RvgpA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eBDk0aUDx42skdXOATcJkh8IHFYJ2f1YlQoTrK2sQBBfs8tv99YKRBEDL/sFFz3nN 20u3gm+NVYzMarZvvyEySLaM8t6NIgBQpCGqKo57ieerWu+eRQzMz9e04HfqTyJAQO 05axpKjSjYGfObAX6Z2sbJ6svlYpTnAHlAahV6B4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chunguang Xu , Christoph Hellwig , Jens Axboe , Sasha Levin Subject: [PATCH 5.12 172/292] block: fix the problem of io_ticks becoming smaller Date: Mon, 19 Jul 2021 16:53:54 +0200 Message-Id: <20210719144948.159839018@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210719144942.514164272@linuxfoundation.org> References: <20210719144942.514164272@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Chunguang Xu [ Upstream commit d80c228d44640f0b47b57a2ca4afa26ef87e16b0 ] On the IO submission path, blk_account_io_start() may interrupt the system interruption. When the interruption returns, the value of part->stamp may have been updated by other cores, so the time value collected before the interruption may be less than part-> stamp. So when this happens, we should do nothing to make io_ticks more accurate? For kernels less than 5.0, this may cause io_ticks to become smaller, which in turn may cause abnormal ioutil values. Signed-off-by: Chunguang Xu Reviewed-by: Christoph Hellwig Link: https://lore.kernel.org/r/1625521646-1069-1-git-send-email-brookxu.cn@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/blk-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index fc60ff208497..e34dfa13b7bc 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1255,7 +1255,7 @@ static void update_io_ticks(struct block_device *part, unsigned long now, unsigned long stamp; again: stamp = READ_ONCE(part->bd_stamp); - if (unlikely(stamp != now)) { + if (unlikely(time_after(now, stamp))) { if (likely(cmpxchg(&part->bd_stamp, stamp, now) == stamp)) __part_stat_add(part, io_ticks, end ? now - stamp : 1); } -- 2.30.2