Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2313184pxb; Mon, 19 Apr 2021 02:41:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyg/wQidrB5CuoBUs/6JhuS2LJ2MzIfmrnxDTUhtsav+zTdiG89SRu25bpC8l9YsJnbIbZ X-Received: by 2002:a05:6a00:b87:b029:257:b86:5cbf with SMTP id g7-20020a056a000b87b02902570b865cbfmr19006030pfj.15.1618825292251; Mon, 19 Apr 2021 02:41:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618825292; cv=none; d=google.com; s=arc-20160816; b=MHaEEt1YqRZUnql2ih3jwmOQpXTXudcMwLCC4sXa9HWuqhbnWSK8OuZOkY4d2PcLYO ttUv1iPdMzmsOssh5o3eEE9KeBDl+6H5qjjvZJrT9bPRxzgapqXEtDbanN6rBDpZjzRT Vuh79Ttd3ad9PatTTBqG3XFMM/6BdIZJIr7vaqSeRPEzzMl2Owxp7fLk/PB9cUZipWgO o04irl3X+BRtifbqaMv9WVgYl+xD97SvgufqzMw+lbgMV70B/n0qalTz9I2QAUbEGciP UoXUhzhVqLxOI6i1Z/VMQvTJy4+00sH8DiSIzridvSmn19dHf8v17XP/72Ls8i7XNSE1 egZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=roRzewFrTcsPJsCWhsNYX+IusFZhyqP8k41ANmvMG84=; b=Bptpi0yqkTzB6Z2qi/U4NDK7SpbErkFxlRTSMwu45mGetM1qjkDHD7UxBIUVzEGt76 s5DnoOz39I8D7o08tB1zaZe2LG/tDCAKqXsRjHeilrWW6/uEaQVt8hGUBT1EGpMIB+xl VHq5iUqYNBENkJGShY5c3cnxiWehzzc5QdtWdNws8bXWz2pKKjr3SLuGuV5JljfRUF9W vB3WjJZGbEMfT0r4RgOnkqZbva3FlzQvhqNWXaLAT3Ih6WPofO9GdLEi2nCpJ4qISS4J N+cx1qb4qI5kjNRefXzwhsjZ2cEHkFJ5QBtmTLpDLot0OgL8UKdcxleZQMSs2T/bYxDN Gquw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u22si16823980pjr.135.2021.04.19.02.41.18; Mon, 19 Apr 2021 02:41:32 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238174AbhDSJeh (ORCPT + 99 others); Mon, 19 Apr 2021 05:34:37 -0400 Received: from szxga08-in.huawei.com ([45.249.212.255]:3340 "EHLO szxga08-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237860AbhDSJeg (ORCPT ); Mon, 19 Apr 2021 05:34:36 -0400 Received: from DGGEML403-HUB.china.huawei.com (unknown [172.30.72.57]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4FP1kg29bRz14J9b; Mon, 19 Apr 2021 17:30:19 +0800 (CST) Received: from dggpemm500023.china.huawei.com (7.185.36.83) by DGGEML403-HUB.china.huawei.com (10.3.17.33) with Microsoft SMTP Server (TLS) id 14.3.498.0; Mon, 19 Apr 2021 17:33:59 +0800 Received: from [10.174.187.128] (10.174.187.128) by dggpemm500023.china.huawei.com (7.185.36.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Mon, 19 Apr 2021 17:33:58 +0800 Subject: Re: [PATCH v6 03/10] KVM: selftests: Use flag CLOCK_MONOTONIC_RAW for timing To: David Laight , Paolo Bonzini CC: Vitaly Kuznetsov , Andrew Jones , Ben Gardon , Sean Christopherson , Peter Xu , "wanghaibin.wang@huawei.com" , "yuzenghui@huawei.com" , kvm , "linux-kselftest@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20210330080856.14940-1-wangyanan55@huawei.com> <20210330080856.14940-4-wangyanan55@huawei.com> <1f892f30-1a72-1bcb-462f-b3d6f2bababb@redhat.com> <82def592-e36c-25c3-c8c5-84c9be83e926@huawei.com> <8f36c1973c8147858000dd2a28d046ce@AcuMS.aculab.com> From: "wangyanan (Y)" Message-ID: <4ab0ec23-51c7-0258-4776-3268120f0c9e@huawei.com> Date: Mon, 19 Apr 2021 17:33:58 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <8f36c1973c8147858000dd2a28d046ce@AcuMS.aculab.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Originating-IP: [10.174.187.128] X-ClientProxiedBy: dggeme711-chm.china.huawei.com (10.1.199.107) To dggpemm500023.china.huawei.com (7.185.36.83) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/4/19 16:22, David Laight wrote: > From: wangyanan (Y) >> Sent: 19 April 2021 07:40 >> >> Hi Paolo, >> >> On 2021/4/17 21:23, Paolo Bonzini wrote: >>> On 30/03/21 10:08, Yanan Wang wrote: >>>> In addition to function of CLOCK_MONOTONIC, flag CLOCK_MONOTONIC_RAW can >>>> also shield possiable impact of NTP, which can provide more robustness. >>>> >>>> Suggested-by: Vitaly Kuznetsov >>>> Signed-off-by: Yanan Wang >>>> Reviewed-by: Ben Gardon >>>> Reviewed-by: Andrew Jones >>> I'm not sure about this one, is the effect visible? >>> >> In practice, difference between results got with CLOCK_MONOTONIC and >> CLOCK_MONOTONIC_RAW >> actually is too little to be visible. But if just in theory, >> CLOCK_MONOTONIC_RAW can ensure time results >> of the compared tests are based on the same local oscillator frequency, >> which is not subject to possible >> NTP frequency adjustment. Change in this patch seems like a bit of >> optimization. > The real annoyance is when NTP is realigning the local clock. > This typically happens after boot - but can take quite a few > minutes (don't think it can quite get to an hour). > (I think something similar is caused by leap seconds.) > > During this period CLOCK_MONOTONIC can run at a significantly > different rate from 'real time'. > This may not matter for timing self tests, but is significant > for RTP audio. > > The problem there is that you want the NTP corrected time > during 'normal running' because the small correction (for > crystal error) is useful. > > But the kernel HR timers are only defined for CLOCK_MONOTONIC > and the userspace requests for CLOCK_MONOTONIC_RAW are likely > to be real system calls. > > What you really want is a clock whose frequency is adjusted > by NTP but doesn't have the NTP offset adjuctments. > In reality this ought to be CLOCK_MONOTONIC. Hi David, I see now, much thanks for the above explanation. :) Still have a lot to learn about this part. Thanks, Yanan > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales)