Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp127288pxf; Wed, 24 Mar 2021 00:36:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx2jHAtpzMRY6mdJpzTk4MWILhDLaJps9c5uKFH1wCvU08a2aDE0hbUIQc/HaQ9mIAh1bLW X-Received: by 2002:a05:6402:4244:: with SMTP id g4mr1968966edb.204.1616571367278; Wed, 24 Mar 2021 00:36:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616571367; cv=none; d=google.com; s=arc-20160816; b=BUoAUBNAMjUu0X97u6H76Gpb7euS4zUU4VGBaL35ifLDeedqU+MwKlrhK2pv8CicTf EydU7glDZVPQETt+BM7/1jq+Go1bDFvd/RrxpJ9DNBNN8byA9MWlM7kAZ87LDqaP7tKK CjQ7h1cbndw+3N4JOz8DBPGDHgQ3H9s9t876qia2jeGBL8fEh1BoZLDSbXPW6C6A5w+x nKUgEEOpdrYOKkXNkmwk2Kww4rLxXAWGkOz//NM4/DXeybw7BFAF8Vj6aCN5/Gc7mRWv X6mNYRPLaRyhPNKRKMUiFPe1wQHnTEloIzfckvCmnBKZR7RcnU988GVv/TuVaNO8iLj1 sVnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=nya+ov9UQJL5DIroCTuSAcRlSsVdt2e1wLenJZbbPhA=; b=sHi9pFF3k1M7E/rpD17ey84WPE/VvTgxNr25nR1D2+K02fzOza6XKfL4/cyFPeTuCW hCGir/c0oz8A6BvsC/BldWhHGH10yjIh8YNkRufjadBi7QDwcoCx5gcqJY8JqjL3usL6 Mk/qTb2iejADRGzPIwN/cVicq2ia8PSw/V1AcPFufsoEdEdJmtzL0eMDE/2zegX5vu/6 EAwaI4Sx7Itisj8kaE4F78l7pK7yizbHuhyMvoJWPKGzzBq+IWVmTCzM45LzL9Jj6flx r2XpijdDvaKY4wqSf3YO3L/69O1K9ZfNIqwjpOqBYeFTKBccpQ55k6po0PbJi3BhpnJr QXSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="AJ1Kfe/D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z15si1193311edr.361.2021.03.24.00.35.44; Wed, 24 Mar 2021 00:36:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="AJ1Kfe/D"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233502AbhCWVjs (ORCPT + 99 others); Tue, 23 Mar 2021 17:39:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233409AbhCWVjV (ORCPT ); Tue, 23 Mar 2021 17:39:21 -0400 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7088C061574 for ; Tue, 23 Mar 2021 14:39:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=nya+ov9UQJL5DIroCTuSAcRlSsVdt2e1wLenJZbbPhA=; b=AJ1Kfe/DCRHVaPq4z0nIiPsldY LDB0+A4YE6Yi/95NfZjZeWKLuaq4lx056SshaDbv65lUWEs630/POM0n0dHn0IAJpIt/ftddjFXoq IOIv092DQcSpk/8+lpehm/iWA7SVyMTIkxgu8VuRK0K2Y5g5t4+0motLaD3gX8WjCCB8OiO2ivkZu B7lZJSbphZQCSaE/Wh2CJwXxC0nGPk0GoBpdtAv0QNqKmcpK0mQOo8Ml11aa3ypgbYFxmh9eufRs5 RIfZTSIvgm4rjwxI3uD5AiYvaL4/vKdvRefQhvn/kaP5nTRZrn0/4YtqnAL9Y2ABKKgbmKXto5meB yhd/P2XQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=worktop.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94 #2 (Red Hat Linux)) id 1lOojn-00FnZS-T1; Tue, 23 Mar 2021 21:38:58 +0000 Received: by worktop.programming.kicks-ass.net (Postfix, from userid 1000) id F21F99864F6; Tue, 23 Mar 2021 22:38:54 +0100 (CET) Date: Tue, 23 Mar 2021 22:38:54 +0100 From: Peter Zijlstra To: Like Xu Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Thomas Gleixner , Borislav Petkov , Kan Liang , x86@kernel.org, linux-kernel@vger.kernel.org, Andi Kleen Subject: Re: [PATCH v4 RESEND 2/5] perf/x86/lbr: Simplify the exposure check for the LBR_INFO registers Message-ID: <20210323213854.GD4746@worktop.programming.kicks-ass.net> References: <20210322060635.821531-1-like.xu@linux.intel.com> <20210322060635.821531-3-like.xu@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210322060635.821531-3-like.xu@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 22, 2021 at 02:06:32PM +0800, Like Xu wrote: > If the platform supports LBR_INFO register, the x86_pmu.lbr_info will > be assigned in intel_pmu_?_lbr_init_?() and it's safe to expose LBR_INFO You mean: intel_pmu_lbr_*init*(). '?' is a single character glob and you've got too many '_'s. > in the x86_perf_get_lbr() directly, instead of relying on lbr_format check. But, afaict, not every model calls one of those. CORE_YONAH for example doesn't. > Also Architectural LBR has IA32_LBR_x_INFO instead of LBR_FORMAT_INFO_x > to hold metadata for the operation, including mispredict, TSX, and > elapsed cycle time information. Relevance? Wouldn't it be much simpler to simple say something like: "x86_pmu.lbr_info is 0 unless explicitly initialized, so there's no point checking lbr_fmt" > Signed-off-by: Like Xu > Reviewed-by: Kan Liang > Reviewed-by: Andi Kleen > --- > arch/x86/events/intel/lbr.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c > index 21890dacfcfe..355ea70f1879 100644 > --- a/arch/x86/events/intel/lbr.c > +++ b/arch/x86/events/intel/lbr.c > @@ -1832,12 +1832,10 @@ void __init intel_pmu_arch_lbr_init(void) > */ > int x86_perf_get_lbr(struct x86_pmu_lbr *lbr) > { > - int lbr_fmt = x86_pmu.intel_cap.lbr_format; > - > lbr->nr = x86_pmu.lbr_nr; > lbr->from = x86_pmu.lbr_from; > lbr->to = x86_pmu.lbr_to; > - lbr->info = (lbr_fmt == LBR_FORMAT_INFO) ? x86_pmu.lbr_info : 0; > + lbr->info = x86_pmu.lbr_info; > > return 0; > } > -- > 2.29.2 >