Skip to content

Commit dd44db6

Browse files
opsifflanlanxiyiji
authored andcommitted
deepin: arm64: cpufeature: disable LSE on some cpus
deepin inclusion category: performance Disable LSE (Large System Extensions) atomic instructions on some systems to improve performance of per-CPU atomic operations. LSE atomics can exhibit significant overhead on certain microarchitectures (e.g., TSV110) due to "far atomic" implementations bypassing L1 cache. LL/SC (Load-Link/Store-Conditional) is substantially faster. The default value is 0 (enabled), which automatically disables LSE on some systems. Set to 1 to skip the check enablement on our test systems regardless of performance impact. When this feature is active, the kernel logs: "LSE atomics: use llsc for performance, use lse_disable_check=1 to disable the feature." PS: Test with byte-unixbench6 in kp920 24c and 64GB memory, improve whole scores by 3.8%. Link: https://lore.kernel.org/r/e7d539ed-ced0-4b96-8ecd-048a5b803b85@paulmck-laptop [1] Signed-off-by: Wentao Guan <[email protected]>
1 parent 91502cb commit dd44db6

File tree

2 files changed

+43
-1
lines changed

2 files changed

+43
-1
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3065,6 +3065,21 @@
30653065
ltpc= [NET]
30663066
Format: <io>,<irq>,<dma>
30673067

3068+
lse_disable_check [ARM64]
3069+
Disable LSE (Large System Extensions) atomic instructions
3070+
on some systems to improve performance of per-CPU atomic
3071+
operations. LSE atomics can exhibit significant overhead
3072+
on certain microarchitectures (e.g., TSV110) due
3073+
to "far atomic" implementations bypassing L1 cache. LL/SC
3074+
(Load-Link/Store-Conditional) is substantially faster.
3075+
3076+
The default value is 0 (enabled), which automatically
3077+
disables LSE on some systems. Set to 1 to bypassing
3078+
the automatic disabling of LSE on affected systems.
3079+
3080+
When this feature is active, the kernel logs:
3081+
"LSE atomics: use llsc for performance, use lse_disable_check=1 to disable the feature."
3082+
30683083
lsm.debug [SECURITY] Enable LSM initialization debugging output.
30693084

30703085
lsm=lsm1,...,lsmN

arch/arm64/kernel/cpufeature.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,33 @@ static bool has_32bit_el0(const struct arm64_cpu_capabilities *entry, int scope)
15401540
return true;
15411541
}
15421542

1543+
static bool lse_disable_check __read_mostly;
1544+
1545+
static int __init arm64_lse_disable_check(char *str)
1546+
{
1547+
return kstrtobool(str, &lse_disable_check);
1548+
}
1549+
early_param("lse_disable_check", arm64_lse_disable_check);
1550+
1551+
static bool has_lse_capability_check(const struct arm64_cpu_capabilities *cap,
1552+
int scope)
1553+
{
1554+
/* List of CPUs that LSE are slow more than llsc */
1555+
static const struct midr_range lse_disable_list[] = {
1556+
MIDR_ALL_VERSIONS(MIDR_HISI_TSV110),
1557+
{ /* sentinel */ }
1558+
};
1559+
1560+
/* Disable LSE when lse_disable_check is enabled */
1561+
if (lse_disable_check == 0 && is_midr_in_range_list(read_cpuid_id(), lse_disable_list)) {
1562+
if (scope == SCOPE_SYSTEM)
1563+
pr_info("LSE atomics: use llsc for performance, use lse_disable_check=1 to disable the feature.\n");
1564+
return false;
1565+
}
1566+
1567+
return has_cpuid_feature(cap, scope);
1568+
}
1569+
15431570
static bool has_useable_gicv3_cpuif(const struct arm64_cpu_capabilities *entry, int scope)
15441571
{
15451572
bool has_sre;
@@ -2348,7 +2375,7 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
23482375
.desc = "LSE atomic instructions",
23492376
.capability = ARM64_HAS_LSE_ATOMICS,
23502377
.type = ARM64_CPUCAP_SYSTEM_FEATURE,
2351-
.matches = has_cpuid_feature,
2378+
.matches = has_lse_capability_check,
23522379
ARM64_CPUID_FIELDS(ID_AA64ISAR0_EL1, ATOMIC, IMP)
23532380
},
23542381
#endif /* CONFIG_ARM64_LSE_ATOMICS */

0 commit comments

Comments
 (0)