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