Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757236AbYAJDaQ (ORCPT ); Wed, 9 Jan 2008 22:30:16 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754854AbYAJDaA (ORCPT ); Wed, 9 Jan 2008 22:30:00 -0500 Received: from gateway-1237.mvista.com ([63.81.120.158]:23753 "EHLO gateway-1237.mvista.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753792AbYAJD37 (ORCPT ); Wed, 9 Jan 2008 22:29:59 -0500 Subject: Re: [RFC PATCH 16/22 -v2] add get_monotonic_cycles From: Daniel Walker To: Steven Rostedt Cc: LKML , Ingo Molnar , Linus Torvalds , Andrew Morton , Peter Zijlstra , Christoph Hellwig , Mathieu Desnoyers , Gregory Haskins , Arnaldo Carvalho de Melo , Thomas Gleixner , Tim Bird , Sam Ravnborg , "Frank Ch. Eigler" , Steven Rostedt In-Reply-To: <20080109233044.777564395@goodmis.org> References: <20080109232914.676624725@goodmis.org> <20080109233044.777564395@goodmis.org> Content-Type: text/plain Date: Wed, 09 Jan 2008 19:28:20 -0800 Message-Id: <1199935701.18203.12.camel@imap.mvista.com> Mime-Version: 1.0 X-Mailer: Evolution 2.12.2 (2.12.2-2.fc8) Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1881 Lines: 46 On Wed, 2008-01-09 at 18:29 -0500, Steven Rostedt wrote: > +cycle_t notrace get_monotonic_cycles(void) > +{ > + cycle_t cycle_now, cycle_delta, cycle_raw, cycle_last; > + > + do { > + /* > + * cycle_raw and cycle_last can change on > + * another CPU and we need the delta calculation > + * of cycle_now and cycle_last happen atomic, as well > + * as the adding to cycle_raw. We don't need to grab > + * any locks, we just keep trying until get all the > + * calculations together in one state. > + * > + * In fact, we __cant__ grab any locks. This > + * function is called from the latency_tracer which can > + * be called anywhere. To grab any locks (including > + * seq_locks) we risk putting ourselves into a deadlock. > + */ > + cycle_raw = clock->cycle_raw; > + cycle_last = clock->cycle_last; > + > + /* read clocksource: */ > + cycle_now = clocksource_read(clock); > + > + /* calculate the delta since the last update_wall_time: */ > + cycle_delta = (cycle_now - cycle_last) & clock->mask; > + > + } while (cycle_raw != clock->cycle_raw || > + cycle_last != clock->cycle_last); > + > + return cycle_raw + cycle_delta; > +} The last I check this changed caused problems for me with the -rt latency tracer.. I haven't tested this tree , but all things being equal I would imagine the exists here also.. Daniel -- 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/