From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753590AbcLIEtD (ORCPT ); Thu, 8 Dec 2016 23:49:03 -0500 Received: from bombadil.infradead.org ([198.137.202.9]:59074 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751563AbcLIEtC (ORCPT ); Thu, 8 Dec 2016 23:49:02 -0500 Date: Fri, 9 Dec 2016 05:48:49 +0100 From: Peter Zijlstra To: Ingo Molnar Cc: Thomas Gleixner , LKML , John Stultz , David Gibson , Liav Rehana , Chris Metcalf , Richard Cochran , Parit Bhargava , Laurent Vivier , "Christopher S. Hall" Subject: Re: [patch 5/6] [RFD] timekeeping: Provide optional 128bit math Message-ID: <20161209044849.GY3045@worktop.programming.kicks-ass.net> References: <20161208202623.883855034@linutronix.de> <20161208204229.005418487@linutronix.de> <20161209040826.GA2595@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161209040826.GA2595@gmail.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 09, 2016 at 05:08:26AM +0100, Ingo Molnar wrote: > > +#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__) > > +static inline u64 timekeeping_delta_to_ns(struct tk_read_base *tkr, u64 delta) > > +{ > > + unsigned __int128 nsec; > > + > > + nsec = ((unsigned __int128)delta * tkr->mult) + tkr->xtime_nsec; > > + return (u64) (nsec >> tkr->shift); > > +} > > Actually, 128-bit multiplication shouldn't be too horrible - at least on 64-bit > architectures. (128-bit division is another matter, but there's no division here.) IIRC there are 64bit architectures that do not have a 64x64->128 mult, only a 64x64->64 mult instruction. Its not immediately apparent using __int128 will generate optimal code for those, nor is it a given GCC will not require libgcc functions for those.