arrfab / rpms / glibc

Forked from rpms/glibc 5 years ago
Clone

Blame SOURCES/glibc-rh1292018-0.patch

147e83
commit a3d9ab5070b56b49aa91be2887fa5b118012b2cd
147e83
Author: H.J. Lu <hjl.tools@gmail.com>
147e83
Date:   Tue Mar 31 13:17:51 2015 -0700
147e83
147e83
    Limit threads sharing L2 cache to 2 for SLM/KNL
147e83
    
147e83
    Silvermont and Knights Landing have a modular system design with two cores
147e83
    sharing an L2 cache.  If more than 2 cores are detected to shared L2 cache,
147e83
    it should be adjusted for Silvermont and Knights Landing.
147e83
    
147e83
        [BZ #18185]
147e83
        * sysdeps/x86_64/cacheinfo.c (init_cacheinfo): Limit threads
147e83
        sharing L2 cache to 2 for Silvermont/Knights Landing.
147e83
147e83
diff --git a/sysdeps/x86_64/cacheinfo.c b/sysdeps/x86_64/cacheinfo.c
147e83
index f1cbf50..b99fb9a 100644
147e83
--- a/sysdeps/x86_64/cacheinfo.c
147e83
+++ b/sysdeps/x86_64/cacheinfo.c
147e83
@@ -585,6 +585,10 @@ init_cacheinfo (void)
147e83
       __cpuid (1, eax, ebx_1, ecx, edx);
147e83
 #endif
147e83
 
147e83
+      unsigned int family = (eax >> 8) & 0x0f;
147e83
+      unsigned int model = (eax >> 4) & 0x0f;
147e83
+      unsigned int extended_model = (eax >> 12) & 0xf0;
147e83
+
147e83
 #ifndef DISABLE_PREFERRED_MEMORY_INSTRUCTION
147e83
       /* Intel prefers SSSE3 instructions for memory/string routines
147e83
 	 if they are available.  */
147e83
@@ -647,6 +651,25 @@ init_cacheinfo (void)
147e83
 		}
147e83
 	    }
147e83
 	  threads += 1;
147e83
+	  if (threads > 2 && level == 2 && family == 6)
147e83
+	    {
147e83
+	      model += extended_model;
147e83
+	      switch (model)
147e83
+		{
147e83
+		case 0x57:
147e83
+		  /* Knights Landing has L2 cache shared by 2 cores.  */
147e83
+		case 0x37:
147e83
+		case 0x4a:
147e83
+		case 0x4d:
147e83
+		case 0x5a:
147e83
+		case 0x5d:
147e83
+		  /* Silvermont has L2 cache shared by 2 cores.  */
147e83
+		  threads = 2;
147e83
+		  break;
147e83
+		default:
147e83
+		  break;
147e83
+		}
147e83
+	    }
147e83
 	}
147e83
       else
147e83
 	{