From nobody Thu Apr 2 20:20:47 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F1A7D376BEC for ; Fri, 27 Mar 2026 02:21:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774578068; cv=none; b=QdTboQx8KiazwdLMaTyYgM+75LR6WW3/3LwbHTWKPhxWgo8i6FCzeXIsR4UE/2UyqBq1ZJsiywqh02TKupdqWxvpmve7pIbiaUmf7X1ZZzqNUUAJ/LtwD10q9bt7HgIK16rhy4OlNbyElKHcCfo1YK2r/gt76xYs5Osi/Naq2vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774578068; c=relaxed/simple; bh=CJIqPe48oi83NtLflCwO7pRjDo23buF+R/95EVAg8Fc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Au1XUd84ZMYaPhTNkShCrLxy3tvm1U8F1mBTLAK1RVHS3+SuZUI44GGIn4bK6h52B7+Yp/HDcBjNs7+ykMHELrOrqbsRn/plsw0SdGajjkhow3GjFd9NpzmQAGllyF34h0XVh9nCLAjqxlNYem4pT8RUif7W0jl/JGaVMiBnvAk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=4vt1yFai; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=+AyGi/Az; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="4vt1yFai"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="+AyGi/Az" From: "Ahmed S. Darwish" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1774578064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hcl3gDDxvBw76pQpHh0N5lzLkbf3ZnbbNEuPzu4azcY=; b=4vt1yFaiU/s7xV6FS+UNVjKIUS8di3FFlF/aBNYZqxjVwtN2tQeoFIdjScKoP8VE9QIuoR ROc1raxDvYlssOeFLxhKxrB3XQeO16HsNUmVqvJJCVrIb/Kr+z5vm9W3l+IVcfQXBACqyN SbDz2Wm9m53pZyK0z6v3bcbOEWxQuYc6masvcHIj6JjfFaR96PRKPi1XdCgKLeyHfwKcBB 1zroaAGtV85QDSK/zGSd3q0gFKXw8Szzd1dqrrgkYsRkvedID+pLHtWIsiTVKVfEc3T5Or oHAtwHVoPyFq9XVApOn5yrbZePpAnlu/ZzAjahHvAvju/rWVl/YhxRdKhyuvTg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1774578064; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hcl3gDDxvBw76pQpHh0N5lzLkbf3ZnbbNEuPzu4azcY=; b=+AyGi/AzlDxJiNhKOYr0UjiPx0PpVTf8joGQndBpP+rWTjM+K2aAX956d5aHsxY2QVmZrS d5bLFvRqwuBUi+CQ== To: Borislav Petkov , Dave Hansen , Ingo Molnar Cc: Thomas Gleixner , Andrew Cooper , "H. Peter Anvin" , Sean Christopherson , David Woodhouse , Peter Zijlstra , Christian Ludloff , Sohil Mehta , John Ogness , x86@kernel.org, x86-cpuid@lists.linux.dev, LKML , "Ahmed S. Darwish" Subject: [PATCH v6 61/90] perf/x86/lbr: Use parsed CPUID(0x1c) Date: Fri, 27 Mar 2026 03:16:15 +0100 Message-ID: <20260327021645.555257-62-darwi@linutronix.de> In-Reply-To: <20260327021645.555257-1-darwi@linutronix.de> References: <20260327021645.555257-1-darwi@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use parsed CPUID(0x1c) instead of a direct CPUID query and custom perf CPUID(0x1c) data types. Signed-off-by: Ahmed S. Darwish --- arch/x86/events/intel/lbr.c | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index cae2e02fe6cc..7bc48f5e5e52 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -1587,19 +1587,16 @@ static bool is_arch_lbr_xsave_available(void) =20 void __init intel_pmu_arch_lbr_init(void) { + const struct leaf_0x1c_0 *l =3D cpuid_leaf(&boot_cpu_data, 0x1c); struct pmu *pmu =3D x86_get_pmu(smp_processor_id()); - union cpuid28_eax eax; - union cpuid28_ebx ebx; - union cpuid28_ecx ecx; - unsigned int unused_edx; bool arch_lbr_xsave; size_t size; u64 lbr_nr; =20 - /* Arch LBR Capabilities */ - cpuid(28, &eax.full, &ebx.full, &ecx.full, &unused_edx); + if (!l) + goto clear_arch_lbr; =20 - lbr_nr =3D fls(eax.split.lbr_depth_mask) * 8; + lbr_nr =3D fls(l->lbr_depth_mask) * 8; if (!lbr_nr) goto clear_arch_lbr; =20 @@ -1607,17 +1604,17 @@ void __init intel_pmu_arch_lbr_init(void) if (wrmsrq_safe(MSR_ARCH_LBR_DEPTH, lbr_nr)) goto clear_arch_lbr; =20 - x86_pmu.lbr_depth_mask =3D eax.split.lbr_depth_mask; - x86_pmu.lbr_deep_c_reset =3D eax.split.lbr_deep_c_reset; - x86_pmu.lbr_lip =3D eax.split.lbr_lip; - x86_pmu.lbr_cpl =3D ebx.split.lbr_cpl; - x86_pmu.lbr_filter =3D ebx.split.lbr_filter; - x86_pmu.lbr_call_stack =3D ebx.split.lbr_call_stack; - x86_pmu.lbr_mispred =3D ecx.split.lbr_mispred; - x86_pmu.lbr_timed_lbr =3D ecx.split.lbr_timed_lbr; - x86_pmu.lbr_br_type =3D ecx.split.lbr_br_type; - x86_pmu.lbr_counters =3D ecx.split.lbr_counters; - x86_pmu.lbr_nr =3D lbr_nr; + x86_pmu.lbr_depth_mask =3D l->lbr_depth_mask; + x86_pmu.lbr_deep_c_reset =3D l->lbr_deep_c_reset; + x86_pmu.lbr_lip =3D l->lbr_ip_is_lip; + x86_pmu.lbr_cpl =3D l->lbr_cpl; + x86_pmu.lbr_filter =3D l->lbr_branch_filter; + x86_pmu.lbr_call_stack =3D l->lbr_call_stack; + x86_pmu.lbr_mispred =3D l->lbr_mispredict; + x86_pmu.lbr_timed_lbr =3D l->lbr_timed_lbr; + x86_pmu.lbr_br_type =3D l->lbr_branch_type; + x86_pmu.lbr_counters =3D l->lbr_events_gpc_bmp; + x86_pmu.lbr_nr =3D lbr_nr; =20 if (!!x86_pmu.lbr_counters) x86_pmu.flags |=3D PMU_FL_BR_CNTR | PMU_FL_DYN_CONSTRAINT; --=20 2.53.0