Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp290858ybg; Wed, 10 Jun 2020 00:30:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+y1BvYqiFhetpbta4LkkiDXCzwubYUnJk9a06e1H/ZaXD8KicO6TRCDSH1FelajgmeqFt X-Received: by 2002:a17:907:42d5:: with SMTP id ng5mr2141532ejb.164.1591774233407; Wed, 10 Jun 2020 00:30:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591774233; cv=none; d=google.com; s=arc-20160816; b=Ux0JvvdoWwPKNFMioxvU4BX6Z2FFswo1cei+ruxnezsJuL5MDCzHtWZWIlOR32IiDz Rl1j+4NoZFih30Y3PrIwEmL9RpdMiJ/x31nJKKneoLQ97uOR1nUTe9oFh14/yKWzIxq8 DHgGZEL2xoVVOIJCfmToqMDMKGkNTT6AP8YJcG6W9VguznLF9BoRu5/MFTxCHadn0uJs gwMfN2Am3LFZMJvvzEeQWWzRB3v6Vd4y6xYOcEcbhrqF7mk4Pl330LmCJSRHU6mlG6yt VVGIJJXMHRPzVeBBt0GxVxtdbWEeeDfQwqxxYUHVUWE5rZEk9v2ZWEOkTSNfK6bwoKoA q7Mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=icQyLe1x0JtVbH2h0JIR6glxOffDGiETwl2nJBOJkMA=; b=dCcwMxIemeThGn/AI03OzSQl5I9ivp24zOgsjujl1hfKyGJvDzembbKxa3fXgvBupb +dHMRw7bQ6SIvJac22omtH8GSe+SczoGnxl3U66QeNcf52qgGbakDDL54xl4hN9aybIR p9hSN6hHbgXPfqWXCiCFv1HT/dr5oJb9SvoHWcA5yK1Q74BdyZT5lVMffVaP80CAJ6YU xAKnEDP66vz1wmD1+BVPmVp02EXAW7abTo3SEO8b+kMGG5dB0PPXkrdaFSuERo6aX514 l4DGPnZZSu5TdOJgsyAy9FO+BxsgUi6CK3aQY2m8EOZKukUlyW7TMhhmSkyl/p6ZUW1s 6SiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netflix.com header.s=google header.b=lafpKDCM; 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=REJECT sp=REJECT dis=NONE) header.from=netflix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si1033145ejk.296.2020.06.10.00.30.09; Wed, 10 Jun 2020 00:30:33 -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=@netflix.com header.s=google header.b=lafpKDCM; 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=REJECT sp=REJECT dis=NONE) header.from=netflix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726499AbgFJH0p (ORCPT + 99 others); Wed, 10 Jun 2020 03:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726081AbgFJH0o (ORCPT ); Wed, 10 Jun 2020 03:26:44 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8019FC03E96B for ; Wed, 10 Jun 2020 00:26:44 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id t6so934074otk.9 for ; Wed, 10 Jun 2020 00:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netflix.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=icQyLe1x0JtVbH2h0JIR6glxOffDGiETwl2nJBOJkMA=; b=lafpKDCMm3DeuM+OTgu5T8Qf2tkuZ7c6gSdQPGBucRUhmFKAPhdSvHixRj+8KjzjVh 2MCDGdz9s2gyNzI/i/dH4crrvq3m86yN6v0HoLO7vO2uFk3xiBAsafLpjo39IJkocDNn OXke9WuiSjA6rE4wgV+JvZudHH+syCPya85k8= 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=icQyLe1x0JtVbH2h0JIR6glxOffDGiETwl2nJBOJkMA=; b=GWnhfNlv8LiRvJMFYJa2mQPanta+V+eSMNsfXiH5o0PKeKpFCClluHl8nms7bZ6YRr J4jcTpuEm56wUUYL9YX+qlfZrN1gHHKBQ/XT9JYsJViZVzbD+5fQhCJR6nnN8/E5Ijsh OMsXH7fJenC+8XXfBYmagFa13Tmufamehl64z1y4LjZosQKo6c19sz8XLqts7YTeRTWN Z1g/WY/69YGwpT/6rVFJ3zWDtdKjhHSWJD5ZqNqkF5H+4vTS3zKv2DblPhOtyPJEMzvF 2QPccK0oWTicRmLwg45ksCtDD0PO4GTf5sILTur9BfEumI4GOYLXG8hZhVOVzD1/bxYP 0nWg== X-Gm-Message-State: AOAM533+mnAFZCmavc1EtWk+3DQeSNCm3KzeMRqTBPhIf5F4tWbdkXcE rBdC64NtwBafKNzHhv1BJRXtkQ== X-Received: by 2002:a9d:6546:: with SMTP id q6mr1528551otl.365.1591774002683; Wed, 10 Jun 2020 00:26:42 -0700 (PDT) Received: from ?IPv6:2600:1700:3ec3:2450:25ca:3996:acb2:84a6? ([2600:1700:3ec3:2450:25ca:3996:acb2:84a6]) by smtp.gmail.com with ESMTPSA id 13sm3732094ois.44.2020.06.10.00.26.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 10 Jun 2020 00:26:41 -0700 (PDT) Subject: Re: [RFC 1/2] Eliminate over- and under-counting of io_ticks To: Hou Tao , Jens Axboe , Mikulas Patocka , Mike Snitzer Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Josh Snyder , Ming Lei References: <20200609040724.448519-1-joshs@netflix.com> <20200609040724.448519-2-joshs@netflix.com> <0b7e623e-2146-5e44-f486-ba9e1657f2a3@huawei.com> From: Josh Snyder Message-ID: Date: Wed, 10 Jun 2020 00:26:05 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <0b7e623e-2146-5e44-f486-ba9e1657f2a3@huawei.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello! On 6/9/20 6:41 PM, Hou Tao wrote: > Hi, > > For the following case, the under-counting is still possible if io2 wins cmpxchg(): > > t 0123456 > io1 |-----| > io2 |--| > stamp 0 6 > io_ticks 0 3 I hadn't noticed that bug. It looks like it can produce an unbounded quantity of undercount. > However considering patch 2 tries to improve sampling rate to 1 us, the problem will gone. Now that you mention it, the below case is also poorly handled, and will be incorrect regardless of sampling frequency. It experiences issues both under this patch (labeled io_ticks) and the current implementation (labeled io_ticks~): t 0123456 io1 |-----| io2 |-| stamp 0 56 io_ticks 28 stamp~ 0 3 56 io_ticks~ 1 34 I am beginning to doubt whether it is even possible to produce an algorithm that is simultaneously unbiased and synchronization-lite. At the same time, Ming's comment on patch 2 was leading me to wonder about the value of being synchronization-lite in the first place. At the proposed sampling rate of 1M/s, it is unlikely that we'd ever exercise the synchronization-free code path (and, as your case shows, incorrect). And for every block device that I'm aware of (even the ones that return in 10us), the cost of a disk access still completely dominates the cost of a locked CPU operation by three orders of magnitude. Josh