From 1bf6c5526533bb7b3d86ebc293eaa6b8bd0034d8 Mon Sep 17 00:00:00 2001 From: kettenis Date: Fri, 1 Mar 2024 15:57:43 +0000 Subject: [PATCH] Reduce dmesg spam by only printing the CPU feature flags when they differ from the previous one. Since CPU cores are typically grouped in clusters of identical cores and are typically enumerated this results in flags being printed for the first core of a cluster. But only if the clusters use cores that implement different features which is rare. ok deraadt@ --- sys/arch/arm64/arm64/cpu.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/sys/arch/arm64/arm64/cpu.c b/sys/arch/arm64/arm64/cpu.c index bf5b41a635b..34444bda98c 100644 --- a/sys/arch/arm64/arm64/cpu.c +++ b/sys/arch/arm64/arm64/cpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.c,v 1.106 2024/02/28 00:53:16 jsg Exp $ */ +/* $OpenBSD: cpu.c,v 1.107 2024/03/01 15:57:43 kettenis Exp $ */ /* * Copyright (c) 2016 Dale Rahn @@ -266,6 +266,13 @@ void cpu_opp_kstat_attach(struct cpu_info *ci); void cpu_identify(struct cpu_info *ci) { + static uint64_t prev_id_aa64isar0; + static uint64_t prev_id_aa64isar1; + static uint64_t prev_id_aa64isar2; + static uint64_t prev_id_aa64mmfr0; + static uint64_t prev_id_aa64mmfr1; + static uint64_t prev_id_aa64pfr0; + static uint64_t prev_id_aa64pfr1; uint64_t midr, impl, part; uint64_t clidr, id; uint32_t ctr, ccsidr, sets, ways, line; @@ -482,6 +489,19 @@ cpu_identify(struct cpu_info *ci) if (impl == CPU_IMPL_APPLE) ci->ci_serror = cpu_serror_apple; + /* + * Skip printing CPU features if they are identical to the + * previous CPU. + */ + if (READ_SPECIALREG(id_aa64isar0_el1) == prev_id_aa64isar0 && + READ_SPECIALREG(id_aa64isar1_el1) == prev_id_aa64isar1 && + READ_SPECIALREG(id_aa64isar2_el1) == prev_id_aa64isar2 && + READ_SPECIALREG(id_aa64mmfr0_el1) == prev_id_aa64mmfr0 && + READ_SPECIALREG(id_aa64mmfr1_el1) == prev_id_aa64mmfr1 && + READ_SPECIALREG(id_aa64pfr0_el1) == prev_id_aa64pfr0 && + READ_SPECIALREG(id_aa64pfr1_el1) == prev_id_aa64pfr1) + return; + /* * Print CPU features encoded in the ID registers. */ @@ -787,6 +807,14 @@ cpu_identify(struct cpu_info *ci) sep = ","; } + prev_id_aa64isar0 = READ_SPECIALREG(id_aa64isar0_el1); + prev_id_aa64isar1 = READ_SPECIALREG(id_aa64isar1_el1); + prev_id_aa64isar2 = READ_SPECIALREG(id_aa64isar2_el1); + prev_id_aa64mmfr0 = READ_SPECIALREG(id_aa64mmfr0_el1); + prev_id_aa64mmfr1 = READ_SPECIALREG(id_aa64mmfr1_el1); + prev_id_aa64pfr0 = READ_SPECIALREG(id_aa64pfr0_el1); + prev_id_aa64pfr1 = READ_SPECIALREG(id_aa64pfr1_el1); + #ifdef CPU_DEBUG id = READ_SPECIALREG(id_aa64afr0_el1); printf("\nID_AA64AFR0_EL1: 0x%016llx", id); -- 2.20.1