[PATCH v2 0/2] meson: ensure we enable CMPXCHG128 on x86_64

Paolo Bonzini posted 2 patches 1 month, 2 weeks ago
There is a newer version of this series
meson.build | 33 ++++++++++++++++++++-------------
1 file changed, 20 insertions(+), 13 deletions(-)
[PATCH v2 0/2] meson: ensure we enable CMPXCHG128 on x86_64
Posted by Paolo Bonzini 1 month, 2 weeks ago
Alex discovered that CMPXCHG128 was not enabled when building for
x86_64, resulting in slow execution for wide atomic instructions,
creating a huge contention when combined with a high number of cpus
(found while booting android aarch64 guest on x86_64 host).

The problem is that even though we enable -mcx16 option for x86_64, this
is not used when testing for CMPXCHG128. Thus, we silently turn it off.

x86_64 is the only architecture adding machine flags for now, so the
problem is limited to this host architecture.  However, the problem
is generic, so define a new variable for all the -m options, so that
they can be used for other such tests in the future.

Based-on: <20241004223715.1275428-1-pierrick.bouvier@linaro.org>
Supersedes: <20241004220123.978938-1-pierrick.bouvier@linaro.org>

Paolo Bonzini (2):
  meson: define qemu_isa_flags
  meson: ensure -mcx16 is passed when detecting ATOMIC128

 meson.build | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)

-- 
2.46.1
Re: [PATCH v2 0/2] meson: ensure we enable CMPXCHG128 on x86_64
Posted by Pierrick Bouvier 1 month, 2 weeks ago
On 10/7/24 01:43, Paolo Bonzini wrote:
> 
> Alex discovered that CMPXCHG128 was not enabled when building for
> x86_64, resulting in slow execution for wide atomic instructions,
> creating a huge contention when combined with a high number of cpus
> (found while booting android aarch64 guest on x86_64 host).
> 
> The problem is that even though we enable -mcx16 option for x86_64, this
> is not used when testing for CMPXCHG128. Thus, we silently turn it off.
> 
> x86_64 is the only architecture adding machine flags for now, so the
> problem is limited to this host architecture.  However, the problem
> is generic, so define a new variable for all the -m options, so that
> they can be used for other such tests in the future.
> 
> Based-on: <20241004223715.1275428-1-pierrick.bouvier@linaro.org>
> Supersedes: <20241004220123.978938-1-pierrick.bouvier@linaro.org>
> 
> Paolo Bonzini (2):
>    meson: define qemu_isa_flags
>    meson: ensure -mcx16 is passed when detecting ATOMIC128
> 
>   meson.build | 33 ++++++++++++++++++++-------------
>   1 file changed, 20 insertions(+), 13 deletions(-)
> 

Hi Paolo,

Thanks for fixing this.

Series:
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>

I was wondering why we have a specific flags path for x64.
People who are interested in getting machine specific binaries can 
always play with CFLAGS, so what was the original intent here?

Thanks,
Pierrick
Re: [PATCH v2 0/2] meson: ensure we enable CMPXCHG128 on x86_64
Posted by Alex Bennée 1 month, 2 weeks ago
Paolo Bonzini <pbonzini@redhat.com> writes:

> Alex discovered that CMPXCHG128 was not enabled when building for
> x86_64, resulting in slow execution for wide atomic instructions,
> creating a huge contention when combined with a high number of cpus
> (found while booting android aarch64 guest on x86_64 host).
>
> The problem is that even though we enable -mcx16 option for x86_64, this
> is not used when testing for CMPXCHG128. Thus, we silently turn it off.
>
> x86_64 is the only architecture adding machine flags for now, so the
> problem is limited to this host architecture.  However, the problem
> is generic, so define a new variable for all the -m options, so that
> they can be used for other such tests in the future.
>
> Based-on: <20241004223715.1275428-1-pierrick.bouvier@linaro.org>
> Supersedes: <20241004220123.978938-1-pierrick.bouvier@linaro.org>

Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Tested-by: Alex Bennée <alex.bennee@linaro.org>

-- 
Alex Bennée
Virtualisation Tech Lead @ Linaro
Re: [PATCH v2 0/2] meson: ensure we enable CMPXCHG128 on x86_64
Posted by Michael Tokarev 1 month, 2 weeks ago
07.10.2024 11:43, Paolo Bonzini wrote:
> 
> Alex discovered that CMPXCHG128 was not enabled when building for
> x86_64, resulting in slow execution for wide atomic instructions,
> creating a huge contention when combined with a high number of cpus
> (found while booting android aarch64 guest on x86_64 host).
> 
> The problem is that even though we enable -mcx16 option for x86_64, this
> is not used when testing for CMPXCHG128. Thus, we silently turn it off.
> 
> x86_64 is the only architecture adding machine flags for now, so the
> problem is limited to this host architecture.  However, the problem
> is generic, so define a new variable for all the -m options, so that
> they can be used for other such tests in the future.
> 
> Based-on: <20241004223715.1275428-1-pierrick.bouvier@linaro.org>
> Supersedes: <20241004220123.978938-1-pierrick.bouvier@linaro.org>
> 
> Paolo Bonzini (2):
>    meson: define qemu_isa_flags
>    meson: ensure -mcx16 is passed when detecting ATOMIC128
> 
>   meson.build | 33 ++++++++++++++++++++-------------
>   1 file changed, 20 insertions(+), 13 deletions(-)

Series:
Reviewed-By: Michael Tokarev <mjt@tls.msk.ru>

Yeah, this is exactly what I thought about when replying to email
by Pierrick Bouvier.  Well, with less details ofc :)

Thanks,

/mjt