Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
From: Jan Engelhardt Date: Fri, 10 Aug 2012 14:51:49 +0200 (CEST) > > On Saturday 2012-07-21 02:46, David Miller wrote: >>> Arnd Bergmann wrote: >>> I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... >>> >>> Some arches (such as Sparc, I think) have count-leading-zero instructions. >> >>Yes, newer sparc64 chips have leading-zero-detect, and I was pretty >>sure that powerpc had something similar. It's called count-leading- >>zeros or something like that. > > And gcc has a __builtin_clz. Which I can't use. I have to patch the code at run time based upon whether the cpu has the 'lzd' instruction or not. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Saturday 2012-07-21 02:46, David Miller wrote: >> Arnd Bergmann wrote: >> >>> I don't generally like to put stuff into asm-generic when it's unlikely >>> to be overridden by architectures. It would really belong into >>> include/linux, but then again we have all the other bitops in asm-generic >>> as well, so whatever... >> >> Some arches (such as Sparc, I think) have count-leading-zero instructions. > >Yes, newer sparc64 chips have leading-zero-detect, and I was pretty >sure that powerpc had something similar. It's called count-leading- >zeros or something like that. And gcc has a __builtin_clz. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Saturday 2012-07-21 02:46, David Miller wrote: Arnd Bergmann a...@arndb.de wrote: I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Some arches (such as Sparc, I think) have count-leading-zero instructions. Yes, newer sparc64 chips have leading-zero-detect, and I was pretty sure that powerpc had something similar. It's called count-leading- zeros or something like that. And gcc has a __builtin_clz. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
From: Jan Engelhardt jeng...@inai.de Date: Fri, 10 Aug 2012 14:51:49 +0200 (CEST) On Saturday 2012-07-21 02:46, David Miller wrote: Arnd Bergmann a...@arndb.de wrote: I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Some arches (such as Sparc, I think) have count-leading-zero instructions. Yes, newer sparc64 chips have leading-zero-detect, and I was pretty sure that powerpc had something similar. It's called count-leading- zeros or something like that. And gcc has a __builtin_clz. Which I can't use. I have to patch the code at run time based upon whether the cpu has the 'lzd' instruction or not. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Friday 20 July 2012, David Howells wrote: > > Arnd Bergmann wrote: > > > I don't generally like to put stuff into asm-generic when it's unlikely > > to be overridden by architectures. It would really belong into > > include/linux, but then again we have all the other bitops in asm-generic > > as well, so whatever... > > Some arches (such as Sparc, I think) have count-leading-zero instructions. But I guess they would still use the same definition of +static inline int count_leading_zeros(unsigned long x) +{ + if (sizeof(x) == 4) + return BITS_PER_LONG - fls(x); + else + return BITS_PER_LONG - fls64(x); +} and just provide their own fls(). Arnd -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Friday 20 July 2012, David Howells wrote: Arnd Bergmann a...@arndb.de wrote: I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Some arches (such as Sparc, I think) have count-leading-zero instructions. But I guess they would still use the same definition of +static inline int count_leading_zeros(unsigned long x) +{ + if (sizeof(x) == 4) + return BITS_PER_LONG - fls(x); + else + return BITS_PER_LONG - fls64(x); +} and just provide their own fls(). Arnd -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
From: David Howells Date: Fri, 20 Jul 2012 15:21:39 +0100 > Arnd Bergmann wrote: > >> I don't generally like to put stuff into asm-generic when it's unlikely >> to be overridden by architectures. It would really belong into >> include/linux, but then again we have all the other bitops in asm-generic >> as well, so whatever... > > Some arches (such as Sparc, I think) have count-leading-zero instructions. Yes, newer sparc64 chips have leading-zero-detect, and I was pretty sure that powerpc had something similar. It's called count-leading- zeros or something like that. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
Arnd Bergmann wrote: > I don't generally like to put stuff into asm-generic when it's unlikely > to be overridden by architectures. It would really belong into > include/linux, but then again we have all the other bitops in asm-generic > as well, so whatever... Some arches (such as Sparc, I think) have count-leading-zero instructions. David -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Friday 20 July 2012, David Howells wrote: > Provide count_leading/trailing_zeros() macros based on extant arch bit > scanning > functions rather than reimplementing from scratch in MPILIB. > > Whilst we're at it, turn count_foo_zeros(n, x) into n = count_foo_zeros(x). > > Also move the definition to asm-generic as other people may be interested in > using it. > > Signed-off-by: David Howells > Cc: David S. Miller > Cc: Dmitry Kasatkin > Cc: Arnd Bergmann I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Acked-by: Arnd Bergmann -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Friday 20 July 2012, David Howells wrote: Provide count_leading/trailing_zeros() macros based on extant arch bit scanning functions rather than reimplementing from scratch in MPILIB. Whilst we're at it, turn count_foo_zeros(n, x) into n = count_foo_zeros(x). Also move the definition to asm-generic as other people may be interested in using it. Signed-off-by: David Howells dhowe...@redhat.com Cc: David S. Miller da...@davemloft.net Cc: Dmitry Kasatkin dmitry.kasat...@intel.com Cc: Arnd Bergmann a...@arndb.de I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Acked-by: Arnd Bergmann a...@arndb.de -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
Arnd Bergmann a...@arndb.de wrote: I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Some arches (such as Sparc, I think) have count-leading-zero instructions. David -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
From: David Howells dhowe...@redhat.com Date: Fri, 20 Jul 2012 15:21:39 +0100 Arnd Bergmann a...@arndb.de wrote: I don't generally like to put stuff into asm-generic when it's unlikely to be overridden by architectures. It would really belong into include/linux, but then again we have all the other bitops in asm-generic as well, so whatever... Some arches (such as Sparc, I think) have count-leading-zero instructions. Yes, newer sparc64 chips have leading-zero-detect, and I was pretty sure that powerpc had something similar. It's called count-leading- zeros or something like that. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Fri, 6 Jul 2012, David Howells wrote: > Provide count_leading/trailing_zeros() macros based on extant arch bit > scanning > functions rather than reimplementing from scratch in MPILIB. > > Whilst we're at it, turn count_foo_zeros(n, x) into n = count_foo_zeros(x). > > Also move the definition to asm-generic as other people may be interested in > using it. Please rebase this against git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next -- James Morris -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] MPILIB: Provide count_leading/trailing_zeros() based on arch functions
On Fri, 6 Jul 2012, David Howells wrote: Provide count_leading/trailing_zeros() macros based on extant arch bit scanning functions rather than reimplementing from scratch in MPILIB. Whilst we're at it, turn count_foo_zeros(n, x) into n = count_foo_zeros(x). Also move the definition to asm-generic as other people may be interested in using it. Please rebase this against git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next -- James Morris jmor...@namei.org -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/