From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752977AbcBWOBt (ORCPT ); Tue, 23 Feb 2016 09:01:49 -0500 Received: from casper.infradead.org ([85.118.1.10]:54465 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbcBWOBr (ORCPT ); Tue, 23 Feb 2016 09:01:47 -0500 Date: Tue, 23 Feb 2016 15:01:43 +0100 From: Peter Zijlstra To: Steven Rostedt Cc: linux-kernel@vger.kernel.org, Ingo Molnar , Thomas Gleixner , Juri Lelli , Clark Williams , Andrew Morton Subject: Re: [PATCH 4/4] tracing: Add __print_ns_to_secs() and __print_ns_without_secs() helpers Message-ID: <20160223140143.GK6356@twins.programming.kicks-ass.net> References: <20160222212649.485719441@goodmis.org> <20160222212825.900322488@goodmis.org> <20160223124915.GQ6357@twins.programming.kicks-ass.net> <20160223081757.59f3b698@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160223081757.59f3b698@gandalf.local.home> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Feb 23, 2016 at 08:17:57AM -0500, Steven Rostedt wrote: > On Tue, 23 Feb 2016 13:49:15 +0100 > Peter Zijlstra wrote: > > > On Mon, Feb 22, 2016 at 04:26:53PM -0500, Steven Rostedt wrote: > > > From: "Steven Rostedt (Red Hat)" > > > > > > To have nanosecond output displayed in a more human readable format, its > > > nicer to convert it to a seconds format (XXX.YYYYYYYYY). The problem is that > > > to do so, the numbers must be divided by NSEC_PER_SEC, and moded too. But as > > > these numbers are 64 bit, this can not be done simply with '/' and '%' > > > operators, but must use do_div() instead. > > > > Would not div_[us]64_rem() make more sense? It would typically result in > > just the one division, instead of two. > > The problem is, how do you do that in a printf() statement? > > We have "%llu.%09ul" which is two arguments in the printf(). And the > values we are processing can't be modified. Which is why the macro uses > ({ }) and creates a temp variable. Hurm,. yes that's not something easily done. We need a temporary limited in scope to the printf statement, and C doesn't really do that.