Prev: [PATCH] Warn on unnecessary spaces before quoted newlines
Next: Possible NULL pointer dereference in m32r
From: Borislav Petkov on 14 Feb 2010 06:30 On Sun, Feb 14, 2010 at 11:12:23AM +0100, Peter Zijlstra wrote: > On Thu, 2010-02-11 at 18:24 +0100, Borislav Petkov wrote: > > On Mon, Feb 08, 2010 at 10:59:45AM +0100, Borislav Petkov wrote: > > > Let me prep another version when I get back on Wed. (currently > > > travelling) with all the stuff we discussed to see how it would turn. > > > > Ok, here's another version ontop of PeterZ's patch at > > http://lkml.org/lkml/2010/2/4/119. I need to handle 32- and 64-bit > > differently wrt to popcnt opcode so on 32-bit I do "popcnt %eax, %eax" > > while on 64-bit I do "popcnt %rdi, %rdi". > > Right, so I don't like how you need to touch !x86 for this, and I think > that is easily avoidable by not making x86 include > asm-generic/bitops/arch_hweight.h. > > If you then add __sw_hweightN() -> __arch_hweightN() wrappers in > arch_hweight.h, then you can leave const_hweight.h use __arch_hweightN() > and simply provide __arch_hweightN() from x86/include/asm/bitops.h Hmm, all these different names start to get a little confusing. Can we first agree on the naming please, here's my proposal: __const_hweightN - for at compile time known constants as arguments __arch_hweightN - arch possibly has an optimized hweight version __sw_hweightN - fall back when nothing else is there, aka the functions in lib/hweight.c Now, in the x86 case, when the compiler can't know that the argument is a constant, we call the __arch_hweightN versions. The alternative does call the __sw_hweightN version in case the CPU doesn't support popcnt. In this case, we need to build __sw_hweightN with -fcall-saved* for gcc to be able to take care of the regs clobbered ny __sw_hweightN. So, if I understand you correctly, your suggestion might work, we simply need to rename the lib/hweight.c versions to __sw_hweightN and have <asm-generic/bitops/arch_hweight.h> have __arch_hweightN -> __sw_hweightN wrappers in the default case, all arches which have an optimized version will provide it in their respective bitops header... Hows that? -- Regards/Gruss, Boris. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Peter Zijlstra on 14 Feb 2010 07:30 On Sun, 2010-02-14 at 12:24 +0100, Borislav Petkov wrote: > > So, if I understand you correctly, your suggestion might work, we > simply need to rename the lib/hweight.c versions to __sw_hweightN > and have <asm-generic/bitops/arch_hweight.h> have __arch_hweightN -> > __sw_hweightN wrappers in the default case, all arches which have an > optimized version will provide it in their respective bitops header... > I'm not quite sure what the last 'it' refers to, does that refer to: 1) an __arch_hweightN() implementation, or 2) __arch_hweightN() -> __sw_hweightN() wrappers ? If you meant 1, then yes. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Borislav Petkov on 14 Feb 2010 09:20 On Sun, Feb 14, 2010 at 01:23:35PM +0100, Peter Zijlstra wrote: > On Sun, 2010-02-14 at 12:24 +0100, Borislav Petkov wrote: > > > > So, if I understand you correctly, your suggestion might work, we > > simply need to rename the lib/hweight.c versions to __sw_hweightN > > and have <asm-generic/bitops/arch_hweight.h> have __arch_hweightN -> > > __sw_hweightN wrappers in the default case, all arches which have an > > optimized version will provide it in their respective bitops header... > > > I'm not quite sure what the last 'it' refers to, does that refer to: > 1) an __arch_hweightN() implementation, or > 2) __arch_hweightN() -> __sw_hweightN() wrappers ? > > If you meant 1, then yes. Yes, I mean all architectures which have an optimized hweight will use that optimized version in their __arch_hweightN while as a default fallback for the remaining architectures we'll have __arch_hweightN() -> __sw_hweightN() wrappers in <asm-generic/bitops/arch_hweight.h>. -- Regards/Gruss, Boris. - Advanced Micro Devices, Inc. Operating Systems Research Center -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Borislav Petkov on 14 Feb 2010 15:30 On Sun, Feb 14, 2010 at 10:36:48AM -0800, H. Peter Anvin wrote: > On 02/14/2010 03:24 AM, Borislav Petkov wrote: > > > > __const_hweightN - for at compile time known constants as arguments > > __arch_hweightN - arch possibly has an optimized hweight version > > __sw_hweightN - fall back when nothing else is there, aka the functions in > > lib/hweight.c > > > > Now, in the x86 case, when the compiler can't know that the argument is > > a constant, we call the __arch_hweightN versions. The alternative does > > call the __sw_hweightN version in case the CPU doesn't support popcnt. > > In this case, we need to build __sw_hweightN with -fcall-saved* for gcc > > to be able to take care of the regs clobbered ny __sw_hweightN. > > > > So, if I understand you correctly, your suggestion might work, we > > simply need to rename the lib/hweight.c versions to __sw_hweightN > > and have <asm-generic/bitops/arch_hweight.h> have __arch_hweightN -> > > __sw_hweightN wrappers in the default case, all arches which have an > > optimized version will provide it in their respective bitops header... > > > > I'm not entirely sure what you're asking; if what you're asking what to > name an x86-specific fallback function, it presumably should be > __arch_sw_hweightN (i.e. __arch prefix with a modifier.) Hmm, basically, what PeterZ suggested is that I drop one indirection under __arch_hweightN, which would make x86-specific fallback functions superfluous. IOW, what we have so far is: #define hweightN(w) (__builtin_constant_p(w) ? __const_hweightN(w) : __arch_hweightN(w)) and have <asm-generic/bitops/arch_hweight.h> provide __arch_hweightN() -> __sw_hweightN wrappers per default, where the __sw_hweightN are the lib/hweight.c generic versions. On architectures/CPUs which provide popcnt in hardware, we create __arch_hweightN implementations in <arch/[:ARCH_NAME:]/include/asm/bitops.h> overriding the <asm-generic/bitops/arch_hweight.h> versions by simply not including that last header. Is that agreeable? -- Regards/Gruss, Boris. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Borislav Petkov on 17 Feb 2010 12:30
On Wed, Feb 17, 2010 at 02:57:42PM +0100, Michal Marek wrote: > On 12.2.2010 20:05, H. Peter Anvin wrote: > > On 02/12/2010 09:47 AM, Borislav Petkov wrote: > >> > >> However, this is generic code and for the above to work we have to > >> enforce x86-specific CFLAGS for it. What is the preferred way to do > >> that? > >> > > > > That's a question for Michal and the kbuild list. Michal? > > (I was offline last week). > > The _preferred_ way probably is not to do it :), but otherwise you can > set CFLAGS_hweight.o depending on CONFIG_X86(_32|_64), just like you do > in arch/x86/lib/Makefile already. Wouldn't it be better if we had something like ARCH_CFLAGS_hweight.o which gets set in the arch Makefile instead? -- Regards/Gruss, Boris. -- Advanced Micro Devices, Inc. Operating Systems Research Center -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |