Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760032AbbEEQKh (ORCPT ); Tue, 5 May 2015 12:10:37 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:64924 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2993408AbbEEPdU (ORCPT ); Tue, 5 May 2015 11:33:20 -0400 From: Arnd Bergmann To: Alan Stern Cc: Tina Ruchandani , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Pete Zaitcev Subject: Re: [PATCH] USB: usbmon: Remove timeval usage for timestamp Date: Tue, 05 May 2015 17:33:03 +0200 Message-ID: <4657648.5HP9obPUcU@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Provags-ID: V03:K0:dZbmeO/eTReW/9CSqbKLhDwHBtoV7YwZJpDctLSeWR7ZcRGb+Ld twGrCcjE11pD16A9zo15Qi3fmt7TauBX98EspCRf6z+1ShDCdrjlHbZ27jH8NhSklE58ulB 96ZcSiMLx0Dkr9mdVUTy0hplegxcSCoTznJiW+MTwGGx1Mfb+650q2Mji1pzuMoXjgW4ykn QqhKf6xF27IIt0MAVhZ+A== X-UI-Out-Filterresults: notjunk:1; Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2213 Lines: 51 On Tuesday 05 May 2015 10:59:32 Alan Stern wrote: > On Tue, 5 May 2015, Arnd Bergmann wrote: > > > Your conversion looks entirely correct, but the original code is a bit > > odd here as it does not use the entire range of the 32-bit microsecond > > value, and counts from 0 to 4096000000us instead of the more intuitive > > 0 to 4294967296 us range before wrapping around. > > > > If we change the code to > > > > static inline unsigned int mon_get_timestamp(void) > > { > > return ktime_to_us(ktime_get_real()); > > } > > > > it might be more obvious what is going on, but it would slightly change > > the output in the debugfs file to use the full range. Do we know what > > behavior is expected by normal user space here? Pete Zaitcev submitted > > a patch for this behavior in 2010, he might remember something about it. > > I don't know of any programs that use the timestamp value, but if some > do exist then the way overflow works should not be changed. > > In my experience, the timestamps are used by humans reading the usbmon > output. Overflow is rare, but when it does occur, a human finds it > much easier to wrap from 4095.999999 seconds to 0.000000 than to wrap > from 4294.967295 to 0.000000. > > (Also, in the rare cases where usbmon timestamps have to be matched up > with printk timestamps, it's easier to figure the relative offset when > overflow affects only the seconds, not the fractions of a second.) Ok, got it. > > I also wonder if we should make the output use monotonic time instead > > of real time (so change it to ktime_get_ts64() or ktime_get()). The effect > > of that would be to keep the time ticking monotonically across a concurrent > > settimeofday() call. > > That seems reasonable to me. The absolute values of the timestamps are > practically meaningless; only the differences are important. Right, although it would also mean you could no longer match up the microseconds with the printk timestamps. Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/