Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4617106pxv; Tue, 6 Jul 2021 05:25:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNekp04ZeidKDC7R+8/QCbHA677BIVyYJ5APLs21e+hCvbkCW/6gq77jGkohj6XCwTIG1P X-Received: by 2002:a05:6402:7c4:: with SMTP id u4mr22812143edy.69.1625574336070; Tue, 06 Jul 2021 05:25:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625574336; cv=none; d=google.com; s=arc-20160816; b=ZwDmOVbK7i3d3NUJhbT+ocrKiZH3ZlD+I2CxHToDt7eQUOlrir/sHDkJ/T4hjsygK7 UZBsp+3H1hU0e9YnD6VopV2nt2ot3m5KErsWB7QzZ+bmmTfkpN5hsorC0PARd59hjqDV AGR2f4S5dhEYqtwqAxuhThDK7JrvMK4TUnKxuGf7LRdt8ZRHh/xoaaDLZAZ4m1ed5Hjy ukdRDfrUtkvljLs3ndfD6yBJbCOh5UhaYkszyytaBy68IBPiBWZilsye5X9iLnZtZ+4Q 41QgfgHiWn06HS4cnImmuTJvMFR8P8Tw4MFqCQQOiy8LZyYynbBo0bXE+B8KPEdbnsyz dPTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=vrJqpbX+WWnMqAWnWXX6YjNds91UcrnpbpdIVx8fXWI=; b=zC/FBUUh87sRQq62NcEPUYxZr0FdWA8E/JKqYog5uxWeo/qitu2bb2pef5C15FWFP3 P9rpYURAqZ+KDRE3XBlbTCwvBUUd/xIAHHr7ITNAt6BTkRXyp4xSmMMSWKCBWZgItdC9 n+32vOaV8k3EZQw34wygmTFcsNGCk11QDj9sU2JhwSr7R+aRZXvXmkYDVQv1i09ZjyDt 7Crs51X7kMXN/G16Od2RsiYIhW6RQ1YyY2K0zn+wacsKM9aAa06iHXy1GgmW3PpVNpBq d/pNnXjOVyfZkWeKbBQUrzKz7xCfOlrAACSCANrojMB6NQtVJpEesXyp/y9RGEiON8xk zy2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ccoO4qSC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cq24si870967edb.242.2021.07.06.05.25.13; Tue, 06 Jul 2021 05:25:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ccoO4qSC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234999AbhGFM0i (ORCPT + 99 others); Tue, 6 Jul 2021 08:26:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245171AbhGFMMa (ORCPT ); Tue, 6 Jul 2021 08:12:30 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B781DC061762; Tue, 6 Jul 2021 05:00:26 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id h1-20020a17090a3d01b0290172d33bb8bcso1373648pjc.0; Tue, 06 Jul 2021 05:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=vrJqpbX+WWnMqAWnWXX6YjNds91UcrnpbpdIVx8fXWI=; b=ccoO4qSCaNLuC6Ruooedshrw/mmQ/wzbQbvFchhCRtKnlNncae0TDfWSjBMdaSoJh6 7O2nS7DskIYbvnRwlDgLPpmEhSXlr3XWUeHmnERD95qLqndGyXAa+Z84gmpmusJ/fPMS ZGUDiCWo91YVbc1jSBptfohZnZArDIB8GlWMGs9QuEsUPzHlekA0zQKD8LCqxa78+Vne UopKgOJ3lh/6jmGv3jR/zKiYMz1VmM1EWjTvyMkSFiMPmqwpivQy9LLCWpoz9tQQT25x w90VIMGSfYO/4l53g8e+CdFthM1nSzNIzxA5vNh4+gdQDxL3CNh3VVTynBlsysE5JU+t 4siw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=vrJqpbX+WWnMqAWnWXX6YjNds91UcrnpbpdIVx8fXWI=; b=RlEiCA3rVtTFUkeqPCXgoioz2RTOlyVlWoHFo6eQbQyHMTJPY+KXA4h/iOMJC/6Cxc j5l1Mv1gNE7bFRYs76eUe8yE8EH3c6xelh3geX5GeHcjbreN394BIB6C4wovnEZ8z6XX mm4M3lgIzg6mphdSuCAu6pWe5X/ZumDFhBiUCLQTokVQrELvf2X4W8YFXyjaFQMY5FNE cuNyxt96dFTJEzihAyvuQc8S2m0ihT4U6PeDPsNd7uWNSOs0mEY89PRVeXJmUPi7jUi7 Tjb4nj0umKYX7zHAOO4SWivU0xzgHg7ifJto5xksbz9s8PmOGUlpTz2hAGNqFl42h0gw cI6w== X-Gm-Message-State: AOAM533va3o8e+JrzUG0Qd+d6oh+lVllL/9o5Hyks/hDd18+7xVrnOWq 8dN71xNuADQvRTmw+giq6cMoU0/fVU6ZVxe0 X-Received: by 2002:a17:90b:1904:: with SMTP id mp4mr19774531pjb.29.1625572825663; Tue, 06 Jul 2021 05:00:25 -0700 (PDT) Received: from [127.0.0.1] ([203.205.141.39]) by smtp.gmail.com with ESMTPSA id w14sm20344583pgo.75.2021.07.06.05.00.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 06 Jul 2021 05:00:25 -0700 (PDT) Subject: Re: [PATCH v3] block: fix the problem of io_ticks becoming smaller To: Christoph Hellwig Cc: axboe@kernel.dk, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org References: <1625521646-1069-1-git-send-email-brookxu.cn@gmail.com> From: brookxu Message-ID: <38566226-a5d3-35c3-3e06-cdf7f3f71609@gmail.com> Date: Tue, 6 Jul 2021 20:00:22 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Christoph Hellwig wrote on 2021/7/6 13:25: > On Tue, Jul 06, 2021 at 05:47:26AM +0800, brookxu wrote: >> From: Chunguang Xu >> >> 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. >> >> v3: update the commit log >> v2: sorry, fix compile error due to the missed ')' >> >> Signed-off-by: Chunguang Xu > > The change looks good: > > Reviewed-by: Christoph Hellwig > > Although I still have trouble understanding the commit log, especially > the last sentence. Thanks for your time,5b18b5a73760 ("block: delete part_round_stats and switch to less precise counting") Merged in 5.0-rc1. Before that, we relied on in_flight to count the disk's io_ticks,as follows: static void part_round_stats_single(struct request_queue *q, struct hd_struct *part, unsigned long now, unsigned int inflight) { if (inflight) { __part_stat_add(part, time_in_queue, inflight * (now - part->stamp)); __part_stat_add(part, io_ticks, (now - part->stamp)); } part->stamp = now; } The value of io_ticks should increase monotonically before the count wraps around. However, due to the reasons mentioned above, the interrupt on the IO submission path may cause the time obtained before the interrupt to be less than part->stamp after the interrupt returns, resulting in the value of io_ticks becoming smaller than the previous value. If the user task periodically samples /proc/diskstats and calculates ioutil, since io_ticks increases non-monotonously, the difference between adjacent times may be negative, which in turn makes ioutil abnormal.Fortunately, this problem can be easily circumvented.