|
|
b18e99 |
From 8b9a0af8ca012217bf90d1dc0694f85b49ae09da Mon Sep 17 00:00:00 2001
|
|
|
b18e99 |
From: Noah Goldstein <goldstein.w.n@gmail.com>
|
|
|
b18e99 |
Date: Tue, 18 Jul 2023 10:27:59 -0500
|
|
|
b18e99 |
Subject: [PATCH] [PATCH v1] x86: Use `3/4*sizeof(per-thread-L3)` as low bound
|
|
|
b18e99 |
for NT threshold.
|
|
|
b18e99 |
Content-type: text/plain; charset=UTF-8
|
|
|
b18e99 |
|
|
|
b18e99 |
On some machines we end up with incomplete cache information. This can
|
|
|
b18e99 |
make the new calculation of `sizeof(total-L3)/custom-divisor` end up
|
|
|
b18e99 |
lower than intended (and lower than the prior value). So reintroduce
|
|
|
b18e99 |
the old bound as a lower bound to avoid potentially regressing code
|
|
|
b18e99 |
where we don't have complete information to make the decision.
|
|
|
b18e99 |
Reviewed-by: DJ Delorie <dj@redhat.com>
|
|
|
b18e99 |
---
|
|
|
b18e99 |
sysdeps/x86/dl-cacheinfo.h | 15 ++++++++++++---
|
|
|
b18e99 |
1 file changed, 12 insertions(+), 3 deletions(-)
|
|
|
b18e99 |
|
|
|
b18e99 |
[DJ - ported to C8S]
|
|
|
b18e99 |
|
|
|
b18e99 |
diff -rup b2/sysdeps/x86/cacheinfo.h b3/sysdeps/x86/cacheinfo.h
|
|
|
b18e99 |
--- b2/sysdeps/x86/cacheinfo.h 2023-08-08 13:55:16.474680016 -0400
|
|
|
b18e99 |
+++ b3/sysdeps/x86/cacheinfo.h 2023-08-08 13:59:14.507988958 -0400
|
|
|
b18e99 |
@@ -401,12 +401,20 @@ init_cacheinfo (void)
|
|
|
b18e99 |
provides proper LRU hints so that the maximum thrashing
|
|
|
b18e99 |
capped at 1/associativity. */
|
|
|
b18e99 |
unsigned long int non_temporal_threshold = shared / 4;
|
|
|
b18e99 |
+ /* If the computed non_temporal_threshold <= 3/4 * per-thread L3, we most
|
|
|
b18e99 |
+ likely have incorrect/incomplete cache info in which case, default to
|
|
|
b18e99 |
+ 3/4 * per-thread L3 to avoid regressions. */
|
|
|
b18e99 |
+ unsigned long int non_temporal_threshold_lowbound
|
|
|
b18e99 |
+ = shared_per_thread * 3 / 4;
|
|
|
b18e99 |
+ if (non_temporal_threshold < non_temporal_threshold_lowbound)
|
|
|
b18e99 |
+ non_temporal_threshold = non_temporal_threshold_lowbound;
|
|
|
b18e99 |
+
|
|
|
b18e99 |
/* If no ERMS, we use the per-thread L3 chunking. Normal cacheable stores run
|
|
|
b18e99 |
a higher risk of actually thrashing the cache as they don't have a HW LRU
|
|
|
b18e99 |
hint. As well, their performance in highly parallel situations is
|
|
|
b18e99 |
noticeably worse. */
|
|
|
b18e99 |
if (!CPU_FEATURE_USABLE_P (cpu_features, ERMS))
|
|
|
b18e99 |
- non_temporal_threshold = shared_per_thread * 3 / 4;
|
|
|
b18e99 |
+ non_temporal_threshold = non_temporal_threshold_lowbound;
|
|
|
b18e99 |
|
|
|
b18e99 |
__x86_shared_non_temporal_threshold
|
|
|
b18e99 |
= (cpu_features->non_temporal_threshold != 0
|