forked from rpms/glibc
Updates for AMD cache size computation (RHEL-3010)
Resolves: RHEL-3010
This commit is contained in:
parent
95743a650a
commit
c3ca668da6
247
glibc-RHEL-3010-1.patch
Normal file
247
glibc-RHEL-3010-1.patch
Normal file
@ -0,0 +1,247 @@
|
|||||||
|
commit 103a469dc7755fd9e8ccf362f3dd4c55dc761908
|
||||||
|
Author: Sajan Karumanchi <sajan.karumanchi@amd.com>
|
||||||
|
Date: Wed Jan 18 18:29:04 2023 +0100
|
||||||
|
|
||||||
|
x86: Cache computation for AMD architecture.
|
||||||
|
|
||||||
|
All AMD architectures cache details will be computed based on
|
||||||
|
__cpuid__ `0x8000_001D` and the reference to __cpuid__ `0x8000_0006` will be
|
||||||
|
zeroed out for future architectures.
|
||||||
|
|
||||||
|
Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
sysdeps/x86/dl-cacheinfo.h
|
||||||
|
(missing backport of commit 2d651eb9265d1366d7b9e881bfddd4
|
||||||
|
("x86: Move x86 processor cache info to cpu_features"))
|
||||||
|
|
||||||
|
diff --git a/sysdeps/x86/cacheinfo.h b/sysdeps/x86/cacheinfo.h
|
||||||
|
index 572f753474ee0610..b6f111e6668cc212 100644
|
||||||
|
--- a/sysdeps/x86/cacheinfo.h
|
||||||
|
+++ b/sysdeps/x86/cacheinfo.h
|
||||||
|
@@ -266,10 +266,6 @@ static void
|
||||||
|
init_cacheinfo (void)
|
||||||
|
{
|
||||||
|
/* Find out what brand of processor. */
|
||||||
|
- unsigned int ebx;
|
||||||
|
- unsigned int ecx;
|
||||||
|
- unsigned int edx;
|
||||||
|
- int max_cpuid_ex;
|
||||||
|
long int data = -1;
|
||||||
|
long int shared = -1;
|
||||||
|
long int shared_per_thread = -1;
|
||||||
|
@@ -303,62 +299,14 @@ init_cacheinfo (void)
|
||||||
|
}
|
||||||
|
else if (cpu_features->basic.kind == arch_kind_amd)
|
||||||
|
{
|
||||||
|
- data = handle_amd (_SC_LEVEL1_DCACHE_SIZE);
|
||||||
|
- long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE);
|
||||||
|
- shared = handle_amd (_SC_LEVEL3_CACHE_SIZE);
|
||||||
|
+ data = handle_amd (_SC_LEVEL1_DCACHE_SIZE, cpu_features);
|
||||||
|
+ long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE, cpu_features);
|
||||||
|
+ shared = handle_amd (_SC_LEVEL3_CACHE_SIZE, cpu_features);
|
||||||
|
shared_per_thread = shared;
|
||||||
|
|
||||||
|
- /* Get maximum extended function. */
|
||||||
|
- __cpuid (0x80000000, max_cpuid_ex, ebx, ecx, edx);
|
||||||
|
-
|
||||||
|
if (shared <= 0)
|
||||||
|
/* No shared L3 cache. All we have is the L2 cache. */
|
||||||
|
shared = core;
|
||||||
|
- else
|
||||||
|
- {
|
||||||
|
- /* Figure out the number of logical threads that share L3. */
|
||||||
|
- if (max_cpuid_ex >= 0x80000008)
|
||||||
|
- {
|
||||||
|
- /* Get width of APIC ID. */
|
||||||
|
- __cpuid (0x80000008, max_cpuid_ex, ebx, ecx, edx);
|
||||||
|
- threads = 1 << ((ecx >> 12) & 0x0f);
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (threads == 0 || cpu_features->basic.family >= 0x17)
|
||||||
|
- {
|
||||||
|
- /* If APIC ID width is not available, use logical
|
||||||
|
- processor count. */
|
||||||
|
- __cpuid (0x00000001, max_cpuid_ex, ebx, ecx, edx);
|
||||||
|
-
|
||||||
|
- if ((edx & (1 << 28)) != 0)
|
||||||
|
- threads = (ebx >> 16) & 0xff;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- /* Cap usage of highest cache level to the number of
|
||||||
|
- supported threads. */
|
||||||
|
- if (threads > 0)
|
||||||
|
- shared /= threads;
|
||||||
|
-
|
||||||
|
- /* Get shared cache per ccx for Zen architectures. */
|
||||||
|
- if (cpu_features->basic.family >= 0x17)
|
||||||
|
- {
|
||||||
|
- unsigned int eax;
|
||||||
|
-
|
||||||
|
- /* Get number of threads share the L3 cache in CCX. */
|
||||||
|
- __cpuid_count (0x8000001D, 0x3, eax, ebx, ecx, edx);
|
||||||
|
-
|
||||||
|
- unsigned int threads_per_ccx = ((eax >> 14) & 0xfff) + 1;
|
||||||
|
- shared *= threads_per_ccx;
|
||||||
|
- }
|
||||||
|
- else
|
||||||
|
- {
|
||||||
|
- /* Account for exclusive L2 and L3 caches. */
|
||||||
|
- shared += core;
|
||||||
|
- }
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if (shared_per_thread <= 0)
|
||||||
|
- shared_per_thread = shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cpu_features->data_cache_size != 0)
|
||||||
|
diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
index b2b90074b0e98a60..294a7d8bfc564aef 100644
|
||||||
|
--- a/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
+++ b/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
@@ -311,117 +311,47 @@ handle_intel (int name, const struct cpu_features *cpu_features)
|
||||||
|
|
||||||
|
|
||||||
|
static long int __attribute__ ((noinline))
|
||||||
|
-handle_amd (int name)
|
||||||
|
+handle_amd (int name, const struct cpu_features *cpu_features)
|
||||||
|
{
|
||||||
|
unsigned int eax;
|
||||||
|
unsigned int ebx;
|
||||||
|
unsigned int ecx;
|
||||||
|
unsigned int edx;
|
||||||
|
- __cpuid (0x80000000, eax, ebx, ecx, edx);
|
||||||
|
+ unsigned int count = 0x1;
|
||||||
|
|
||||||
|
/* No level 4 cache (yet). */
|
||||||
|
if (name > _SC_LEVEL3_CACHE_LINESIZE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- unsigned int fn = 0x80000005 + (name >= _SC_LEVEL2_CACHE_SIZE);
|
||||||
|
- if (eax < fn)
|
||||||
|
- return 0;
|
||||||
|
+ if (name >= _SC_LEVEL3_CACHE_SIZE)
|
||||||
|
+ count = 0x3;
|
||||||
|
+ else if (name >= _SC_LEVEL2_CACHE_SIZE)
|
||||||
|
+ count = 0x2;
|
||||||
|
+ else if (name >= _SC_LEVEL1_DCACHE_SIZE)
|
||||||
|
+ count = 0x0;
|
||||||
|
|
||||||
|
- __cpuid (fn, eax, ebx, ecx, edx);
|
||||||
|
-
|
||||||
|
- if (name < _SC_LEVEL1_DCACHE_SIZE)
|
||||||
|
- {
|
||||||
|
- name += _SC_LEVEL1_DCACHE_SIZE - _SC_LEVEL1_ICACHE_SIZE;
|
||||||
|
- ecx = edx;
|
||||||
|
- }
|
||||||
|
+ __cpuid_count (0x8000001D, count, eax, ebx, ecx, edx);
|
||||||
|
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
- case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
- return (ecx >> 14) & 0x3fc00;
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
- ecx >>= 16;
|
||||||
|
- if ((ecx & 0xff) == 0xff)
|
||||||
|
- /* Fully associative. */
|
||||||
|
- return (ecx << 2) & 0x3fc00;
|
||||||
|
- return ecx & 0xff;
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
- return ecx & 0xff;
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
- return (ecx & 0xf000) == 0 ? 0 : (ecx >> 6) & 0x3fffc00;
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
- switch ((ecx >> 12) & 0xf)
|
||||||
|
- {
|
||||||
|
- case 0:
|
||||||
|
- case 1:
|
||||||
|
- case 2:
|
||||||
|
- case 4:
|
||||||
|
- return (ecx >> 12) & 0xf;
|
||||||
|
- case 6:
|
||||||
|
- return 8;
|
||||||
|
- case 8:
|
||||||
|
- return 16;
|
||||||
|
- case 10:
|
||||||
|
- return 32;
|
||||||
|
- case 11:
|
||||||
|
- return 48;
|
||||||
|
- case 12:
|
||||||
|
- return 64;
|
||||||
|
- case 13:
|
||||||
|
- return 96;
|
||||||
|
- case 14:
|
||||||
|
- return 128;
|
||||||
|
- case 15:
|
||||||
|
- return ((ecx >> 6) & 0x3fffc00) / (ecx & 0xff);
|
||||||
|
- default:
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- /* NOTREACHED */
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
- return (ecx & 0xf000) == 0 ? 0 : ecx & 0xff;
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
- return (edx & 0xf000) == 0 ? 0 : (edx & 0x3ffc0000) << 1;
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL3_CACHE_ASSOC:
|
||||||
|
- switch ((edx >> 12) & 0xf)
|
||||||
|
- {
|
||||||
|
- case 0:
|
||||||
|
- case 1:
|
||||||
|
- case 2:
|
||||||
|
- case 4:
|
||||||
|
- return (edx >> 12) & 0xf;
|
||||||
|
- case 6:
|
||||||
|
- return 8;
|
||||||
|
- case 8:
|
||||||
|
- return 16;
|
||||||
|
- case 10:
|
||||||
|
- return 32;
|
||||||
|
- case 11:
|
||||||
|
- return 48;
|
||||||
|
- case 12:
|
||||||
|
- return 64;
|
||||||
|
- case 13:
|
||||||
|
- return 96;
|
||||||
|
- case 14:
|
||||||
|
- return 128;
|
||||||
|
- case 15:
|
||||||
|
- return ((edx & 0x3ffc0000) << 1) / (edx & 0xff);
|
||||||
|
- default:
|
||||||
|
- return 0;
|
||||||
|
- }
|
||||||
|
- /* NOTREACHED */
|
||||||
|
-
|
||||||
|
- case _SC_LEVEL3_CACHE_LINESIZE:
|
||||||
|
- return (edx & 0xf000) == 0 ? 0 : edx & 0xff;
|
||||||
|
-
|
||||||
|
- default:
|
||||||
|
- assert (! "cannot happen");
|
||||||
|
+ case _SC_LEVEL1_ICACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL3_CACHE_ASSOC:
|
||||||
|
+ return ecx?((ebx >> 22) & 0x3ff) + 1 : 0;
|
||||||
|
+ case _SC_LEVEL1_ICACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL3_CACHE_LINESIZE:
|
||||||
|
+ return ecx?(ebx & 0xfff) + 1 : 0;
|
||||||
|
+ case _SC_LEVEL1_ICACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
+ return ecx?(((ebx >> 22) & 0x3ff) + 1)*((ebx & 0xfff) + 1)\
|
||||||
|
+ *(ecx + 1):0;
|
||||||
|
+ default:
|
||||||
|
+ assert (! "cannot happen");
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
85
glibc-RHEL-3010-2.patch
Normal file
85
glibc-RHEL-3010-2.patch
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
commit 856bab7717ef6d1033fd7cbf7cfb2ddefbfffb07
|
||||||
|
Author: Andreas Schwab <schwab@suse.de>
|
||||||
|
Date: Thu Feb 9 14:56:21 2023 +0100
|
||||||
|
|
||||||
|
x86/dl-cacheinfo: remove unsused parameter from handle_amd
|
||||||
|
|
||||||
|
Also replace an unreachable assert with __builtin_unreachable.
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
sysdeps/x86/dl-cacheinfo.h
|
||||||
|
(missing backport of commit 2d651eb9265d1366d7b9e881bfddd4
|
||||||
|
("x86: Move x86 processor cache info to cpu_features"))
|
||||||
|
|
||||||
|
diff --git a/sysdeps/x86/cacheinfo.h b/sysdeps/x86/cacheinfo.h
|
||||||
|
index b6f111e6668cc212..85e5731281c62503 100644
|
||||||
|
--- a/sysdeps/x86/cacheinfo.h
|
||||||
|
+++ b/sysdeps/x86/cacheinfo.h
|
||||||
|
@@ -299,9 +299,9 @@ init_cacheinfo (void)
|
||||||
|
}
|
||||||
|
else if (cpu_features->basic.kind == arch_kind_amd)
|
||||||
|
{
|
||||||
|
- data = handle_amd (_SC_LEVEL1_DCACHE_SIZE, cpu_features);
|
||||||
|
- long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE, cpu_features);
|
||||||
|
- shared = handle_amd (_SC_LEVEL3_CACHE_SIZE, cpu_features);
|
||||||
|
+ data = handle_amd (_SC_LEVEL1_DCACHE_SIZE);
|
||||||
|
+ long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE);
|
||||||
|
+ shared = handle_amd (_SC_LEVEL3_CACHE_SIZE);
|
||||||
|
shared_per_thread = shared;
|
||||||
|
|
||||||
|
if (shared <= 0)
|
||||||
|
diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
index 294a7d8bfc564aef..74cd5072a9d10756 100644
|
||||||
|
--- a/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
+++ b/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
@@ -311,7 +311,7 @@ handle_intel (int name, const struct cpu_features *cpu_features)
|
||||||
|
|
||||||
|
|
||||||
|
static long int __attribute__ ((noinline))
|
||||||
|
-handle_amd (int name, const struct cpu_features *cpu_features)
|
||||||
|
+handle_amd (int name)
|
||||||
|
{
|
||||||
|
unsigned int eax;
|
||||||
|
unsigned int ebx;
|
||||||
|
@@ -334,24 +334,23 @@ handle_amd (int name, const struct cpu_features *cpu_features)
|
||||||
|
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
- case _SC_LEVEL1_ICACHE_ASSOC:
|
||||||
|
- case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
- case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
- case _SC_LEVEL3_CACHE_ASSOC:
|
||||||
|
- return ecx?((ebx >> 22) & 0x3ff) + 1 : 0;
|
||||||
|
- case _SC_LEVEL1_ICACHE_LINESIZE:
|
||||||
|
- case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
- case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
- case _SC_LEVEL3_CACHE_LINESIZE:
|
||||||
|
- return ecx?(ebx & 0xfff) + 1 : 0;
|
||||||
|
- case _SC_LEVEL1_ICACHE_SIZE:
|
||||||
|
- case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
- case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
- case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
- return ecx?(((ebx >> 22) & 0x3ff) + 1)*((ebx & 0xfff) + 1)\
|
||||||
|
- *(ecx + 1):0;
|
||||||
|
- default:
|
||||||
|
- assert (! "cannot happen");
|
||||||
|
+ case _SC_LEVEL1_ICACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL3_CACHE_ASSOC:
|
||||||
|
+ return ecx ? ((ebx >> 22) & 0x3ff) + 1 : 0;
|
||||||
|
+ case _SC_LEVEL1_ICACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL3_CACHE_LINESIZE:
|
||||||
|
+ return ecx ? (ebx & 0xfff) + 1 : 0;
|
||||||
|
+ case _SC_LEVEL1_ICACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
+ return ecx ? (((ebx >> 22) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1): 0;
|
||||||
|
+ default:
|
||||||
|
+ __builtin_unreachable ();
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
280
glibc-RHEL-3010-3.patch
Normal file
280
glibc-RHEL-3010-3.patch
Normal file
@ -0,0 +1,280 @@
|
|||||||
|
commit dcad5c8578130dec7f35fd5b0885304b59f9f543
|
||||||
|
Author: Sajan Karumanchi <sajan.karumanchi@amd.com>
|
||||||
|
Date: Tue Aug 1 15:20:55 2023 +0000
|
||||||
|
|
||||||
|
x86: Fix for cache computation on AMD legacy cpus.
|
||||||
|
|
||||||
|
Some legacy AMD CPUs and hypervisors have the _cpuid_ '0x8000_001D'
|
||||||
|
set to Zero, thus resulting in zeroed-out computed cache values.
|
||||||
|
This patch reintroduces the old way of cache computation as a
|
||||||
|
fail-safe option to handle these exceptions.
|
||||||
|
Fixed 'level4_cache_size' value through handle_amd().
|
||||||
|
|
||||||
|
Reviewed-by: Premachandra Mallappa <premachandra.mallappa@amd.com>
|
||||||
|
Tested-by: Florian Weimer <fweimer@redhat.com>
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
sysdeps/x86/dl-cacheinfo.h
|
||||||
|
(missing backport of commit 2d651eb9265d1366d7b9e881bfddd4
|
||||||
|
("x86: Move x86 processor cache info to cpu_features"))
|
||||||
|
|
||||||
|
diff --git a/sysdeps/x86/cacheinfo.h b/sysdeps/x86/cacheinfo.h
|
||||||
|
index 85e5731281c62503..10ebadd819d9efff 100644
|
||||||
|
--- a/sysdeps/x86/cacheinfo.h
|
||||||
|
+++ b/sysdeps/x86/cacheinfo.h
|
||||||
|
@@ -302,11 +302,19 @@ init_cacheinfo (void)
|
||||||
|
data = handle_amd (_SC_LEVEL1_DCACHE_SIZE);
|
||||||
|
long int core = handle_amd (_SC_LEVEL2_CACHE_SIZE);
|
||||||
|
shared = handle_amd (_SC_LEVEL3_CACHE_SIZE);
|
||||||
|
- shared_per_thread = shared;
|
||||||
|
|
||||||
|
if (shared <= 0)
|
||||||
|
- /* No shared L3 cache. All we have is the L2 cache. */
|
||||||
|
- shared = core;
|
||||||
|
+ {
|
||||||
|
+ /* No shared L3 cache. All we have is the L2 cache. */
|
||||||
|
+ shared = core;
|
||||||
|
+ }
|
||||||
|
+ else if (cpu_features->basic.family < 0x17)
|
||||||
|
+ {
|
||||||
|
+ /* Account for exclusive L2 and L3 caches. */
|
||||||
|
+ shared += core;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ shared_per_thread = shared;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cpu_features->data_cache_size != 0)
|
||||||
|
diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
index 74cd5072a9d10756..75a6b1dfde199dd7 100644
|
||||||
|
--- a/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
+++ b/sysdeps/x86/dl-cacheinfo.h
|
||||||
|
@@ -315,40 +315,206 @@ handle_amd (int name)
|
||||||
|
{
|
||||||
|
unsigned int eax;
|
||||||
|
unsigned int ebx;
|
||||||
|
- unsigned int ecx;
|
||||||
|
+ unsigned int ecx = 0;
|
||||||
|
unsigned int edx;
|
||||||
|
- unsigned int count = 0x1;
|
||||||
|
+ unsigned int max_cpuid = 0;
|
||||||
|
+ unsigned int fn = 0;
|
||||||
|
|
||||||
|
/* No level 4 cache (yet). */
|
||||||
|
if (name > _SC_LEVEL3_CACHE_LINESIZE)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- if (name >= _SC_LEVEL3_CACHE_SIZE)
|
||||||
|
- count = 0x3;
|
||||||
|
- else if (name >= _SC_LEVEL2_CACHE_SIZE)
|
||||||
|
- count = 0x2;
|
||||||
|
- else if (name >= _SC_LEVEL1_DCACHE_SIZE)
|
||||||
|
- count = 0x0;
|
||||||
|
+ __cpuid (0x80000000, max_cpuid, ebx, ecx, edx);
|
||||||
|
+
|
||||||
|
+ if (max_cpuid >= 0x8000001D)
|
||||||
|
+ /* Use __cpuid__ '0x8000_001D' to compute cache details. */
|
||||||
|
+ {
|
||||||
|
+ unsigned int count = 0x1;
|
||||||
|
+
|
||||||
|
+ if (name >= _SC_LEVEL3_CACHE_SIZE)
|
||||||
|
+ count = 0x3;
|
||||||
|
+ else if (name >= _SC_LEVEL2_CACHE_SIZE)
|
||||||
|
+ count = 0x2;
|
||||||
|
+ else if (name >= _SC_LEVEL1_DCACHE_SIZE)
|
||||||
|
+ count = 0x0;
|
||||||
|
+
|
||||||
|
+ __cpuid_count (0x8000001D, count, eax, ebx, ecx, edx);
|
||||||
|
+
|
||||||
|
+ if (ecx != 0)
|
||||||
|
+ {
|
||||||
|
+ switch (name)
|
||||||
|
+ {
|
||||||
|
+ case _SC_LEVEL1_ICACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL3_CACHE_ASSOC:
|
||||||
|
+ return ((ebx >> 22) & 0x3ff) + 1;
|
||||||
|
+ case _SC_LEVEL1_ICACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
+ case _SC_LEVEL3_CACHE_LINESIZE:
|
||||||
|
+ return (ebx & 0xfff) + 1;
|
||||||
|
+ case _SC_LEVEL1_ICACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
+ case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
+ return (((ebx >> 22) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1);
|
||||||
|
+ default:
|
||||||
|
+ __builtin_unreachable ();
|
||||||
|
+ }
|
||||||
|
+ return -1;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
- __cpuid_count (0x8000001D, count, eax, ebx, ecx, edx);
|
||||||
|
+ /* Legacy cache computation for CPUs prior to Bulldozer family.
|
||||||
|
+ This is also a fail-safe mechanism for some hypervisors that
|
||||||
|
+ accidentally configure __cpuid__ '0x8000_001D' to Zero. */
|
||||||
|
+
|
||||||
|
+ fn = 0x80000005 + (name >= _SC_LEVEL2_CACHE_SIZE);
|
||||||
|
+
|
||||||
|
+ if (max_cpuid < fn)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ __cpuid (fn, eax, ebx, ecx, edx);
|
||||||
|
+
|
||||||
|
+ if (name < _SC_LEVEL1_DCACHE_SIZE)
|
||||||
|
+ {
|
||||||
|
+ name += _SC_LEVEL1_DCACHE_SIZE - _SC_LEVEL1_ICACHE_SIZE;
|
||||||
|
+ ecx = edx;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
- case _SC_LEVEL1_ICACHE_ASSOC:
|
||||||
|
- case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
- case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
+ case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
+ return (ecx >> 14) & 0x3fc00;
|
||||||
|
+
|
||||||
|
+ case _SC_LEVEL1_DCACHE_ASSOC:
|
||||||
|
+ ecx >>= 16;
|
||||||
|
+ if ((ecx & 0xff) == 0xff)
|
||||||
|
+ {
|
||||||
|
+ /* Fully associative. */
|
||||||
|
+ return (ecx << 2) & 0x3fc00;
|
||||||
|
+ }
|
||||||
|
+ return ecx & 0xff;
|
||||||
|
+
|
||||||
|
+ case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
+ return ecx & 0xff;
|
||||||
|
+
|
||||||
|
+ case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
+ return (ecx & 0xf000) == 0 ? 0 : (ecx >> 6) & 0x3fffc00;
|
||||||
|
+
|
||||||
|
+ case _SC_LEVEL2_CACHE_ASSOC:
|
||||||
|
+ switch ((ecx >> 12) & 0xf)
|
||||||
|
+ {
|
||||||
|
+ case 0:
|
||||||
|
+ case 1:
|
||||||
|
+ case 2:
|
||||||
|
+ case 4:
|
||||||
|
+ return (ecx >> 12) & 0xf;
|
||||||
|
+ case 6:
|
||||||
|
+ return 8;
|
||||||
|
+ case 8:
|
||||||
|
+ return 16;
|
||||||
|
+ case 10:
|
||||||
|
+ return 32;
|
||||||
|
+ case 11:
|
||||||
|
+ return 48;
|
||||||
|
+ case 12:
|
||||||
|
+ return 64;
|
||||||
|
+ case 13:
|
||||||
|
+ return 96;
|
||||||
|
+ case 14:
|
||||||
|
+ return 128;
|
||||||
|
+ case 15:
|
||||||
|
+ return ((ecx >> 6) & 0x3fffc00) / (ecx & 0xff);
|
||||||
|
+ default:
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
+ return (ecx & 0xf000) == 0 ? 0 : ecx & 0xff;
|
||||||
|
+
|
||||||
|
+ case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
+ {
|
||||||
|
+ long int total_l3_cache = 0, l3_cache_per_thread = 0;
|
||||||
|
+ unsigned int threads = 0;
|
||||||
|
+ const struct cpu_features *cpu_features;
|
||||||
|
+
|
||||||
|
+ if ((edx & 0xf000) == 0)
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ total_l3_cache = (edx & 0x3ffc0000) << 1;
|
||||||
|
+ cpu_features = __get_cpu_features ();
|
||||||
|
+
|
||||||
|
+ /* Figure out the number of logical threads that share L3. */
|
||||||
|
+ if (max_cpuid >= 0x80000008)
|
||||||
|
+ {
|
||||||
|
+ /* Get width of APIC ID. */
|
||||||
|
+ __cpuid (0x80000008, eax, ebx, ecx, edx);
|
||||||
|
+ threads = (ecx & 0xff) + 1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ if (threads == 0)
|
||||||
|
+ {
|
||||||
|
+ /* If APIC ID width is not available, use logical
|
||||||
|
+ processor count. */
|
||||||
|
+ __cpuid (0x00000001, eax, ebx, ecx, edx);
|
||||||
|
+ if ((edx & (1 << 28)) != 0)
|
||||||
|
+ threads = (ebx >> 16) & 0xff;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ /* Cap usage of highest cache level to the number of
|
||||||
|
+ supported threads. */
|
||||||
|
+ if (threads > 0)
|
||||||
|
+ l3_cache_per_thread = total_l3_cache/threads;
|
||||||
|
+
|
||||||
|
+ /* Get shared cache per ccx for Zen architectures. */
|
||||||
|
+ if (cpu_features->basic.family >= 0x17)
|
||||||
|
+ {
|
||||||
|
+ long int l3_cache_per_ccx = 0;
|
||||||
|
+ /* Get number of threads share the L3 cache in CCX. */
|
||||||
|
+ __cpuid_count (0x8000001D, 0x3, eax, ebx, ecx, edx);
|
||||||
|
+ unsigned int threads_per_ccx = ((eax >> 14) & 0xfff) + 1;
|
||||||
|
+ l3_cache_per_ccx = l3_cache_per_thread * threads_per_ccx;
|
||||||
|
+ return l3_cache_per_ccx;
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ return l3_cache_per_thread;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
case _SC_LEVEL3_CACHE_ASSOC:
|
||||||
|
- return ecx ? ((ebx >> 22) & 0x3ff) + 1 : 0;
|
||||||
|
- case _SC_LEVEL1_ICACHE_LINESIZE:
|
||||||
|
- case _SC_LEVEL1_DCACHE_LINESIZE:
|
||||||
|
- case _SC_LEVEL2_CACHE_LINESIZE:
|
||||||
|
+ switch ((edx >> 12) & 0xf)
|
||||||
|
+ {
|
||||||
|
+ case 0:
|
||||||
|
+ case 1:
|
||||||
|
+ case 2:
|
||||||
|
+ case 4:
|
||||||
|
+ return (edx >> 12) & 0xf;
|
||||||
|
+ case 6:
|
||||||
|
+ return 8;
|
||||||
|
+ case 8:
|
||||||
|
+ return 16;
|
||||||
|
+ case 10:
|
||||||
|
+ return 32;
|
||||||
|
+ case 11:
|
||||||
|
+ return 48;
|
||||||
|
+ case 12:
|
||||||
|
+ return 64;
|
||||||
|
+ case 13:
|
||||||
|
+ return 96;
|
||||||
|
+ case 14:
|
||||||
|
+ return 128;
|
||||||
|
+ case 15:
|
||||||
|
+ return ((edx & 0x3ffc0000) << 1) / (edx & 0xff);
|
||||||
|
+ default:
|
||||||
|
+ return 0;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
case _SC_LEVEL3_CACHE_LINESIZE:
|
||||||
|
- return ecx ? (ebx & 0xfff) + 1 : 0;
|
||||||
|
- case _SC_LEVEL1_ICACHE_SIZE:
|
||||||
|
- case _SC_LEVEL1_DCACHE_SIZE:
|
||||||
|
- case _SC_LEVEL2_CACHE_SIZE:
|
||||||
|
- case _SC_LEVEL3_CACHE_SIZE:
|
||||||
|
- return ecx ? (((ebx >> 22) & 0x3ff) + 1) * ((ebx & 0xfff) + 1) * (ecx + 1): 0;
|
||||||
|
+ return (edx & 0xf000) == 0 ? 0 : edx & 0xff;
|
||||||
|
+
|
||||||
|
default:
|
||||||
|
__builtin_unreachable ();
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
%define glibcsrcdir glibc-2.28
|
%define glibcsrcdir glibc-2.28
|
||||||
%define glibcversion 2.28
|
%define glibcversion 2.28
|
||||||
%define glibcrelease 248%{?dist}
|
%define glibcrelease 249%{?dist}
|
||||||
# Pre-release tarballs are pulled in from git using a command that is
|
# Pre-release tarballs are pulled in from git using a command that is
|
||||||
# effectively:
|
# effectively:
|
||||||
#
|
#
|
||||||
@ -1178,6 +1178,9 @@ Patch990: glibc-RHEL-15696-110.patch
|
|||||||
Patch991: glibc-RHEL-17468-1.patch
|
Patch991: glibc-RHEL-17468-1.patch
|
||||||
Patch992: glibc-RHEL-17468-2.patch
|
Patch992: glibc-RHEL-17468-2.patch
|
||||||
Patch993: glibc-RHEL-19824.patch
|
Patch993: glibc-RHEL-19824.patch
|
||||||
|
Patch994: glibc-RHEL-3010-1.patch
|
||||||
|
Patch995: glibc-RHEL-3010-2.patch
|
||||||
|
Patch996: glibc-RHEL-3010-3.patch
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
# Continued list of core "glibc" package information:
|
# Continued list of core "glibc" package information:
|
||||||
@ -3009,6 +3012,9 @@ fi
|
|||||||
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
|
%files -f compat-libpthread-nonshared.filelist -n compat-libpthread-nonshared
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jan 3 2024 Florian Weimer <fweimer@redhat.com> - 2.28-249
|
||||||
|
- Updates for AMD cache size computation (RHEL-3010)
|
||||||
|
|
||||||
* Tue Jan 2 2024 Florian Weimer <fweimer@redhat.com> - 2.28-248
|
* Tue Jan 2 2024 Florian Weimer <fweimer@redhat.com> - 2.28-248
|
||||||
- Re-enable output buffering for wide stdio streams (RHEL-19824)
|
- Re-enable output buffering for wide stdio streams (RHEL-19824)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user