Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755326AbZGGIJS (ORCPT ); Tue, 7 Jul 2009 04:09:18 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753552AbZGGIJH (ORCPT ); Tue, 7 Jul 2009 04:09:07 -0400 Received: from www.tglx.de ([62.245.132.106]:51259 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753222AbZGGIJF (ORCPT ); Tue, 7 Jul 2009 04:09:05 -0400 Date: Tue, 7 Jul 2009 10:08:56 +0200 (CEST) From: Thomas Gleixner To: Martin Schwidefsky cc: linux-kernel@vger.kernel.org, Ingo Molnar , john stultz Subject: Re: [PATCH] optimized ktime_get[_ts] for GENERIC_TIME=y In-Reply-To: <20090707094018.08406c49@skybase> Message-ID: References: <20090706154933.5a1f8990@skybase> <20090707094018.08406c49@skybase> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1338 Lines: 39 Martin, On Tue, 7 Jul 2009, Martin Schwidefsky wrote: > On Mon, 6 Jul 2009 22:31:39 +0200 (CEST) > Thomas Gleixner wrote: > > > On Mon, 6 Jul 2009, Martin Schwidefsky wrote: > > > +ktime_t ktime_get(void) > > > +{ > > > + cycle_t cycle_now, cycle_delta; > > > + struct timespec time; > > > + unsigned long seq; > > > + s64 nsecs; > > > + > > > + do { > > > + seq = read_seqbegin(&xtime_lock); > > > + time.tv_sec = xtime.tv_sec + wall_to_monotonic.tv_sec; > > > + time.tv_nsec = xtime.tv_nsec + wall_to_monotonic.tv_nsec; > > > > That's actually a violation of the timespec semantics. tv_nsec can end > > up greater than (10^9 - 1). Please use separate sec and nsec variables. > > Well the tv_sec/tv_nsec fields of a timespec are long values. But its > no problem to switch to local variables. Right. I'm not worried about an overflow of the variable. I was about to suggest using timespec_to_ktime() to fix the !SCALAR problem when I noticed that the timespec is possibly not normalized. Not using a timespec makes the code more obvious I think. Thanks, tglx -- 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/