olga / rpms / glibc

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