db: disable the ARM assembler mutex code
PATCH 1/1 db: disable the ARM assembler mutex code
The swpb in macro MUTEX_SET will cause "undefined instruction" error on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't support them. So to avoid this issue, just disable the ARM assembler mutex code, and use the default pthreads mutex.
--- meta/recipes-support/db/db_6.0.30.bb | 9 --------- 1 file changed, 9 deletions(-)
meta/recipes-support/db/db_6.0.30.bb +0 -9
@@ -74,15 +74,6 @@ DB6_CONFIG ?= "--enable-o_direct --disable-cryptography --disable-queue --disabl EXTRA_OECONF = "${DB6_CONFIG} --enable-shared --enable-cxx --with-sysroot" -# Override the MUTEX setting here, the POSIX library is -# the default - "POSIX/pthreads/library". -# Don't ignore the nice SWP instruction on the ARM: -# These enable the ARM assembler mutex code -ARM_MUTEX = "--with-mutex=ARM/gcc-assembly" -MUTEX = "" -MUTEX_arm = "${ARM_MUTEX}" -MUTEX_armeb = "${ARM_MUTEX}" -EXTRA_OECONF += "${MUTEX}" EXTRA_OEMAKE_class-target = "LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" # Cancel the site stuff - it's set for db3 and destroys the
Signature · 1 line
2.9.3
Some more explanations:
Berkeley DB's assembly mutex code for arm is related with arm arch version.
The old version DB code uses old arm instruction (such as swpb), which isn't supported by new arm arch (such as armv7).
The new version DB (maybe from 6.1.29 or 6.1.26) uses new arm instruction (such as ldrex/strex), which isn't supported by old arm arch (such as armv5).
To support all the arm arches, and consider that the Berkeley DB code will upgrade in the future, I suggest disable the ARM assembler mutex code, and use the default pthreads mutex.
Thanks.
Zhou Li
Quoted 31 lines · Li Zhou
The swpb in macro
MUTEX_SETwill cause "undefined instruction" error on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't support them. So to avoid this issue, just disable the ARM assembler mutex code, and use the default pthreads mutex.Signed-off-by Li Zhou <[email protected]>--- meta/recipes-support/db/db_6.0.30.bb | 9 --------- 1 file changed, 9 deletions(-)meta/recipes-support/db/db_6.0.30.bb +0
-9@@ -74,15 +74,6 @@ DB6_CONFIG ?= "--enable-o_direct --disable-cryptography --disable-queue --disabl EXTRA_OECONF = "${DB6_CONFIG} --enable-shared --enable-cxx --with-sysroot" -# Override the MUTEX setting here, the POSIX library is -# the default - "POSIX/pthreads/library". -# Don't ignore the nice SWP instruction on the ARM: -# These enable the ARM assembler mutex code -ARM_MUTEX = "--with-mutex=ARM/gcc-assembly" -MUTEX = "" -MUTEX_arm = "${ARM_MUTEX}" -MUTEX_armeb = "${ARM_MUTEX}" -EXTRA_OECONF += "${MUTEX}" EXTRA_OEMAKE_class-target = "LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" # Cancel the site stuff - it's set for db3 and destroys the
Signature · 3 lines
Best Regards! Zhou Li Phone number: 86-10-84778511
This patch cannot be applied because the modified file is not track by oe-core.
Quoted 31 lines · Li Zhou
The swpb in macro
MUTEX_SETwill cause "undefined instruction" error on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't support them. So to avoid this issue, just disable the ARM assembler mutex code, and use the default pthreads mutex.Signed-off-by Li Zhou <[email protected]>--- meta/recipes-support/db/db_6.0.30.bb | 9 --------- 1 file changed, 9 deletions(-)meta/recipes-support/db/db_6.0.30.bb +0
-9@@ -74,15 +74,6 @@ DB6_CONFIG ?= "--enable-o_direct --disable-cryptography --disable-queue --disabl EXTRA_OECONF = "${DB6_CONFIG} --enable-shared --enable-cxx --with-sysroot" -# Override the MUTEX setting here, the POSIX library is -# the default - "POSIX/pthreads/library". -# Don't ignore the nice SWP instruction on the ARM: -# These enable the ARM assembler mutex code -ARM_MUTEX = "--with-mutex=ARM/gcc-assembly" -MUTEX = "" -MUTEX_arm = "${ARM_MUTEX}" -MUTEX_armeb = "${ARM_MUTEX}" -EXTRA_OECONF += "${MUTEX}" EXTRA_OEMAKE_class-target = "LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" # Cancel the site stuff - it's set for db3 and destroys the
Quoted 3 lines · Leonardo Sandoval
This patch cannot be applied because the modified file is not track by oe-core.
The original submitted should have mentioned this patch is against Jethro. However the patch is directly applicable to master, morty and korgoth as well.
Li, please rebase this against master and then ask for it to be backported to the others.
--Mark
Quoted 33 lines · Li Zhou
Quoted 31 lines
The swpb in macro
MUTEX_SETwill cause "undefined instruction" error on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't support them. So to avoid this issue, just disable the ARM assembler mutex code, and use the default pthreads mutex.Signed-off-by Li Zhou <[email protected]>--- meta/recipes-support/db/db_6.0.30.bb | 9 --------- 1 file changed, 9 deletions(-)meta/recipes-support/db/db_6.0.30.bb +0
-9@@ -74,15 +74,6 @@ DB6_CONFIG ?= "--enable-o_direct --disable-cryptography --disable-queue --disabl EXTRA_OECONF = "${DB6_CONFIG} --enable-shared --enable-cxx --with-sysroot" -# Override the MUTEX setting here, the POSIX library is -# the default - "POSIX/pthreads/library". -# Don't ignore the nice SWP instruction on the ARM: -# These enable the ARM assembler mutex code -ARM_MUTEX = "--with-mutex=ARM/gcc-assembly" -MUTEX = "" -MUTEX_arm = "${ARM_MUTEX}" -MUTEX_armeb = "${ARM_MUTEX}" -EXTRA_OECONF += "${MUTEX}" EXTRA_OEMAKE_class-target = "LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" # Cancel the site stuff - it's set for db3 and destroys the
Quoted 18 lines · Li Zhou
The swpb in macro
MUTEX_SETwill cause "undefined instruction" error on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't support them. So to avoid this issue, just disable the ARM assembler mutex code, and use the default pthreads mutex.Signed-off-by Li Zhou <[email protected]>--- meta/recipes-support/db/db_6.0.30.bb | 9 --------- 1 file changed, 9 deletions(-)meta/recipes-support/db/db_6.0.30.bb +0
-0@@ -74,15 +74,6 @@ DB6_CONFIG ?= "--enable-o_direct --disable-cryptography --disable-queue --disabl EXTRA_OECONF = "${DB6_CONFIG} --enable-shared --enable-cxx --with-sysroot"
meta/recipes-support/db/db_6.0.30.bb DB6_CONFIG ?= "--enable-o_direct --disable-cryptography --disable-queue --disabl · line 85
Quoted 10 lines
meta/recipes-support/db/db_6.0.30.bb +0
-9-# Override the MUTEX setting here, the POSIX library is -# the default - "POSIX/pthreads/library". -# Don't ignore the nice SWP instruction on the ARM: -# These enable the ARM assembler mutex code -ARM_MUTEX = "--with-mutex=ARM/gcc-assembly" -MUTEX = "" -MUTEX_arm = "${ARM_MUTEX}" -MUTEX_armeb = "${ARM_MUTEX}" -EXTRA_OECONF += "${MUTEX}"
it would be good to keep this for older < armv5 arches
Quoted 4 lines
meta/recipes-support/db/db_6.0.30.bb +0
-0EXTRA_OEMAKE_class-target = "LIBTOOL=${STAGING_BINDIR_CROSS}/${HOST_SYS}-libtool" # Cancel the site stuff - it's set for db3 and destroys the
Quoted 2 lines · Khem Raj
it would be good to keep this for older < armv5 arches
Doesn't the C library support its own atomics for those?
Ross
A message that is not in the archive (sent off-list or not yet received): CAMKF1sp=ZHOP4aY7r11kvURBymq4+uknmeiSGQyP9BUpW_WXBQ@mail.gmail.com
Not sure the atomics in newer compiler and libc has ever been tested in this version of db
On Nov 4, 2016 1:29 PM, "Burton, Ross" <[email protected]> wrote:
Quoted 2 lines · Khem Raj
it would be good to keep this for older < armv5 arches
Doesn't the C library support its own atomics for those?
Ross
Quoted 14 lines · Khem Raj
Quoted 10 lines · Li Zhou
The swpb in macro
MUTEX_SETwill cause "undefined instruction" error
on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't
support them. So to avoid this issue, just disable the ARM assembler
mutex code, and use the default pthreads mutex.
Quoted 1 line
it would be good to keep this for older < armv5 arches
I guess you meant "<= ARMv5". STREX etc were introduced in ARMv6, so ARMv5 (and ARMv5TE) don't have it. But in any case, won't the default libpthread mutex work just fine on those older architectures? There is no SMP on anything before ARMv6 anyway so lock contention will be relatively low, and it seems fairly unlikely that anybody has a real- world application which uses db so heavily that the mutex implementation will have any noticeable performance impact.
And, given that it's now something like 15 years since support for STREX was introduced in ARMv6, and more than 10 years since support for SWP was deleted in ARMv7, it doesn't seem entirely unreasonable for oe- core to pick the newer paradigm as the case to optimise for. Distros that want to target ARMv5 or older are obviously free to do so and they can carry the SWP patch locally if they want to. But as far as oe-core itself is concerned, at this point it seems like it's just scar tissue.
p.
Phil
Quoted 17 lines · Phil Blundell
Quoted 14 lines · Khem Raj
Quoted 10 lines · Li Zhou
The swpb in macro
MUTEX_SETwill cause "undefined instruction" error
on the new arm arches which don't support this assembly instruction any more. If use ldrex/strex to replace swpb, the old arm arches don't
support them. So to avoid this issue, just disable the ARM assembler
mutex code, and use the default pthreads mutex.Quoted 1 line
it would be good to keep this for older < armv5 arches
Quoted 7 lines
I guess you meant "<= ARMv5". STREX etc were introduced in ARMv6, so ARMv5 (and ARMv5TE) don't have it. But in any case, won't the default libpthread mutex work just fine on those older architectures? There is no SMP on anything before ARMv6 anyway so lock contention will be relatively low, and it seems fairly unlikely that anybody has a real- world application which uses db so heavily that the mutex implementation will have any noticeable performance impact.
yes I meant <= v5, it should work usually, I am just thinking its a untested option, it may not be as bad as I think but some testing might be useful
Quoted 8 lines
And, given that it's now something like 15 years since support for STREX was introduced in ARMv6, and more than 10 years since support for SWP was deleted in ARMv7, it doesn't seem entirely unreasonable for oe- core to pick the newer paradigm as the case to optimise for. Distros that want to target ARMv5 or older are obviously free to do so and they can carry the SWP patch locally if they want to. But as far as oe-core itself is concerned, at this point it seems like it's just scar tissue.
yeah agree here.
Quoted 3 lines
p.
Quoted 5 lines · Khem Raj
yes I meant <= v5, it should work usually, I am just thinking its a untested
option, it may not be as bad as I think but some testing might be useful
Well, I admit I haven't looked at the actual code, but from the comments in the patch I get the impression that it just causes db to use the same code (i.e. pthread_mutex_xx) on ARM as it already was doing on every other architecture. I think it's safe to say that pthread_mutex_lock() on ARM probably does work, otherwise any number of programs would be broken, and db probably does work with pthread_mutex_lock generically otherwise it would be broken on x86 and so on.
You're right of course that this specific combination could do with some testing but all in all it seems like a fairly low-risk change.
p.