]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
32bit memset-sse2.S fails with uneven cache size
authorUlrich Drepper <drepper@redhat.com>
Fri, 5 Nov 2010 11:57:46 +0000 (07:57 -0400)
committerAndreas Schwab <schwab@redhat.com>
Wed, 1 Dec 2010 14:35:07 +0000 (15:35 +0100)
32bit memset-sse2.S assumes cache size is multiple of 128 bytes.  If
it isn't true, memset-sse2.S will fail.  For example, a processor can
have 24576 KB L3 cache and 20 cores. That is 2516582 byte per core. Half
of it is 1258291, which isn't helpful for vector instructions.  This
patch rounds cache sizes to multiple of 256 bytes and adds "raw" cache
sizes.
(cherry picked from commit c0dde15b5dba7e02ce6f36eab3a4d1c166f9951b)

ChangeLog
sysdeps/i386/i686/cacheinfo.c
sysdeps/x86_64/cacheinfo.c

index 77cd729ba7709bfe68081187fa1f3401f4a5e3a2..2c8f7cd5b7b26185184848fcf2d8611a19fcf057 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2010-11-03  H.J. Lu  <hongjiu.lu@intel.com>
+
+       [BZ #12191]
+       * sysdeps/i386/i686/cacheinfo.c (__x86_64_raw_data_cache_size): New.
+       (__x86_64_raw_data_cache_size_half): Likewise.
+       (__x86_64_raw_shared_cache_size): Likewise.
+       (__x86_64_raw_shared_cache_size_half): Likewise.
+
+       * sysdeps/x86_64/cacheinfo.c (__x86_64_raw_data_cache_size): New.
+       (__x86_64_raw_data_cache_size_half): Likewise.
+       (__x86_64_raw_shared_cache_size): Likewise.
+       (__x86_64_raw_shared_cache_size_half): Likewise.
+       (init_cacheinfo): Set __x86_64_raw_data_cache_size,
+       __x86_64_raw_data_cache_size_half, __x86_64_raw_shared_cache_size
+       and __x86_64_raw_shared_cache_size_half.  Round
+       __x86_64_data_cache_size_half, __x86_64_data_cache_size
+       __x86_64_shared_cache_size_half and __x86_64_shared_cache_size,
+       to multiple of 256 bytes.
+
 2010-11-03  Ulrich Drepper  <drepper@gmail.com>
 
        [BZ #12167]
index f8b7f521cae16df1cc5ed7f30a7e9e0c66db207d..3635961727fdab74f53d7c52fa5556083f2f5693 100644 (file)
@@ -1,7 +1,11 @@
 #define __x86_64_data_cache_size __x86_data_cache_size
+#define __x86_64_raw_data_cache_size __x86_raw_data_cache_size
 #define __x86_64_data_cache_size_half __x86_data_cache_size_half
+#define __x86_64_raw_data_cache_size_half __x86_raw_data_cache_size_half
 #define __x86_64_shared_cache_size __x86_shared_cache_size
+#define __x86_64_raw_shared_cache_size __x86_raw_shared_cache_size
 #define __x86_64_shared_cache_size_half __x86_shared_cache_size_half
+#define __x86_64_raw_shared_cache_size_half __x86_raw_shared_cache_size_half
 
 #define DISABLE_PREFETCHW
 #define DISABLE_PREFERRED_MEMORY_INSTRUCTION
index 54220379ec9a3c15cba4dbadf8e70819c52d4939..eae54e725a658b8bfed6408a4127132c60615cc3 100644 (file)
@@ -455,13 +455,21 @@ __cache_sysconf (int name)
 
 
 /* Data cache size for use in memory and string routines, typically
-   L1 size.  */
+   L1 size, rounded to multiple of 256 bytes.  */
 long int __x86_64_data_cache_size_half attribute_hidden = 32 * 1024 / 2;
 long int __x86_64_data_cache_size attribute_hidden = 32 * 1024;
+/* Similar to __x86_64_data_cache_size_half, but not rounded.  */
+long int __x86_64_raw_data_cache_size_half attribute_hidden = 32 * 1024 / 2;
+/* Similar to __x86_64_data_cache_size, but not rounded.  */
+long int __x86_64_raw_data_cache_size attribute_hidden = 32 * 1024;
 /* Shared cache size for use in memory and string routines, typically
-   L2 or L3 size.  */
+   L2 or L3 size, rounded to multiple of 256 bytes.  */
 long int __x86_64_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
 long int __x86_64_shared_cache_size attribute_hidden = 1024 * 1024;
+/* Similar to __x86_64_shared_cache_size_half, but not rounded.  */
+long int __x86_64_raw_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
+/* Similar to __x86_64_shared_cache_size, but not rounded.  */
+long int __x86_64_raw_shared_cache_size attribute_hidden = 1024 * 1024;
 
 #ifndef DISABLE_PREFETCHW
 /* PREFETCHW support flag for use in memory and string routines.  */
@@ -661,12 +669,20 @@ init_cacheinfo (void)
 
   if (data > 0)
     {
+      __x86_64_raw_data_cache_size_half = data / 2;
+      __x86_64_raw_data_cache_size = data;
+      /* Round data cache size to multiple of 256 bytes.  */
+      data = data & ~255L;
       __x86_64_data_cache_size_half = data / 2;
       __x86_64_data_cache_size = data;
     }
 
   if (shared > 0)
     {
+      __x86_64_raw_shared_cache_size_half = shared / 2;
+      __x86_64_raw_shared_cache_size = shared;
+      /* Round shared cache size to multiple of 256 bytes.  */
+      shared = shared & ~255L;
       __x86_64_shared_cache_size_half = shared / 2;
       __x86_64_shared_cache_size = shared;
     }