Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1864625ybb; Sun, 29 Mar 2020 15:36:55 -0700 (PDT) X-Google-Smtp-Source: ADFU+vs0K9r9D5rIHYPw1IcXRH2zpW4yHKX93SjCF3UNE8Dm13t6VXCCln7Hw6GSVxLJjBH/2qQE X-Received: by 2002:a9d:2074:: with SMTP id n107mr6938872ota.306.1585521415464; Sun, 29 Mar 2020 15:36:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585521415; cv=none; d=google.com; s=arc-20160816; b=K95an5ffJrH01vWV9OxRUkLNoV4rAzRqrotc8lZJJ+WtmsyFmRTtS3xTySNLHFf6mM bKC28pIlq1kd9OLVe8nhGVHGoEkVM+ZOBhBEN1fll5W9FI5F6sPLEKxz1EqjjFMWnc6W Qh2m4lpyrlCDYGpzCy5l+QncTKqzOs8EvkmT8cyKcXwO+l3MPNEU2XeMPEhBDu9NFYdB iCuZicIIZBV+gcAZIWaOckG54jB4/Sx9d3DIgZiDnwX3gKIFDUDdzhyVUdfFA+q9JM6t 2+IvKGEbke9wcTtfq9Vs9HcRTnEWIts2F6ebDoinmeRm75Ltz9Z2XkiWkZnXcA4YBJVi 7YIg== 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:to:subject:cc:dkim-signature; bh=icwY7JIFcNczEa1rCrz7zrplk1TvJEdie0LkxroVzWg=; b=fL3HqJLIsT4no4aMEHYzHoyoaog3Shlf2BGS5nZeEwceNw0e/Q9Bj7SwDRdloPuzR6 NlUMiFnRiD4JiiPMOwN5x23Iw89Gx5B2CGjfQPR2l5u73aXgGZVsTpFiRl+EWGewN+52 ZcPcgRRE4qFnhWQdpW5lt/6kMYbsp9sGAW755fGk9JP+2BWpX33YL5OQd5POUzO/VX86 5hhVL5+OLdkM2qVJwmtU3LNweEwNp42Oi1f2HLMgzd0JvziyFSkoSW+xVXhUQnFJJ34e JSsuxl4Zcsm9wZ6TMkAybgv98f596mz7BY3vd9JRCX7LIQ8nVTV/Q3d+8GbxADRSeFDN YJYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Sv9/5Zmf"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id y6si5161795ooj.61.2020.03.29.15.36.43; Sun, 29 Mar 2020 15:36:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Sv9/5Zmf"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1728783AbgC2VG4 (ORCPT + 99 others); Sun, 29 Mar 2020 17:06:56 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:37384 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728481AbgC2VGz (ORCPT ); Sun, 29 Mar 2020 17:06:55 -0400 Received: by mail-wm1-f66.google.com with SMTP id j19so393973wmi.2; Sun, 29 Mar 2020 14:06:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=cc:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=icwY7JIFcNczEa1rCrz7zrplk1TvJEdie0LkxroVzWg=; b=Sv9/5ZmfHgCEsGzy74Xlpdr60eIaBDmv+LW+X7slbOZ+z8rWlv41w+lp6hgWjCFhf3 3mmAMuQaMBWJuRtlcC87+H5WIAEZnK9n6fBbXphEVi7ePV3CrjMQfOHl39R/xcC2XaSh vYqe10TblJsi83bDFppEzNOvSeuBqIg4El1CFG6oAnrCPP+Z/4+YwByD+yO4zT4IK5xD WTqoVNFoWxbwOhdSiGA6ANlQuiNE3FKoTqfsOOuhIdqHUX/xd8ttPKcTOIN5fKHnkK7c 6rmBAzml/6IDYO/qJb5p6sIQKuB/FsFzVzCEiJNxSnUK1WFrysabFL7IHXHQu8GMmbSv zmcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:cc:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=icwY7JIFcNczEa1rCrz7zrplk1TvJEdie0LkxroVzWg=; b=Mn8PENeAAfDw4HOb43qUeyem5XoAPfz46hoV6ZB/IXyJl6Jdr/UCyy6YLbUZuPMDpx GRqDxMIzESF4lZMwFpF/nF5L7kX09Ca1ktpy4f7FS5teW+ZBL8V7b+rXBqlEeLSlspuq TnWmkj7kswgGvVCPCa8y5QaO9pAz17dWUrpCGAYWrqUNWe5yGUeRlvaBXzdF7v8l4qV7 GbTjvDOGlZ7wJeJGV363endw5CBdmiYk6c1dN5Qc/WdPY94/PhcrCH8FOn0T6MfUSqKT sO6Mk8l4/CgdjMvRL1k7RpGAfwU7TlWvPWsnXalN72+74FRLuTsBbiVWy6tijwHxItWC xE9g== X-Gm-Message-State: ANhLgQ0LXmkzroUBuOLnIoNjY6sK23EZL7gmxKxcEby/EV2tDG7Ohxxl NsoIL2S2+CHVkU+yyQf6MYwm84Yp X-Received: by 2002:a1c:e914:: with SMTP id q20mr9668763wmc.105.1585516012641; Sun, 29 Mar 2020 14:06:52 -0700 (PDT) Received: from ?IPv6:2001:a61:2482:101:3351:6160:8173:cc31? ([2001:a61:2482:101:3351:6160:8173:cc31]) by smtp.gmail.com with ESMTPSA id u11sm18769238wrt.29.2020.03.29.14.06.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Mar 2020 14:06:52 -0700 (PDT) Cc: mtk.manpages@gmail.com, linux-man@vger.kernel.org, Thomas Gleixner , lkml , arul.jeniston@gmail.com Subject: Re: [PATCH] timerfd_create.2: Included return value 0 To: "devi R.K" References: <55aa30be-5894-ae52-ffd4-5f2a82aa5ad5@gmail.com> From: "Michael Kerrisk (man-pages)" Message-ID: <3cbd0919-c82a-cb21-c10f-0498433ba5d1@gmail.com> Date: Sun, 29 Mar 2020 23:06:49 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: 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 [CC widened] Hello Devi, [It's best not to top post. I've rearranged the reply for readability.] [Greetings, Thomas; now I recall a conversation we had in Lyon :-) ] On 3/27/20 5:29 AM, devi R.K wrote: > > On Thu, Mar 26, 2020 at 2:16 PM Michael Kerrisk (man-pages) < > mtk.manpages@gmail.com> wrote: > >> Hello Devi, >> >> On 3/18/20 3:04 PM, devi R.K wrote: >>> Added a return value 0 for timerfd_read which happens when there is a >>> bigger backward time drift*.* >>> >>> Signed-off-by: DEVI RK >> >> Can you say some more please about how you verified this and/or >> point me at the relevant kernel source code? At a simple attempt, >> I can't replicate the behavior you describe. > We have written a program using real time clock and it has been raised to > the community. > > https://lore.kernel.org/lkml/alpine.DEB.2.21.1908191943280.1796@nanos.tec.linutronix.de/T/ It would be helpful if you had pointed me to this in the first place, and also CCed the people from that earlier discussion. I've widened the CC list. Thanks for pointing me at that thread. In particular, the test program at https://lore.kernel.org/lkml/alpine.DEB.2.21.1908191943280.1796@nanos.tec.linutronix.de/T/#m489d81abdfbb2699743e18c37657311f8d52a4cd I've now replicated this behavior with a program of my own. >>> --- >>> man2/timerfd_create.2 | 4 ++++ >>> 1 file changed, 4 insertions(+) >>> >>> diff --git a/man2/timerfd_create.2 b/man2/timerfd_create.2 >>> index 066e0be..ccced98 100644 >>> --- a/man2/timerfd_create.2 >>> +++ b/man2/timerfd_create.2 >>> @@ -317,6 +317,10 @@ fails with the error >>> if the real-time clock undergoes a discontinuous change. >>> (This allows the reading application to discover >>> such discontinuous changes to the clock.) >>> +.IP >>> +A >>> +.BR read (2) >>> +may return 0 if the system clock undergoes a discontinuous change. >>> .TP >>> .BR poll "(2), " select "(2) (and similar)" >>> The file descriptor is readable I think this patch does not really capture the details properly. The immediately preceding paragraph says: If the associated clock is either CLOCK_REALTIME or CLOCK_REALTIME_ALARM, the timer is absolute (TFD_TIMER_ABSTIME), and the flag TFD_TIMER_CANCEL_ON_SET was specified when calling timerfd_settime(), then read(2) fails with the error ECANCELED if the real-time clock undergoes a discontinuous change. (This allows the reading application to discover such discontinuous changes to the clock.) Following on from that, I think we should have a pargraph that says something like: If the associated clock is either CLOCK_REALTIME or CLOCK_REALTIME_ALARM, the timer is absolute (TFD_TIMER_ABSTIME), and the flag TFD_TIMER_CANCEL_ON_SET was not specified when calling timerfd_settime(), then a discontinuous negative change to the clock (e.g., clock_settime(2)) may cause read(2) to unblock, but return a value of 0 (i.e., no bytes read), if the clock change occurs after the time expired, but before the read(2) on the timerfd file descriptor. This seems consistent with Thomas's observations in https://lore.kernel.org/lkml/alpine.DEB.2.21.1908191943280.1796@nanos.tec.linutronix.de/T/#m49b78122b573a2749a05b720dc9fa036546db490 Do you agree? Thomas, if you had a moment, your input would, as always, be appreciated. Cheers, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/