Skip to content

Commit 04d402a

Browse files
jlintonarmctmarinas
authored andcommitted
arm64: cpufeature: Change DBM to display enabled cores
Now that we have the ability to display the list of cores with a feature when its selectivly enabled, lets convert DBM to use that as well. Signed-off-by: Jeremy Linton <jeremy.linton@arm.com> Link: https://lore.kernel.org/r/20231017052322.1211099-3-jeremy.linton@arm.com Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
1 parent 23b727d commit 04d402a

File tree

1 file changed

+8
-25
lines changed

1 file changed

+8
-25
lines changed

arch/arm64/kernel/cpufeature.c

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,8 @@ static int __init parse_kpti(char *str)
18481848
early_param("kpti", parse_kpti);
18491849

18501850
#ifdef CONFIG_ARM64_HW_AFDBM
1851+
static struct cpumask dbm_cpus __read_mostly;
1852+
18511853
static inline void __cpu_enable_hw_dbm(void)
18521854
{
18531855
u64 tcr = read_sysreg(tcr_el1) | TCR_HD;
@@ -1883,35 +1885,22 @@ static bool cpu_can_use_dbm(const struct arm64_cpu_capabilities *cap)
18831885

18841886
static void cpu_enable_hw_dbm(struct arm64_cpu_capabilities const *cap)
18851887
{
1886-
if (cpu_can_use_dbm(cap))
1888+
if (cpu_can_use_dbm(cap)) {
18871889
__cpu_enable_hw_dbm();
1890+
cpumask_set_cpu(smp_processor_id(), &dbm_cpus);
1891+
}
18881892
}
18891893

18901894
static bool has_hw_dbm(const struct arm64_cpu_capabilities *cap,
18911895
int __unused)
18921896
{
1893-
static bool detected = false;
18941897
/*
18951898
* DBM is a non-conflicting feature. i.e, the kernel can safely
18961899
* run a mix of CPUs with and without the feature. So, we
18971900
* unconditionally enable the capability to allow any late CPU
18981901
* to use the feature. We only enable the control bits on the
1899-
* CPU, if it actually supports.
1900-
*
1901-
* We have to make sure we print the "feature" detection only
1902-
* when at least one CPU actually uses it. So check if this CPU
1903-
* can actually use it and print the message exactly once.
1904-
*
1905-
* This is safe as all CPUs (including secondary CPUs - due to the
1906-
* LOCAL_CPU scope - and the hotplugged CPUs - via verification)
1907-
* goes through the "matches" check exactly once. Also if a CPU
1908-
* matches the criteria, it is guaranteed that the CPU will turn
1909-
* the DBM on, as the capability is unconditionally enabled.
1902+
* CPU, if it is supported.
19101903
*/
1911-
if (!detected && cpu_can_use_dbm(cap)) {
1912-
detected = true;
1913-
pr_info("detected: Hardware dirty bit management\n");
1914-
}
19151904

19161905
return true;
19171906
}
@@ -2448,18 +2437,12 @@ static const struct arm64_cpu_capabilities arm64_features[] = {
24482437
},
24492438
#ifdef CONFIG_ARM64_HW_AFDBM
24502439
{
2451-
/*
2452-
* Since we turn this on always, we don't want the user to
2453-
* think that the feature is available when it may not be.
2454-
* So hide the description.
2455-
*
2456-
* .desc = "Hardware pagetable Dirty Bit Management",
2457-
*
2458-
*/
2440+
.desc = "Hardware dirty bit management",
24592441
.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
24602442
.capability = ARM64_HW_DBM,
24612443
.matches = has_hw_dbm,
24622444
.cpu_enable = cpu_enable_hw_dbm,
2445+
.cpus = &dbm_cpus,
24632446
ARM64_CPUID_FIELDS(ID_AA64MMFR1_EL1, HAFDBS, DBM)
24642447
},
24652448
#endif

0 commit comments

Comments
 (0)