Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1372732
| From | Sam Ravnborg <sam@ravnborg.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2 08/30] Add sparc-specific parity functions |
| Date | 2016-04-06 20:50 +0200 |
| Message-ID | <rl0GC-8e3-25@gated-at.bofh.it> (permalink) |
| References | <rkoUH-4m4-33@gated-at.bofh.it> <rkRN0-1BH-11@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hi Zeng.
>
> Use runtime patching for sparc64, lifted from hweight
No errors found in patch - but a few comments.
In general patch looks good.
> +++ b/arch/sparc/include/asm/bitops_64.h
> @@ -47,6 +47,24 @@ unsigned int __arch_hweight16(unsigned int w);
> unsigned int __arch_hweight8(unsigned int w);
>
> #include <asm-generic/bitops/const_hweight.h>
> +
> +/*
> + * parityN: returns the parity of a N-bit word,
> + * i.e. the number of 1-bits in w modulo 2.
> + */
> +
> +static inline unsigned int __arch_parity4(unsigned int w)
> +{
> + w &= 0xf;
> + return (0x6996 >> w) & 1;
> +}
As Josef already said - this constant should have a name.
PARITY_BIT
?
> +++ b/arch/sparc/kernel/sparc_ksyms_64.c
> @@ -45,6 +45,12 @@ EXPORT_SYMBOL(__arch_hweight16);
> EXPORT_SYMBOL(__arch_hweight32);
> EXPORT_SYMBOL(__arch_hweight64);
>
> +/* from parity.S */
> +EXPORT_SYMBOL(__arch_parity8);
> +EXPORT_SYMBOL(__arch_parity16);
> +EXPORT_SYMBOL(__arch_parity32);
> +EXPORT_SYMBOL(__arch_parity64);
Did you compile this?
I wonder if bitops_64.h is indirectly included.
> index 0000000..b1945e3
> --- /dev/null
> +++ b/arch/sparc/lib/parity.S
> @@ -0,0 +1,93 @@
> +#include <linux/linkage.h>
> +
> + .text
> + .align 32
> +
> +ENTRY(__arch_parity8)
> + srl %o0, 4, %g1
> + xor %o0, %g1, %o0
> + and %o0, 0xf, %o0
> + sethi %hi(0x6996), %g1
> + or %g1, %lo(0x6996), %g1
> + srl %g1, %o0, %o0
> + retl
> + and %o0, 1, %o0
> +ENDPROC(__arch_parity8)
I know the level of comments in hweight is equal to none.
But please do not follow this bad example.
At least for each function a one-liner of the C code.
And in the top of the file maybe two lines that the functions
are patched at run-time if the processor has popc available.
Sam
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH V2 01/30] bitops: add parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-05 04:30 +0200
[PATCH V2 02/30] Include generic parity.h in some architectures' bitops.h Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-05 06:30 +0200
[PATCH v2 02/30] Include generic parity.h in some architectures' bitops.h zengzhaoxiu@163.com - 2016-04-06 10:50 +0200
Re: [PATCH V2 01/30] bitops: add parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-04-05 21:10 +0200
Re: [PATCH V2 01/30] bitops: add parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-06 07:40 +0200
Re: [PATCH V2 01/30] bitops: add parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-04-06 10:30 +0200
[PATCH v2 01/30] bitops: add parity functions zengzhaoxiu@163.com - 2016-04-06 10:50 +0200
[PATCH v2 03/30] Add alpha-specific parity functions zengzhaoxiu@163.com - 2016-04-06 10:50 +0200
[PATCH v2 05/30] Add ia64-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:00 +0200
[PATCH v2 07/30] Add powerpc-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:10 +0200
[PATCH v2 06/30] Add mips-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:10 +0200
[PATCH v2 06/30] Add mips-specific parity functions zengzhaoxiu@163.com - 2016-04-06 12:30 +0200
[PATCH v2 04/30] Add blackfin-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:10 +0200
[PATCH v2 09/30] Add tile-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:10 +0200
Re: [PATCH v2 09/30] Add tile-specific parity functions Chris Metcalf <cmetcalf@mellanox.com> - 2016-04-06 15:30 +0200
Re: [PATCH v2 09/30] Add tile-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-07 06:00 +0200
[PATCH v2 08/30] Add sparc-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:20 +0200
Re: [PATCH v2 08/30] Add sparc-specific parity functions Sam Ravnborg <sam@ravnborg.org> - 2016-04-06 20:50 +0200
Re: [PATCH v2 08/30] Add sparc-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-07 06:00 +0200
[PATCH v2 10/30] Add x86-specific parity functions zengzhaoxiu@163.com - 2016-04-06 11:30 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-04-06 12:20 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-04-06 12:40 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-04-06 13:00 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-07 06:00 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-04-07 11:50 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-11 04:50 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-04-15 02:20 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-07 06:00 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-04-07 11:50 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Andi Kleen <andi@firstfloor.org> - 2016-04-06 21:50 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com> - 2016-04-07 06:00 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Dmitry Vyukov <dvyukov@google.com> - 2016-04-07 08:40 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions Borislav Petkov <bp@suse.de> - 2016-04-07 11:50 +0200
Re: [PATCH v2 10/30] Add x86-specific parity functions One Thousand Gnomes <gnomes@lxorguk.ukuu.org.uk> - 2016-04-07 16:20 +0200
[PATCH v2 11/30] sunrpc: use parity8 zengzhaoxiu@163.com - 2016-04-06 11:40 +0200
[PATCH v2 12/30] mips: use parity functions in cerr-sb1.c zengzhaoxiu@163.com - 2016-04-06 11:40 +0200
[PATCH v2 14/30] media: use parity8 in vivid-vbi-gen.c zengzhaoxiu@163.com - 2016-04-06 11:40 +0200
[PATCH v2 13/30] bch: use parity32 zengzhaoxiu@163.com - 2016-04-06 11:40 +0200
[PATCH v2 17/30] input: use parity64 in sidewinder zengzhaoxiu@163.com - 2016-04-06 11:50 +0200
[PATCH v2 16/30] input: use parity32 in grip_mp zengzhaoxiu@163.com - 2016-04-06 11:50 +0200
[PATCH v2 18/30] input: use parity16 in ams_delta_serio zengzhaoxiu@163.com - 2016-04-06 11:50 +0200
[PATCH v2 19/30] scsi: use parity32 in isci's phy zengzhaoxiu@163.com - 2016-04-06 11:50 +0200
[PATCH v2 15/30] media: use parity functions in saa7115 zengzhaoxiu@163.com - 2016-04-06 11:50 +0200
[PATCH v2 22/30] crypto: use parity functions in qat_hal zengzhaoxiu@163.com - 2016-04-06 12:00 +0200
[PATCH v2 21/30] mtd: use parity functions in inftlcore zengzhaoxiu@163.com - 2016-04-06 12:00 +0200
[PATCH v2 20/30] mtd: use parity16 in ssfdc zengzhaoxiu@163.com - 2016-04-06 12:00 +0200
[PATCH v2 23/30] mtd: use parity16 in sm_ftl zengzhaoxiu@163.com - 2016-04-06 12:10 +0200
[PATCH v2 26/30] input: use parity8 in sa1111ps2 zengzhaoxiu@163.com - 2016-04-06 12:20 +0200
[PATCH v2 27/30] iio: use parity32 in adxrs450 zengzhaoxiu@163.com - 2016-04-06 12:20 +0200
Re: [PATCH v2 27/30] iio: use parity32 in adxrs450 Jonathan Cameron <jic23@kernel.org> - 2016-04-10 16:40 +0200
Re: [PATCH v2 27/30] iio: use parity32 in adxrs450 Lars-Peter Clausen <lars@metafoo.de> - 2016-04-10 17:10 +0200
Re: [PATCH v2 27/30] iio: use parity32 in adxrs450 Jonathan Cameron <jic23@kernel.org> - 2016-04-10 17:20 +0200
Re: [PATCH v2 27/30] iio: use parity32 in adxrs450 Jonathan Cameron <jic23@kernel.org> - 2016-04-10 17:20 +0200
[PATCH v2 24/30] ethernet: use parity8 in sun/niu.c zengzhaoxiu@163.com - 2016-04-06 12:20 +0200
[PATCH v2 25/30] input: use parity8 in pcips2 zengzhaoxiu@163.com - 2016-04-06 12:20 +0200
Re: [PATCH v2 28/30] serial: use parity32 in max3100 Greg KH <gregkh@linuxfoundation.org> - 2016-04-06 12:30 +0200
[PATCH v2 28/30] serial: use parity32 in max3100 zengzhaoxiu@163.com - 2016-04-06 12:30 +0200
[PATCH v2 30/30] ethernet: use parity8 in broadcom/tg3.c zengzhaoxiu@163.com - 2016-04-06 12:30 +0200
[PATCH v2 29/30] input: use parity8 in elantech zengzhaoxiu@163.com - 2016-04-06 12:30 +0200
csiph-web