[v1] x86: Fix value for `x86_memset_non_temporal_threshold` when it is undesirable

Message ID 20240614180158.4084300-1-goldstein.w.n@gmail.com
State Committed
Commit 5b54a33435e5533653a9956728f2de9d16a3b4ee
Headers
Series [v1] x86: Fix value for `x86_memset_non_temporal_threshold` when it is undesirable |

Checks

Context Check Description
redhat-pt-bot/TryBot-32bit success Build for i686
redhat-pt-bot/TryBot-apply_patch success Patch applied to master at the time it was sent
linaro-tcwg-bot/tcwg_glibc_build--master-arm warning Patch is already merged
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 warning Patch is already merged

Commit Message

Noah Goldstein June 14, 2024, 6:01 p.m. UTC
  When we don't want to use non-temporal stores for memset, we set
`x86_memset_non_temporal_threshold` to SIZE_MAX.

The current code, however, we using `maximum_non_temporal_threshold`
as the upper bound which is `SIZE_MAX >> 4` so we ended up with a
value of `0`.

Fix is to just use `SIZE_MAX` as the upper bound for when setting the
tunable.
---
 sysdeps/x86/dl-cacheinfo.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Comments

Borislav Petkov June 14, 2024, 6:13 p.m. UTC | #1
On Fri, Jun 14, 2024 at 01:01:58PM -0500, Noah Goldstein wrote:
> When we don't want to use non-temporal stores for memset, we set
> `x86_memset_non_temporal_threshold` to SIZE_MAX.
> 
> The current code, however, we using `maximum_non_temporal_threshold`
> as the upper bound which is `SIZE_MAX >> 4` so we ended up with a
> value of `0`.
> 
> Fix is to just use `SIZE_MAX` as the upper bound for when setting the
> tunable.
> ---
>  sysdeps/x86/dl-cacheinfo.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
> index d2fe61b997..3a6ec4ef9f 100644
> --- a/sysdeps/x86/dl-cacheinfo.h
> +++ b/sysdeps/x86/dl-cacheinfo.h
> @@ -1044,9 +1044,9 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
>    TUNABLE_SET_WITH_BOUNDS (x86_non_temporal_threshold, non_temporal_threshold,
>  			   minimum_non_temporal_threshold,
>  			   maximum_non_temporal_threshold);
> -  TUNABLE_SET_WITH_BOUNDS (
> -      x86_memset_non_temporal_threshold, memset_non_temporal_threshold,
> -      minimum_non_temporal_threshold, maximum_non_temporal_threshold);
> +  TUNABLE_SET_WITH_BOUNDS (x86_memset_non_temporal_threshold,
> +			   memset_non_temporal_threshold,
> +			   minimum_non_temporal_threshold, SIZE_MAX);
>    TUNABLE_SET_WITH_BOUNDS (x86_rep_movsb_threshold, rep_movsb_threshold,
>  			   minimum_rep_movsb_threshold, SIZE_MAX);
>    TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1,
> -- 

Yap, that does it, thanks!

Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
  
H.J. Lu June 14, 2024, 9:45 p.m. UTC | #2
On Fri, Jun 14, 2024 at 11:02 AM Noah Goldstein <goldstein.w.n@gmail.com> wrote:
>
> When we don't want to use non-temporal stores for memset, we set
> `x86_memset_non_temporal_threshold` to SIZE_MAX.
>
> The current code, however, we using `maximum_non_temporal_threshold`
> as the upper bound which is `SIZE_MAX >> 4` so we ended up with a
> value of `0`.
>
> Fix is to just use `SIZE_MAX` as the upper bound for when setting the
> tunable.
> ---
>  sysdeps/x86/dl-cacheinfo.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
> index d2fe61b997..3a6ec4ef9f 100644
> --- a/sysdeps/x86/dl-cacheinfo.h
> +++ b/sysdeps/x86/dl-cacheinfo.h
> @@ -1044,9 +1044,9 @@ dl_init_cacheinfo (struct cpu_features *cpu_features)
>    TUNABLE_SET_WITH_BOUNDS (x86_non_temporal_threshold, non_temporal_threshold,
>                            minimum_non_temporal_threshold,
>                            maximum_non_temporal_threshold);
> -  TUNABLE_SET_WITH_BOUNDS (
> -      x86_memset_non_temporal_threshold, memset_non_temporal_threshold,
> -      minimum_non_temporal_threshold, maximum_non_temporal_threshold);
> +  TUNABLE_SET_WITH_BOUNDS (x86_memset_non_temporal_threshold,
> +                          memset_non_temporal_threshold,
> +                          minimum_non_temporal_threshold, SIZE_MAX);
>    TUNABLE_SET_WITH_BOUNDS (x86_rep_movsb_threshold, rep_movsb_threshold,
>                            minimum_rep_movsb_threshold, SIZE_MAX);
>    TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1,
> --
> 2.34.1
>

LGTM.

Reviewed-by: H.J. Lu <hjl.tools@gmail.com>

Thanks.
  

Patch

diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
index d2fe61b997..3a6ec4ef9f 100644
--- a/sysdeps/x86/dl-cacheinfo.h
+++ b/sysdeps/x86/dl-cacheinfo.h
@@ -1044,9 +1044,9 @@  dl_init_cacheinfo (struct cpu_features *cpu_features)
   TUNABLE_SET_WITH_BOUNDS (x86_non_temporal_threshold, non_temporal_threshold,
 			   minimum_non_temporal_threshold,
 			   maximum_non_temporal_threshold);
-  TUNABLE_SET_WITH_BOUNDS (
-      x86_memset_non_temporal_threshold, memset_non_temporal_threshold,
-      minimum_non_temporal_threshold, maximum_non_temporal_threshold);
+  TUNABLE_SET_WITH_BOUNDS (x86_memset_non_temporal_threshold,
+			   memset_non_temporal_threshold,
+			   minimum_non_temporal_threshold, SIZE_MAX);
   TUNABLE_SET_WITH_BOUNDS (x86_rep_movsb_threshold, rep_movsb_threshold,
 			   minimum_rep_movsb_threshold, SIZE_MAX);
   TUNABLE_SET_WITH_BOUNDS (x86_rep_stosb_threshold, rep_stosb_threshold, 1,