From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H. Peter Anvin" Subject: Re: [PATCH 2/5] bitops: compile time optimization for hweight_long(CONSTANT) Date: Sat, 06 Feb 2010 17:55:47 -0800 Message-ID: <4B6E1DA3.50204@zytor.com> References: <20100203074251.e2caa3f3.akpm@linux-foundation.org> <20100203181425.GB1367@aftab> <1265222875.24455.1020.camel@laptop> <4B69D362.10608@zytor.com> <20100204151050.GC32711@aftab> <1265296432.22001.18.camel@laptop> <20100204155419.GD32711@aftab> <1265299457.22001.72.camel@laptop> <20100205121139.GA9044@aftab> <4B6C93A2.1090302@zytor.com> <20100206093659.GA28326@aftab> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Cc: Peter Zijlstra , Andrew Morton , Wu Fengguang , LKML , Jamie Lokier , Roland Dreier , Al Viro , "linux-fsdevel@vger.kernel.org" , Ingo Molnar , Brian Gerst To: Borislav Petkov Return-path: In-Reply-To: <20100206093659.GA28326@aftab> Sender: linux-kernel-owner@vger.kernel.org List-Id: linux-fsdevel.vger.kernel.org On 02/06/2010 01:36 AM, Borislav Petkov wrote: > >> c) You call a C function, but you don't clobber the set of registers >> that a C function would clobber. You either need to put the function in >> an assembly wrapper (which is better in the long run), or clobber the >> full set of registers that is clobbered by a C function (which is better >> in the short term) -- which is eax, edx, ecx on 32 bits, but rax, rdi, >> esi, rdx, rcx, r8, r9, r10, r11 on 64 bits. > > I think you mean rsi instead of esi here. > > Well, the example Brian pointed me to - __mutex_fastpath_lock - lists > the full set of clobbered registers. Please elaborate on the assembly > wrapper for the function, wouldn't I need to list all the clobbered > registers there too or am I missing something? > The notion there would be that you do push/pop in the assembly wrapper. >> d) On the other hand, you do *not* need a "memory" clobber. > > Right, in this case we have all non-barrier like inlines so no memory > clobber, according to the comment above alternative() macro. OK, I'm missing something here. A few more notions: a. This is exactly the kind of code where you don't want to put "volatile" on your asm statement, because it's a pure compute. b. It is really rather pointless to go through the whole alternatives work if you are then going to put it inside a function which isn't an inline ... -hpa -- H. Peter Anvin, Intel Open Source Technology Center I work for Intel. I don't speak on their behalf.