From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932864AbcLIKBp (ORCPT ); Fri, 9 Dec 2016 05:01:45 -0500 Received: from merlin.infradead.org ([205.233.59.134]:45740 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753106AbcLIKBo (ORCPT ); Fri, 9 Dec 2016 05:01:44 -0500 Date: Fri, 9 Dec 2016 11:01:30 +0100 From: Peter Zijlstra To: Thomas Gleixner Cc: LKML , John Stultz , Ingo Molnar , 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: <20161209100130.GS3174@twins.programming.kicks-ass.net> References: <20161208202623.883855034@linutronix.de> <20161208204229.005418487@linutronix.de> <20161209052638.GC3061@worktop.programming.kicks-ass.net> <20161209063847.GC15765@worktop.programming.kicks-ass.net> <20161209083011.GD15765@worktop.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20161209083011.GD15765@worktop.programming.kicks-ass.net> User-Agent: Mutt/1.5.23.1 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 09, 2016 at 09:30:11AM +0100, Peter Zijlstra wrote: > +static inline u64 mul_u32_u32(u32 a, u32 b) > +{ > + u64 ret; > + > + asm ("mull %[b]" : "=A" (ret) : [a] "a" (a), [b] "g" (b) ); > + > + return ret; > +} ARGH, that's broken on x86_64, it needs to be: u32 high, low; asm ("mull %[b]" : "=a" (low), "=d" (high) : [a] "a" (a), [b] "g" (b) ); return low | ((u64)high) << 32; The 'A' constraint doesn't work right. And with that all the benchmark results are borken too. root@ivb-ep:~/spinlocks# for i in -m64 -m32 -mx32 ; do echo $i; gcc -O3 $i -o mult mult.c -lm; ./mult; done -m64 cond: avg: 7.474872 +- 0.008302 uncond: avg: 9.116401 +- 0.008468 128: avg: 0.826584 +- 0.005514 -m32 cond: avg: 16.604030 +- 0.009808 uncond: avg: 13.115470 +- 0.004452 -mx32 cond: avg: 6.168156 +- 0.006650 uncond: avg: 7.202092 +- 0.006813 128: avg: 0.081809 +- 0.008440