Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp38673lqb; Tue, 16 Apr 2024 08:13:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX1bGXpdtwvBPw2cAR0GiWqswzVPVh1AorrpBaiY2cEAjUuH3E7EfcOpjUCrW2b3lu36fM0iqWdDJlVJuR9iVrHnL4oBLR7wrOWKIZM1Q== X-Google-Smtp-Source: AGHT+IHNSyWtcUAo/oO70HKE6do+4Yo1mtP/Zz7jVo+qyAl3Cyn5MCDGTpxBKEksJljQuwWKYQ/D X-Received: by 2002:ae9:e607:0:b0:78d:6150:fc16 with SMTP id z7-20020ae9e607000000b0078d6150fc16mr13550943qkf.33.1713280395401; Tue, 16 Apr 2024 08:13:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713280395; cv=pass; d=google.com; s=arc-20160816; b=Z6Ono171Gv+3Rb21s12c7slV/AfB7xb/nMfaDG6zXa9uCqb1zyABds45/Rnm5FrL5v +zv4boG+cODvRp8w5H8hideWB/Hx22g7ScMyN9x0d125Oar96uzPVz17NKnuaTcPhVGF OKjKIGdPbLhMXTZ+71x6P/ybRqcSpRFl0iSiz8eHx6Q+4/DxcmjHwVOTiONwDP2c6UFV /pPThknZM7PsfWbsfgERyepa+ACrCQp2MIgkJB8SE0JGVGGGV7cK5iVvhbM3CYPv6o8j RxXBaYH4jt1THf/j7Z3LtS6TWUIqfBtnLG14SMpNz39RXc9TxsewZ0XWnCty01x/cews egzA== ARC-Message-Signature: i=2; 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; bh=ORqlcAUGff56lf0HoOBE7o9B2w/lfDLQd+UuMtPHrXo=; fh=SLX4p6vBqPU7zW0wkqICJqcdDgAXGE8nOkU5rRZfi1w=; b=nynyPNF42Kao1niGRgBTGQ/CiUrokw9fdi3uOmHJSwrHp8Q6O6W1/c7ydcAkX6oqt0 adV3O36nSCDrRwJmfZyGYY+YRZzynTVPzuuu3bZhdL3OGEZdUIeWkK+3NzR0Z0ou2CrV STCl35cDb3R1RoxQfTqLeXlIGbCsbSFl3jE96lttZPRD06U76AVEISk2GVcsiidtl0QZ naktLerHxEWj0WiU/bQ0ABrpPHKNbUKiSVdYDndlxalzrn+AHZAyQkQYPG4niHS+vrc4 vIPckltI83lIr0eIn6F0WT5j1+18ZYkaClw5CqvHnFI1H24yfy8hq2uva0305Q+s4HZy mHUg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-147095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x16-20020a05620a099000b0078eeec487ffsi3175188qkx.510.2024.04.16.08.13.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 08:13:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=alien8.de dmarc=pass fromdomain=alien8.de); spf=pass (google.com: domain of linux-kernel+bounces-147095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 1F8911C210E6 for ; Tue, 16 Apr 2024 15:13:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0D9D6130A47; Tue, 16 Apr 2024 15:13:06 +0000 (UTC) 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 A37BE12F5BE for ; Tue, 16 Apr 2024 15:13:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713280385; cv=none; b=PUCkY1t9d1zkHkmjpe8wuxkb9kcgEhYGwTNrU65DOuQUZbMoprTSKgstFLvjxtx85Ejk+p+W9Cm10xjhNUt+AvRq9CroixqkQWKa66Ytr/fKY8yVltI7/Eic0JVwu7TpGCNZOkluOIg2/Y+EEyLynxgijAOu8PZMKvVPeeH3KxM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713280385; c=relaxed/simple; bh=IPx8CmpfXcKAFC2d2Ekg6iZ70z+J/jgyY6cewblWTmA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=dIt6v52FcpdVkDKGDGo4w1OmLSoo8mMK039eBWoNjYcEPitv6jcgMxIzHCtsaeh+M6xj4KarGEFUzWUBCE97aw2bnjdlAzEPQQZ322nq6o6ySxFZZwEtmdDtNaabWuJ19T2C5o4NNySKM8VTOfkNCV93qZ907PiZPLyz7XQqFpc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; arc=none smtp.client-ip=65.109.113.108 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 A307E40E0187; Tue, 16 Apr 2024 15:13:01 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.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 xFtK88hvB0ON; Tue, 16 Apr 2024 15:12:56 +0000 (UTC) Received: from zn.tnic (pd953020b.dip0.t-ipconnect.de [217.83.2.11]) (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 4DE7C40E0177; Tue, 16 Apr 2024 15:12:49 +0000 (UTC) Date: Tue, 16 Apr 2024 17:12:42 +0200 From: Borislav Petkov To: Dave Hansen , Robert Richter Cc: linux-kernel@vger.kernel.org, jgross@suse.com, tglx@linutronix.de, x86@kernel.org Subject: Re: [PATCH 2/4] perf/x86/ibs: Use CPUID region helper Message-ID: <20240416151242.GGZh6VaiO2gC4ej2BT@fat_crate.local> References: <20240403153508.7328E749@davehans-spike.ostc.intel.com> <20240403153511.75CB9DA0@davehans-spike.ostc.intel.com> 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: <20240403153511.75CB9DA0@davehans-spike.ostc.intel.com> On Wed, Apr 03, 2024 at 08:35:11AM -0700, Dave Hansen wrote: > > From: Dave Hansen > > IBS details are enumerated in an extended CPUID leaf. But > the support has an open-coded CPUID region check. Use the > new helper to trim down the code. > > Signed-off-by: Dave Hansen > -- > > Note: this cleanup could take another form: > > if (boot_cpu_data->extended_cpuid_level >= IBS_CPUID_FEATURES) > caps = cpuid_eax(IBS_CPUID_FEATURES); > > that would be one fewer CPUID invocations, but one more > line of code. > --- > > b/arch/x86/events/amd/ibs.c | 9 ++------- > 1 file changed, 2 insertions(+), 7 deletions(-) > > diff -puN arch/x86/events/amd/ibs.c~ibs-region-helpers arch/x86/events/amd/ibs.c > --- a/arch/x86/events/amd/ibs.c~ibs-region-helpers 2024-04-02 15:22:59.262912595 -0700 > +++ b/arch/x86/events/amd/ibs.c 2024-04-02 15:22:59.262912595 -0700 > @@ -1278,18 +1278,13 @@ static __init int perf_event_ibs_init(vo > > static __init u32 __get_ibs_caps(void) > { > - u32 caps; > - unsigned int max_level; > + u32 caps = 0; > > if (!boot_cpu_has(X86_FEATURE_IBS)) > return 0; > > - /* check IBS cpuid feature flags */ > - max_level = cpuid_eax(0x80000000); > - if (max_level < IBS_CPUID_FEATURES) > - return IBS_CAPS_DEFAULT; > + get_cpuid_region_leaf(IBS_CPUID_FEATURES, CPUID_EAX, &caps); I wanna say all this checking of max level is worthless because if you have X86_FEATURE_IBS, then it is a given that you also have that 0x8000001b CPUID leaf. Right, Bob? Unless there was some weird thing back then with the CPUID leafs... Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette