b18e99
Adjusted for backport to c8s by modifying sysdeps/x86/cacheinfo.h.
b18e99
b18e99
commit 885a7f0feee951f514a121788f46f33b2867110f
b18e99
Author: Noah Goldstein <goldstein.w.n@gmail.com>
b18e99
Date:   Fri Aug 11 12:29:11 2023 -0500
b18e99
b18e99
    x86: Fix incorrect scope of setting `shared_per_thread` [BZ# 30745]
b18e99
    
b18e99
    The:
b18e99
    
b18e99
    ```
b18e99
        if (shared_per_thread > 0 && threads > 0)
b18e99
          shared_per_thread /= threads;
b18e99
    ```
b18e99
    
b18e99
    Code was accidentally moved to inside the else scope.  This doesn't
b18e99
    match how it was previously (before af992e7abd).
b18e99
    
b18e99
    This patch fixes that by putting the division after the `else` block.
b18e99
b18e99
diff --git a/sysdeps/x86/cacheinfo.h b/sysdeps/x86/cacheinfo.h
b18e99
index 4dbfa979ef052eaa..e53fa25106c95253 100644
b18e99
--- a/sysdeps/x86/cacheinfo.h
b18e99
+++ b/sysdeps/x86/cacheinfo.h
b18e99
@@ -243,11 +243,10 @@ get_common_cache_info (long int *shared_ptr, long int * shared_per_thread_ptr, u
b18e99
 	     level.  */
b18e99
 	  threads = ((cpu_features->features[COMMON_CPUID_INDEX_1].cpuid.ebx >> 16)
b18e99
 		     & 0xff);
b18e99
-
b18e99
-	  /* Get per-thread size of highest level cache.  */
b18e99
-	  if (shared_per_thread > 0 && threads > 0)
b18e99
-	    shared_per_thread /= threads;
b18e99
 	}
b18e99
+      /* Get per-thread size of highest level cache.  */
b18e99
+      if (shared_per_thread > 0 && threads > 0)
b18e99
+	shared_per_thread /= threads;
b18e99
     }
b18e99
 
b18e99
   /* Account for non-inclusive L2 and L3 caches.  */