From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752849AbbL2Jpc (ORCPT ); Tue, 29 Dec 2015 04:45:32 -0500 Received: from www.linutronix.de ([62.245.132.108]:42017 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750906AbbL2Jpb (ORCPT ); Tue, 29 Dec 2015 04:45:31 -0500 Date: Tue, 29 Dec 2015 10:44:35 +0100 (CET) From: Thomas Gleixner To: Helge Deller cc: Linux Kernel Development , linux-parisc Subject: Re: timerfd_settime/timerfd_gettime issue ? In-Reply-To: <567E8766.6020707@gmx.de> Message-ID: References: <567E8766.6020707@gmx.de> User-Agent: Alpine 2.11 (DEB 23 2013-08-11) 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 List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Helge, On Sat, 26 Dec 2015, Helge Deller wrote: > I see a strange behavior on the parisc platform, for which I'm not sure if > it's intended or if there is a bug somewhere. > The program calls timerfd_settime() and sets a timer (e.g. sec=0, nsec=100000000). > Directly after setting the timer it calls timerfd_gettime() and receives > (sec=0, nsec=103914413). > The second nsec is higher than the initial nsec value which was set. > > Does timerfd_settime() maybe tries to add the initial time it takes to start > the timer? > > Any idea or hint? Yes. This is a fallout from the power aware batching magic. Interesting that nobody noticed this within 7 years. Does the patch below fix your issue? Thanks, tglx 8<---------------- diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h index 76dd4f0da5ca..0f4a3e8734f1 100644 --- a/include/linux/hrtimer.h +++ b/include/linux/hrtimer.h @@ -268,7 +268,7 @@ static inline s64 hrtimer_get_expires_ns(const struct hrtimer *timer) static inline ktime_t hrtimer_expires_remaining(const struct hrtimer *timer) { - return ktime_sub(timer->node.expires, timer->base->get_time()); + return ktime_sub(timer->_softexpires, timer->base->get_time()); } static inline ktime_t hrtimer_cb_get_time(struct hrtimer *timer)