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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 A93EAC00306 for ; Thu, 5 Sep 2019 15:34:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2B75B206B8 for ; Thu, 5 Sep 2019 15:34:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390486AbfIEPef (ORCPT ); Thu, 5 Sep 2019 11:34:35 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43282 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727915AbfIEPef (ORCPT ); Thu, 5 Sep 2019 11:34:35 -0400 Received: from p5de0b6c5.dip0.t-ipconnect.de ([93.224.182.197] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1i5tmI-0003aH-GY; Thu, 05 Sep 2019 17:34:30 +0200 Date: Thu, 5 Sep 2019 17:34:29 +0200 (CEST) From: Thomas Gleixner To: Arul Jeniston cc: viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, arul_mc@dell.com Subject: Re: [PATCH] FS: timerfd: Fix unexpected return value of timerfd_read function. In-Reply-To: Message-ID: References: <20190816083246.169312-1-arul.jeniston@gmail.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Arul, On Thu, 5 Sep 2019, Arul Jeniston wrote: > When we adjust the date setting using date command we observed > 'timerfd_read()' on CLOCK_REALTIME (TFD_TIMER_ABSTIME flag is set) > returns 0. > we don't see any hardware influence here and we are able to recreate > it consistently. Is it expected? if yes, isn't it something to be > documented in timerfd read() man page? It's expected, yes. Simply because it hits the following condition: armtimer(T1) settime(T1 + X) --> causes timer to fire wakeup reader settime(T0) read number of intervals: 0 i.e. timer did not expire Changing the return value to 1 would be just a cosmetic workaround. We could also jump back and wait again. But that's all not consistent because armtimer(T1) settime(T1 + X) --> causes timer to fire wakeup reader read number of intervals: 1 settime(T0) user space reads time and figures that the returned tick is bogus. So I rather change the documentation (this applies only to CLOCK_REALTIME and CLOCK_REALTIME_ALARM) and explain the rationale. For applications which care about notifications when the time was set, timerfd_settime() provides TFD_TIMER_CANCEL_ON_SET which causes the timer to be canceled when time is set and returns -ECANCELED from the read. That's unambiguous. Thanks, tglx