Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754814AbcC1Phv (ORCPT ); Mon, 28 Mar 2016 11:37:51 -0400 Received: from asavdk3.altibox.net ([109.247.116.14]:57570 "EHLO asavdk3.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754710AbcC1Pht (ORCPT ); Mon, 28 Mar 2016 11:37:49 -0400 Date: Mon, 28 Mar 2016 17:37:43 +0200 From: Sam Ravnborg To: David Miller Cc: zhaoxiu.zeng@gmail.com, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org Subject: Re: [PATCH 10/31] Add sparc-specific parity functions Message-ID: <20160328153743.GA13061@ravnborg.org> References: <56F780FE.7000600@gmail.com> <20160327.224308.220596078048860811.davem@davemloft.net> <56F8C4A3.1070808@gmail.com> <20160328.112915.1286498398436148099.davem@davemloft.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20160328.112915.1286498398436148099.davem@davemloft.net> User-Agent: Mutt/1.5.24 (2015-08-30) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.1 cv=YbIdn1lf c=1 sm=1 tr=0 a=Ij76tQDYWdb01v2+RnYW5w==:117 a=Ij76tQDYWdb01v2+RnYW5w==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=yUDm12blmX5nNaY-xBMA:9 a=QEXdDO2ut3YA:10 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1362 Lines: 34 On Mon, Mar 28, 2016 at 11:29:15AM -0400, David Miller wrote: > From: Zeng Zhaoxiu > Date: Mon, 28 Mar 2016 13:44:03 +0800 > > > 在 2016年03月28日 10:43, David Miller 写道: > >> From: "zhaoxiu.zeng" > >> Date: Sun, 27 Mar 2016 14:43:10 +0800 > >> > >>> + > >>> +/* > >>> + * parityN: returns the parity of a N-bit word, > >>> + * i.e. the number of 1-bits in x modulo 2. > >>> + */ > >>> + > >>> +#define __arch_parity4(w) (__arch_hweight8((w) & 0xf) & 1) > >>> +#define __arch_parity8(w) (__arch_hweight8(w) & 1) > >>> +#define __arch_parity16(w) (__arch_hweight16(w) & 1) > >>> +#define __arch_parity32(w) (__arch_hweight32(w) & 1) > >>> +#define __arch_parity64(w) ((unsigned int)__arch_hweight64(w) & 1) > >> This looks like asm-generic/ material to me. > > > > This is generic for the architectures which have popcount instruction, > > but more higher costs than asm-generic/ for others. > > Which is why said stanza's in the asm-generic header should be triggered > by a CPP define or similar. For sparc we would need to do a run-time patch as far as I see. If popc is availble then use of hweight* should be fine. But without popc then I think the generic implementation that uses the stanford algorithm would be most efficient, rather than the base this on the generic hweight functions. Sam