Blame sysdeps/x86/cacheinfo.h

Packit Service 4f62bc
/* x86 cache info.
Packit Service 4f62bc
   Copyright (C) 2020 Free Software Foundation, Inc.
Packit Service 4f62bc
   This file is part of the GNU C Library.
Packit Service 4f62bc
Packit Service 4f62bc
   The GNU C Library is free software; you can redistribute it and/or
Packit Service 4f62bc
   modify it under the terms of the GNU Lesser General Public
Packit Service 4f62bc
   License as published by the Free Software Foundation; either
Packit Service 4f62bc
   version 2.1 of the License, or (at your option) any later version.
Packit Service 4f62bc
Packit Service 4f62bc
   The GNU C Library is distributed in the hope that it will be useful,
Packit Service 4f62bc
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 4f62bc
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit Service 4f62bc
   Lesser General Public License for more details.
Packit Service 4f62bc
Packit Service 4f62bc
   You should have received a copy of the GNU Lesser General Public
Packit Service 4f62bc
   License along with the GNU C Library; if not, see
Packit Service 4f62bc
   <https://www.gnu.org/licenses/>.  */
Packit Service 4f62bc
Packit Service 4f62bc
#include <assert.h>
Packit Service 4f62bc
#include <unistd.h>
Packit Service 4f62bc
Packit Service 4f62bc
/* Data cache size for use in memory and string routines, typically
Packit Service 4f62bc
   L1 size, rounded to multiple of 256 bytes.  */
Packit Service 4f62bc
long int __x86_data_cache_size_half attribute_hidden = 32 * 1024 / 2;
Packit Service 4f62bc
long int __x86_data_cache_size attribute_hidden = 32 * 1024;
Packit Service 4f62bc
/* Similar to __x86_data_cache_size_half, but not rounded.  */
Packit Service 4f62bc
long int __x86_raw_data_cache_size_half attribute_hidden = 32 * 1024 / 2;
Packit Service 4f62bc
/* Similar to __x86_data_cache_size, but not rounded.  */
Packit Service 4f62bc
long int __x86_raw_data_cache_size attribute_hidden = 32 * 1024;
Packit Service 4f62bc
/* Shared cache size for use in memory and string routines, typically
Packit Service 4f62bc
   L2 or L3 size, rounded to multiple of 256 bytes.  */
Packit Service 4f62bc
long int __x86_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
Packit Service 4f62bc
long int __x86_shared_cache_size attribute_hidden = 1024 * 1024;
Packit Service 4f62bc
/* Similar to __x86_shared_cache_size_half, but not rounded.  */
Packit Service 4f62bc
long int __x86_raw_shared_cache_size_half attribute_hidden = 1024 * 1024 / 2;
Packit Service 4f62bc
/* Similar to __x86_shared_cache_size, but not rounded.  */
Packit Service 4f62bc
long int __x86_raw_shared_cache_size attribute_hidden = 1024 * 1024;
Packit Service 4f62bc
Packit Service 4f62bc
/* Threshold to use non temporal store.  */
Packit Service 4f62bc
long int __x86_shared_non_temporal_threshold attribute_hidden;
Packit Service 4f62bc
Packit Service 4f62bc
/* Threshold to use Enhanced REP MOVSB.  */
Packit Service 4f62bc
long int __x86_rep_movsb_threshold attribute_hidden = 2048;
Packit Service 4f62bc
Packit Service 4f62bc
/* Threshold to use Enhanced REP STOSB.  */
Packit Service 4f62bc
long int __x86_rep_stosb_threshold attribute_hidden = 2048;
Packit Service 4f62bc
Packit Service 4f62bc
static void
Packit Service 4f62bc
get_common_cache_info (long int *shared_ptr, unsigned int *threads_ptr,
Packit Service 4f62bc
		       long int core)
Packit Service 4f62bc
{
Packit Service 4f62bc
  unsigned int eax;
Packit Service 4f62bc
  unsigned int ebx;
Packit Service 4f62bc
  unsigned int ecx;
Packit Service 4f62bc
  unsigned int edx;
Packit Service 4f62bc
Packit Service 4f62bc
  /* Number of logical processors sharing L2 cache.  */
Packit Service 4f62bc
  int threads_l2;
Packit Service 4f62bc
Packit Service 4f62bc
  /* Number of logical processors sharing L3 cache.  */
Packit Service 4f62bc
  int threads_l3;
Packit Service 4f62bc
Packit Service 4f62bc
  const struct cpu_features *cpu_features = __get_cpu_features ();
Packit Service 4f62bc
  int max_cpuid = cpu_features->basic.max_cpuid;
Packit Service 4f62bc
  unsigned int family = cpu_features->basic.family;
Packit Service 4f62bc
  unsigned int model = cpu_features->basic.model;
Packit Service 4f62bc
  long int shared = *shared_ptr;
Packit Service 4f62bc
  unsigned int threads = *threads_ptr;
Packit Service 4f62bc
  bool inclusive_cache = true;
Packit Service 4f62bc
  bool support_count_mask = true;
Packit Service 4f62bc
Packit Service 4f62bc
  /* Try L3 first.  */
Packit Service 4f62bc
  unsigned int level = 3;
Packit Service 4f62bc
Packit Service 4f62bc
  if (cpu_features->basic.kind == arch_kind_zhaoxin && family == 6)
Packit Service 4f62bc
    support_count_mask = false;
Packit Service 4f62bc
Packit Service 4f62bc
  if (shared <= 0)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      /* Try L2 otherwise.  */
Packit Service 4f62bc
      level  = 2;
Packit Service 4f62bc
      shared = core;
Packit Service 4f62bc
      threads_l2 = 0;
Packit Service 4f62bc
      threads_l3 = -1;
Packit Service 4f62bc
    }
Packit Service 4f62bc
  else
Packit Service 4f62bc
    {
Packit Service 4f62bc
      threads_l2 = 0;
Packit Service 4f62bc
      threads_l3 = 0;
Packit Service 4f62bc
    }
Packit Service 4f62bc
Packit Service 4f62bc
  /* A value of 0 for the HTT bit indicates there is only a single
Packit Service 4f62bc
     logical processor.  */
Packit Service 4f62bc
  if (HAS_CPU_FEATURE (HTT))
Packit Service 4f62bc
    {
Packit Service 4f62bc
      /* Figure out the number of logical threads that share the
Packit Service 4f62bc
         highest cache level.  */
Packit Service 4f62bc
      if (max_cpuid >= 4)
Packit Service 4f62bc
        {
Packit Service 4f62bc
          int i = 0;
Packit Service 4f62bc
Packit Service 4f62bc
          /* Query until cache level 2 and 3 are enumerated.  */
Packit Service 4f62bc
          int check = 0x1 | (threads_l3 == 0) << 1;
Packit Service 4f62bc
          do
Packit Service 4f62bc
            {
Packit Service 4f62bc
              __cpuid_count (4, i++, eax, ebx, ecx, edx);
Packit Service 4f62bc
Packit Service 4f62bc
              /* There seems to be a bug in at least some Pentium Ds
Packit Service 4f62bc
                 which sometimes fail to iterate all cache parameters.
Packit Service 4f62bc
                 Do not loop indefinitely here, stop in this case and
Packit Service 4f62bc
                 assume there is no such information.  */
Packit Service 4f62bc
              if (cpu_features->basic.kind == arch_kind_intel
Packit Service 4f62bc
                  && (eax & 0x1f) == 0 )
Packit Service 4f62bc
                goto intel_bug_no_cache_info;
Packit Service 4f62bc
Packit Service 4f62bc
              switch ((eax >> 5) & 0x7)
Packit Service 4f62bc
                {
Packit Service 4f62bc
                  default:
Packit Service 4f62bc
                    break;
Packit Service 4f62bc
                  case 2:
Packit Service 4f62bc
                    if ((check & 0x1))
Packit Service 4f62bc
                      {
Packit Service 4f62bc
                        /* Get maximum number of logical processors
Packit Service 4f62bc
                           sharing L2 cache.  */
Packit Service 4f62bc
                        threads_l2 = (eax >> 14) & 0x3ff;
Packit Service 4f62bc
                        check &= ~0x1;
Packit Service 4f62bc
                      }
Packit Service 4f62bc
                    break;
Packit Service 4f62bc
                  case 3:
Packit Service 4f62bc
                    if ((check & (0x1 << 1)))
Packit Service 4f62bc
                      {
Packit Service 4f62bc
                        /* Get maximum number of logical processors
Packit Service 4f62bc
                           sharing L3 cache.  */
Packit Service 4f62bc
                        threads_l3 = (eax >> 14) & 0x3ff;
Packit Service 4f62bc
Packit Service 4f62bc
                        /* Check if L2 and L3 caches are inclusive.  */
Packit Service 4f62bc
                        inclusive_cache = (edx & 0x2) != 0;
Packit Service 4f62bc
                        check &= ~(0x1 << 1);
Packit Service 4f62bc
                      }
Packit Service 4f62bc
                    break;
Packit Service 4f62bc
                }
Packit Service 4f62bc
            }
Packit Service 4f62bc
          while (check);
Packit Service 4f62bc
Packit Service 4f62bc
          /* If max_cpuid >= 11, THREADS_L2/THREADS_L3 are the maximum
Packit Service 4f62bc
             numbers of addressable IDs for logical processors sharing
Packit Service 4f62bc
             the cache, instead of the maximum number of threads
Packit Service 4f62bc
             sharing the cache.  */
Packit Service 4f62bc
          if (max_cpuid >= 11 && support_count_mask)
Packit Service 4f62bc
            {
Packit Service 4f62bc
              /* Find the number of logical processors shipped in
Packit Service 4f62bc
                 one core and apply count mask.  */
Packit Service 4f62bc
              i = 0;
Packit Service 4f62bc
Packit Service 4f62bc
              /* Count SMT only if there is L3 cache.  Always count
Packit Service 4f62bc
                 core if there is no L3 cache.  */
Packit Service 4f62bc
              int count = ((threads_l2 > 0 && level == 3)
Packit Service 4f62bc
                           | ((threads_l3 > 0
Packit Service 4f62bc
                               || (threads_l2 > 0 && level == 2)) << 1));
Packit Service 4f62bc
Packit Service 4f62bc
              while (count)
Packit Service 4f62bc
                {
Packit Service 4f62bc
                  __cpuid_count (11, i++, eax, ebx, ecx, edx);
Packit Service 4f62bc
Packit Service 4f62bc
                  int shipped = ebx & 0xff;
Packit Service 4f62bc
                  int type = ecx & 0xff00;
Packit Service 4f62bc
                  if (shipped == 0 || type == 0)
Packit Service 4f62bc
                    break;
Packit Service 4f62bc
                  else if (type == 0x100)
Packit Service 4f62bc
                    {
Packit Service 4f62bc
                      /* Count SMT.  */
Packit Service 4f62bc
                      if ((count & 0x1))
Packit Service 4f62bc
                        {
Packit Service 4f62bc
                          int count_mask;
Packit Service 4f62bc
Packit Service 4f62bc
                          /* Compute count mask.  */
Packit Service 4f62bc
                          asm ("bsr %1, %0"
Packit Service 4f62bc
                               : "=r" (count_mask) : "g" (threads_l2));
Packit Service 4f62bc
                          count_mask = ~(-1 << (count_mask + 1));
Packit Service 4f62bc
                          threads_l2 = (shipped - 1) & count_mask;
Packit Service 4f62bc
                          count &= ~0x1;
Packit Service 4f62bc
                        }
Packit Service 4f62bc
                    }
Packit Service 4f62bc
                  else if (type == 0x200)
Packit Service 4f62bc
                    {
Packit Service 4f62bc
                      /* Count core.  */
Packit Service 4f62bc
                      if ((count & (0x1 << 1)))
Packit Service 4f62bc
                        {
Packit Service 4f62bc
                          int count_mask;
Packit Service 4f62bc
                          int threads_core
Packit Service 4f62bc
                            = (level == 2 ? threads_l2 : threads_l3);
Packit Service 4f62bc
Packit Service 4f62bc
                          /* Compute count mask.  */
Packit Service 4f62bc
                          asm ("bsr %1, %0"
Packit Service 4f62bc
                               : "=r" (count_mask) : "g" (threads_core));
Packit Service 4f62bc
                          count_mask = ~(-1 << (count_mask + 1));
Packit Service 4f62bc
                          threads_core = (shipped - 1) & count_mask;
Packit Service 4f62bc
                          if (level == 2)
Packit Service 4f62bc
                            threads_l2 = threads_core;
Packit Service 4f62bc
                          else
Packit Service 4f62bc
                            threads_l3 = threads_core;
Packit Service 4f62bc
                          count &= ~(0x1 << 1);
Packit Service 4f62bc
                        }
Packit Service 4f62bc
                    }
Packit Service 4f62bc
                }
Packit Service 4f62bc
            }
Packit Service 4f62bc
          if (threads_l2 > 0)
Packit Service 4f62bc
            threads_l2 += 1;
Packit Service 4f62bc
          if (threads_l3 > 0)
Packit Service 4f62bc
            threads_l3 += 1;
Packit Service 4f62bc
          if (level == 2)
Packit Service 4f62bc
            {
Packit Service 4f62bc
              if (threads_l2)
Packit Service 4f62bc
                {
Packit Service 4f62bc
                  threads = threads_l2;
Packit Service 4f62bc
                  if (cpu_features->basic.kind == arch_kind_intel
Packit Service 4f62bc
                      && threads > 2
Packit Service 4f62bc
                      && family == 6)
Packit Service 4f62bc
                    switch (model)
Packit Service 4f62bc
                      {
Packit Service 4f62bc
                        case 0x37:
Packit Service 4f62bc
                        case 0x4a:
Packit Service 4f62bc
                        case 0x4d:
Packit Service 4f62bc
                        case 0x5a:
Packit Service 4f62bc
                        case 0x5d:
Packit Service 4f62bc
                          /* Silvermont has L2 cache shared by 2 cores.  */
Packit Service 4f62bc
                          threads = 2;
Packit Service 4f62bc
                          break;
Packit Service 4f62bc
                        default:
Packit Service 4f62bc
                          break;
Packit Service 4f62bc
                      }
Packit Service 4f62bc
                }
Packit Service 4f62bc
            }
Packit Service 4f62bc
          else if (threads_l3)
Packit Service 4f62bc
            threads = threads_l3;
Packit Service 4f62bc
        }
Packit Service 4f62bc
      else
Packit Service 4f62bc
        {
Packit Service 4f62bc
intel_bug_no_cache_info:
Packit Service 4f62bc
          /* Assume that all logical threads share the highest cache
Packit Service 4f62bc
             level.  */
Packit Service 4f62bc
          threads
Packit Service 4f62bc
            = ((cpu_features->features[COMMON_CPUID_INDEX_1].cpuid.ebx
Packit Service 4f62bc
                >> 16) & 0xff);
Packit Service 4f62bc
        }
Packit Service 4f62bc
Packit Service 4f62bc
        /* Cap usage of highest cache level to the number of supported
Packit Service 4f62bc
           threads.  */
Packit Service 4f62bc
        if (shared > 0 && threads > 0)
Packit Service 4f62bc
          shared /= threads;
Packit Service 4f62bc
    }
Packit Service 4f62bc
Packit Service 4f62bc
  /* Account for non-inclusive L2 and L3 caches.  */
Packit Service 4f62bc
  if (!inclusive_cache)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      if (threads_l2 > 0)
Packit Service 4f62bc
        core /= threads_l2;
Packit Service 4f62bc
      shared += core;
Packit Service 4f62bc
    }
Packit Service 4f62bc
Packit Service 4f62bc
  *shared_ptr = shared;
Packit Service 4f62bc
  *threads_ptr = threads;
Packit Service 4f62bc
}
Packit Service 4f62bc
Packit Service 4f62bc
static void
Packit Service 4f62bc
init_cacheinfo (void)
Packit Service 4f62bc
{
Packit Service 4f62bc
  /* Find out what brand of processor.  */
Packit Service 4f62bc
  unsigned int ebx;
Packit Service 4f62bc
  unsigned int ecx;
Packit Service 4f62bc
  unsigned int edx;
Packit Service 4f62bc
  int max_cpuid_ex;
Packit Service 4f62bc
  long int data = -1;
Packit Service 4f62bc
  long int shared = -1;
Packit Service 4f62bc
  long int core;
Packit Service 4f62bc
  unsigned int threads = 0;
Packit Service 4f62bc
  const struct cpu_features *cpu_features = __get_cpu_features ();
Packit Service 4f62bc
Packit Service 4f62bc
  /* NB: In libc.so, cpu_features is defined in ld.so and is initialized
Packit Service 4f62bc
     by DL_PLATFORM_INIT or IFUNC relocation before init_cacheinfo is
Packit Service 4f62bc
     called by IFUNC relocation.  In libc.a, init_cacheinfo is called
Packit Service 4f62bc
     from init_cpu_features by ARCH_INIT_CPU_FEATURES.  */
Packit Service 4f62bc
  assert (cpu_features->basic.kind != arch_kind_unknown);
Packit Service 4f62bc
Packit Service 4f62bc
  if (cpu_features->basic.kind == arch_kind_intel)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      data = handle_intel (_SC_LEVEL1_DCACHE_SIZE, cpu_features);
Packit Service 4f62bc
      core = handle_intel (_SC_LEVEL2_CACHE_SIZE, cpu_features);
Packit Service 4f62bc
      shared = handle_intel (_SC_LEVEL3_CACHE_SIZE, cpu_features);
Packit Service 4f62bc
Packit Service 4f62bc
      get_common_cache_info (&shared, &threads, core);
Packit Service 4f62bc
    }
Packit Service 4f62bc
  else if (cpu_features->basic.kind == arch_kind_zhaoxin)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      data = handle_zhaoxin (_SC_LEVEL1_DCACHE_SIZE);
Packit Service 4f62bc
      core = handle_zhaoxin (_SC_LEVEL2_CACHE_SIZE);
Packit Service 4f62bc
      shared = handle_zhaoxin (_SC_LEVEL3_CACHE_SIZE);
Packit Service 4f62bc
Packit Service 4f62bc
      get_common_cache_info (&shared, &threads, core);
Packit Service 4f62bc
    }
Packit Service 4f62bc
  else if (cpu_features->basic.kind == arch_kind_amd)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      data   = handle_amd (_SC_LEVEL1_DCACHE_SIZE);
Packit Service 4f62bc
      long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE);
Packit Service 4f62bc
      shared = handle_amd (_SC_LEVEL3_CACHE_SIZE);
Packit Service 4f62bc
Packit Service 4f62bc
      /* Get maximum extended function. */
Packit Service 4f62bc
      __cpuid (0x80000000, max_cpuid_ex, ebx, ecx, edx);
Packit Service 4f62bc
Packit Service 4f62bc
      if (shared <= 0)
Packit Service 4f62bc
	/* No shared L3 cache.  All we have is the L2 cache.  */
Packit Service 4f62bc
	shared = core;
Packit Service 4f62bc
      else
Packit Service 4f62bc
	{
Packit Service 4f62bc
	  /* Figure out the number of logical threads that share L3.  */
Packit Service 4f62bc
	  if (max_cpuid_ex >= 0x80000008)
Packit Service 4f62bc
	    {
Packit Service 4f62bc
	      /* Get width of APIC ID.  */
Packit Service 4f62bc
	      __cpuid (0x80000008, max_cpuid_ex, ebx, ecx, edx);
Packit Service 4f62bc
	      threads = 1 << ((ecx >> 12) & 0x0f);
Packit Service 4f62bc
	    }
Packit Service 4f62bc
Packit Service 4f62bc
	  if (threads == 0 || cpu_features->basic.family >= 0x17)
Packit Service 4f62bc
	    {
Packit Service 4f62bc
	      /* If APIC ID width is not available, use logical
Packit Service 4f62bc
		 processor count.  */
Packit Service 4f62bc
	      __cpuid (0x00000001, max_cpuid_ex, ebx, ecx, edx);
Packit Service 4f62bc
Packit Service 4f62bc
	      if ((edx & (1 << 28)) != 0)
Packit Service 4f62bc
		threads = (ebx >> 16) & 0xff;
Packit Service 4f62bc
	    }
Packit Service 4f62bc
Packit Service 4f62bc
	  /* Cap usage of highest cache level to the number of
Packit Service 4f62bc
	     supported threads.  */
Packit Service 4f62bc
	  if (threads > 0)
Packit Service 4f62bc
	    shared /= threads;
Packit Service 4f62bc
Packit Service 4f62bc
	  /* Get shared cache per ccx for Zen architectures.  */
Packit Service 4f62bc
	  if (cpu_features->basic.family >= 0x17)
Packit Service 4f62bc
	    {
Packit Service 4f62bc
	      unsigned int eax;
Packit Service 4f62bc
Packit Service 4f62bc
	      /* Get number of threads share the L3 cache in CCX.  */
Packit Service 4f62bc
	      __cpuid_count (0x8000001D, 0x3, eax, ebx, ecx, edx);
Packit Service 4f62bc
Packit Service 4f62bc
	      unsigned int threads_per_ccx = ((eax >> 14) & 0xfff) + 1;
Packit Service 4f62bc
	      shared *= threads_per_ccx;
Packit Service 4f62bc
	    }
Packit Service 4f62bc
	  else
Packit Service 4f62bc
	    {
Packit Service 4f62bc
	      /* Account for exclusive L2 and L3 caches.  */
Packit Service 4f62bc
	      shared += core;
Packit Service 4f62bc
            }
Packit Service 4f62bc
	}
Packit Service 4f62bc
    }
Packit Service 4f62bc
Packit Service 4f62bc
  if (cpu_features->data_cache_size != 0)
Packit Service 4f62bc
    data = cpu_features->data_cache_size;
Packit Service 4f62bc
Packit Service 4f62bc
  if (data > 0)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      __x86_raw_data_cache_size_half = data / 2;
Packit Service 4f62bc
      __x86_raw_data_cache_size = data;
Packit Service 4f62bc
      /* Round data cache size to multiple of 256 bytes.  */
Packit Service 4f62bc
      data = data & ~255L;
Packit Service 4f62bc
      __x86_data_cache_size_half = data / 2;
Packit Service 4f62bc
      __x86_data_cache_size = data;
Packit Service 4f62bc
    }
Packit Service 4f62bc
Packit Service 4f62bc
  if (cpu_features->shared_cache_size != 0)
Packit Service 4f62bc
    shared = cpu_features->shared_cache_size;
Packit Service 4f62bc
Packit Service 4f62bc
  if (shared > 0)
Packit Service 4f62bc
    {
Packit Service 4f62bc
      __x86_raw_shared_cache_size_half = shared / 2;
Packit Service 4f62bc
      __x86_raw_shared_cache_size = shared;
Packit Service 4f62bc
      /* Round shared cache size to multiple of 256 bytes.  */
Packit Service 4f62bc
      shared = shared & ~255L;
Packit Service 4f62bc
      __x86_shared_cache_size_half = shared / 2;
Packit Service 4f62bc
      __x86_shared_cache_size = shared;
Packit Service 4f62bc
    }
Packit Service 4f62bc
Packit Service 4f62bc
  /* The default setting for the non_temporal threshold is 3/4 of one
Packit Service 4f62bc
     thread's share of the chip's cache. For most Intel and AMD processors
Packit Service 4f62bc
     with an initial release date between 2017 and 2020, a thread's typical
Packit Service 4f62bc
     share of the cache is from 500 KBytes to 2 MBytes. Using the 3/4
Packit Service 4f62bc
     threshold leaves 125 KBytes to 500 KBytes of the thread's data
Packit Service 4f62bc
     in cache after a maximum temporal copy, which will maintain
Packit Service 4f62bc
     in cache a reasonable portion of the thread's stack and other
Packit Service 4f62bc
     active data. If the threshold is set higher than one thread's
Packit Service 4f62bc
     share of the cache, it has a substantial risk of negatively
Packit Service 4f62bc
     impacting the performance of other threads running on the chip. */
Packit Service 4f62bc
  __x86_shared_non_temporal_threshold
Packit Service 4f62bc
    = (cpu_features->non_temporal_threshold != 0
Packit Service 4f62bc
       ? cpu_features->non_temporal_threshold
Packit Service 4f62bc
       : __x86_shared_cache_size * 3 / 4);
Packit Service 4f62bc
Packit Service 4f62bc
  /* NB: The REP MOVSB threshold must be greater than VEC_SIZE * 8.  */
Packit Service 4f62bc
  unsigned int minimum_rep_movsb_threshold;
Packit Service 4f62bc
  /* NB: The default REP MOVSB threshold is 2048 * (VEC_SIZE / 16).  */
Packit Service 4f62bc
  unsigned int rep_movsb_threshold;
Packit Service 4f62bc
  if (CPU_FEATURE_USABLE_P (cpu_features, AVX512F)
Packit Service 4f62bc
      && !CPU_FEATURE_PREFERRED_P (cpu_features, Prefer_No_AVX512))
Packit Service 4f62bc
    {
Packit Service 4f62bc
      rep_movsb_threshold = 2048 * (64 / 16);
Packit Service 4f62bc
      minimum_rep_movsb_threshold = 64 * 8;
Packit Service 4f62bc
    }
Packit Service 4f62bc
  else if (CPU_FEATURE_PREFERRED_P (cpu_features,
Packit Service 4f62bc
				    AVX_Fast_Unaligned_Load))
Packit Service 4f62bc
    {
Packit Service 4f62bc
      rep_movsb_threshold = 2048 * (32 / 16);
Packit Service 4f62bc
      minimum_rep_movsb_threshold = 32 * 8;
Packit Service 4f62bc
    }
Packit Service 4f62bc
  else
Packit Service 4f62bc
    {
Packit Service 4f62bc
      rep_movsb_threshold = 2048 * (16 / 16);
Packit Service 4f62bc
      minimum_rep_movsb_threshold = 16 * 8;
Packit Service 4f62bc
    }
Packit Service 4f62bc
  if (cpu_features->rep_movsb_threshold > minimum_rep_movsb_threshold)
Packit Service 4f62bc
    __x86_rep_movsb_threshold = cpu_features->rep_movsb_threshold;
Packit Service 4f62bc
  else
Packit Service 4f62bc
    __x86_rep_movsb_threshold = rep_movsb_threshold;
Packit Service 4f62bc
Packit Service 4f62bc
# if HAVE_TUNABLES
Packit Service 4f62bc
  __x86_rep_stosb_threshold = cpu_features->rep_stosb_threshold;
Packit Service 4f62bc
# endif
Packit Service 4f62bc
}