Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp6458308rdb; Tue, 2 Jan 2024 02:35:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IE0RguiG2qOaQK7oiBsxJbQRxuO4HUVW+NgPWCe02rOim4SJke+IwdVmy1r2RI0UlVpbtoz X-Received: by 2002:a17:90a:de06:b0:28b:8c2e:5226 with SMTP id m6-20020a17090ade0600b0028b8c2e5226mr5325082pjv.71.1704191715391; Tue, 02 Jan 2024 02:35:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704191715; cv=none; d=google.com; s=arc-20160816; b=PFQInCaLDQKm73Aq7M8DV5p3UM9tODPXV4xMuNx/F0KUjefG/4LCvIVJUQ/xpAUYs6 FT9gElH9nfcYvxhrP4Wb0qxpqQDDWM5VrWQITnGyjhQzXM0gVWBblNQyCm2KupZgXsTO W9uHznqXVEQEmPtIuf9khMuGzK3B9W/uGXEWvlRYKnXaiG4oJSaYScHah0waYMb7zsAF XnYFqA4XXSPG6JTKyaPTslDEwMEyX7hZbkP7J04tTZJekWo07UaB27RU3mip5TO1Z7xG kc/vLN0YW2aLAl982tLeern0iPrMHVdQCAGuw3PaQwvg9SLzsnQCAjK6gDJi+vhFTHRm 7aMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=qmzzjq3k0ZYuRvdQFFKTodBxJQM9E/DweoyCy+/wM74=; fh=1/jtZYXaaK7GI6CWBuEXOBSlUKPIfQjP2SiQxXy4rD8=; b=h5wh8AK7FReo05ZP9PYZinmVLYe5qPM7UIsSsMyvPx5MfE85wBiFZy821BnrNfz1/a YkdJ1Q5M+fCDmI0C7di5xjRR+BqjXXwF8V63cbF8aJdGi9h7e7K7RlXr3OMgBaURDRJq +8HTLqfxRWVyHkMxtklSyp3aRL3lxBErCeqruIbtkYpRL8BE/6BYNAzQ2uFWslaCqoxj eXNgBTN3beEpJ5+ul3EUh2byFnINVu+MS+7RpeLpDUI4nqzSNQsKFu1J1cG58Y4Kpz+F PlJzRe/UQ15gg0KTzqR3bCGokZoUORZgvqMRyTLkChOCA3RZJKBldLCYRRj/eplJIdtC 8UcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=Uzl7Zo5R; spf=pass (google.com: domain of linux-kernel+bounces-14251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id o12-20020a17090a9f8c00b0028b21dd5308si23458819pjp.37.2024.01.02.02.35.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Jan 2024 02:35:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-14251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=alien8 header.b=Uzl7Zo5R; spf=pass (google.com: domain of linux-kernel+bounces-14251-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-14251-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 6E638B20B91 for ; Tue, 2 Jan 2024 10:35:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BB383D304; Tue, 2 Jan 2024 10:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="Uzl7Zo5R" X-Original-To: linux-kernel@vger.kernel.org Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 0E47DD28D; Tue, 2 Jan 2024 10:34:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id DD99540E00C9; Tue, 2 Jan 2024 10:34:50 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id mxpEbl6mtL9g; Tue, 2 Jan 2024 10:34:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1704191688; bh=qmzzjq3k0ZYuRvdQFFKTodBxJQM9E/DweoyCy+/wM74=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Uzl7Zo5ROy5ZjJo+SRSbo7Jv+rAmFH2RAMynkUlNu2MHLgqEcn5u54yIRhd+KrvzN 6rH+GM5G8yVYLYO+HqnEwIgxT7EtO5jYtV2kIhN3G+/jftTquh3tnfN8YIUt5sMi35 1smnU700J/W1hP7FO9y50JKT6Xu6ZfEWZDV3GtjQxgqzyceow5SCsmYr9vs3J1ii77 JyuLgCLFJXxMIlwS16uiu9e5nfE1wWh6PD6Wjq4z9EttthrAao7Twt/KKyNSWoYsPC Xqj9hIfrGlj0n/LOfT6OD55NVdDoS57TlCfrRjizoMyiWidJrDWcAenHzCcrCBJEzn dwcbOdyHFvdYJE84P1vKJgszRZPejPDQDDXMefBSy2tkYcZZAX9C/VQlPf+mB93kyy MdkNmSh06lo4CxeR2pvgUXbOOV7IHli3y2dYayP2eAstBKACbIVpiPZ4E6f/9nb9u5 eollM0gTXfrHNyO4+WOPaJrfdJm4qSqEnxnAl49rZiXCMeeo7fO8FbpQuLMdU2/rzI bxdFRwkxMiYjKfxm/4jSKI/WvETSjDWsIqhBP1dTmLrh7jI8RH+G4+5cbl357LxMOR PRuvhYtAAUSyJodRPf4Y/KbPvsTTA91/Wp4u85mFB7njsCen7Fmr0N+k3alI8X3gLl Kyzmd4BalADYoOOcwPlzKLFc= Received: from zn.tnic (pd9530f8c.dip0.t-ipconnect.de [217.83.15.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id C878040E016D; Tue, 2 Jan 2024 10:34:29 +0000 (UTC) Date: Tue, 2 Jan 2024 11:34:24 +0100 From: Borislav Petkov To: Sandipan Das Cc: linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, peterz@infradead.org, mingo@redhat.com, acme@kernel.org, mark.rutland@arm.com, alexander.shishkin@linux.intel.com, jolsa@kernel.org, namhyung@kernel.org, adrian.hunter@intel.com, tglx@linutronix.de, eranian@google.com, irogers@google.com, mario.limonciello@amd.com, ravi.bangoria@amd.com, ananth.narayan@amd.com Subject: Re: [PATCH v2 1/3] perf/x86/amd/lbr: Use freeze based on availability Message-ID: <20240102103424.GAZZPmsDsrSF9WZVl+@fat_crate.local> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Tue, Jan 02, 2024 at 11:31:28AM +0530, Sandipan Das wrote: > Currently, it is assumed that LBR Freeze is supported on all processors > which have CPUID leaf 0x80000022[EAX] bit 1 set. This is incorrect as > the feature availability is additionally dependent on CPUID leaf > 0x80000022[EAX] bit 2 being set which may not be set for all Zen 4 > processors. Define a new feature bit for LBR and PMC freeze and set the > freeze enable bit (FLBRI) in DebugCtl (MSR 0x1d9) conditionally. > > It should still be possible to use LBR without freeze for profile-guided > optimization of user programs by using an user-only branch filter during > profiling. When the user-only filter is enabled, branches are no longer > recorded after the transition to CPL 0 upon PMI arrival. When branch > entries are read in the PMI handler, the branch stack does not change. > > E.g. > > $ perf record -j any,u -e ex_ret_brn_tkn ./workload > > Fixes: ca5b7c0d9621 ("perf/x86/amd/lbr: Add LbrExtV2 branch record support") > Signed-off-by: Sandipan Das Whoever ends up committing this, please add to the commit message the reason why X86_FEATURE_AMD_LBR_PMC_FREEZE is left visible in /proc/cpuinfo: https://lore.kernel.org/all/CABPqkBQ0Zn_orR_9FnHA7Y1pNHAzG0E=86MkdMjOtGfKXDp29g@mail.gmail.com/ Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette