Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp1480449pxb; Fri, 10 Sep 2021 06:56:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKTlvXA4q33FrCwa0s5p3yhqX22fxEjhKZcBJ7YvaEPrquoQ03Y+WZt7BX5wz9EXV4rClz X-Received: by 2002:a5e:db06:: with SMTP id q6mr7319487iop.129.1631282214957; Fri, 10 Sep 2021 06:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631282214; cv=none; d=google.com; s=arc-20160816; b=lVybJSxTikxgvnEH6uF+VPh0gZpGDZG5XFjOclWo0ccgz1RR2dBpio5P/NYmhdGfoT XjlsvFxvr1TU+bKB4ASB07zAqgEVezQ9PhARhECcDDhQFanp/9NZEXZTgDhho5hKKqhw 0xz8OdXH0DmIJL3ELoyeyJIIocLrOgymeEygHfVlZnrSzpjmbtY0HHwP/kaUcxa5iZ01 N00DVRvmZ68RewFiGdIHMDccCnLXpCc9uTOWLqGtsVg4/o22AECZKyCRE/qgcrNnXu4o 8nYcwbBGXMn0c9BwwLFWn2HPmOqV++8qTzwV3AqtNFAy2ZO0ve0aR81cSPTfUE5rrE88 icJg== 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=9ImyjIQib3SxIlByLQNiBXiiPVZK58gAv8kSEMD9sVE=; b=o/Lmsxr1jjhZmYmLXGeQsi+f29XrH1Rb48i5q/FVSIIDImo2yr9L/iaC0bk4H2Z1bM vCQzoihG4k5rl5W3/mbFQdRxmG3EgbduvaNNoITczJ5GrQDpJsp0QLpNU2c000Nv0N7q XqkbJZhpXI5IBQYnPw4sigrmnyybugQfRQDZB+cMSyPzcXornQgr+zaStkI6WSNyFnYL xManG/tSQSFMu/gnnk8nQfK+aXgJu3CiFlxQAQYsm1eAjmfjGNXm21OPCxEXe78KF1o1 X0qrdtpH1ai/BSiawUFmkS4NJMPvh0tj3K05qadIfijphaoyiQsLXon1vynvJOJI94UI dQGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=oBN7pCYz; 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 d186si6497284iog.78.2021.09.10.06.56.42; Fri, 10 Sep 2021 06:56:54 -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=casper.20170209 header.b=oBN7pCYz; 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 S233702AbhIJN4V (ORCPT + 99 others); Fri, 10 Sep 2021 09:56:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233682AbhIJN4U (ORCPT ); Fri, 10 Sep 2021 09:56:20 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E12A4C061574; Fri, 10 Sep 2021 06:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; 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=9ImyjIQib3SxIlByLQNiBXiiPVZK58gAv8kSEMD9sVE=; b=oBN7pCYz8VJ7+hrMhxoU5Oij6M i9W2Webo06YujU1PHoBJLxTBPW8Kkv+nVKIMIzqCjQQM62u65SnRjm7yyDtjOPv2VK2vq5EN88IFP Tsa9QkKntfCwVt9ZGt7zxrBFNYR49+szBCP971/mWZhp5+ijFB1xv1TfE09+43Yy9N9c+5TBLz2UR 0HQ8pu9JrbxD8ULdvqdEV7RrLKNt9jT43HhBTOiVcQLRHUhm68uKBuFceDVMTXMa1UetgtLkHl4Sx 9BdUC2i06YN7mdCzDZsHaCvkvlUJF+AFQM+/1N0YM4k2HG4Pn0gS9HX9Ho5SQkVrx4RVJWIxR8b1E /NWTkGGw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mOgyi-00B3X5-6o; Fri, 10 Sep 2021 13:54:11 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 5FB4E300047; Fri, 10 Sep 2021 15:54:03 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 4025420195557; Fri, 10 Sep 2021 15:54:03 +0200 (CEST) Date: Fri, 10 Sep 2021 15:54:03 +0200 From: Peter Zijlstra To: Song Liu Cc: bpf@vger.kernel.org, linux-kernel@vger.kernel.org, acme@kernel.org, mingo@redhat.com, kjain@linux.ibm.com, kernel-team@fb.com, John Fastabend , Andrii Nakryiko Subject: Re: [PATCH v6 bpf-next 1/3] perf: enable branch record for software events Message-ID: References: <20210907202802.3675104-1-songliubraving@fb.com> <20210907202802.3675104-2-songliubraving@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 10, 2021 at 12:40:51PM +0200, Peter Zijlstra wrote: > The below seems to cure that. Seems I lost a hunk, fold below. diff --git a/arch/x86/events/intel/lbr.c b/arch/x86/events/intel/lbr.c index 9e6d6eaeb4cb..6b72e9b55c69 100644 --- a/arch/x86/events/intel/lbr.c +++ b/arch/x86/events/intel/lbr.c @@ -228,20 +228,6 @@ static void __intel_pmu_lbr_enable(bool pmi) wrmsrl(MSR_ARCH_LBR_CTL, lbr_select | ARCH_LBR_CTL_LBREN); } -static void __intel_pmu_lbr_disable(void) -{ - u64 debugctl; - - if (static_cpu_has(X86_FEATURE_ARCH_LBR)) { - wrmsrl(MSR_ARCH_LBR_CTL, 0); - return; - } - - rdmsrl(MSR_IA32_DEBUGCTLMSR, debugctl); - debugctl &= ~(DEBUGCTLMSR_LBR | DEBUGCTLMSR_FREEZE_LBRS_ON_PMI); - wrmsrl(MSR_IA32_DEBUGCTLMSR, debugctl); -} - void intel_pmu_lbr_reset_32(void) { int i; @@ -779,8 +765,12 @@ void intel_pmu_lbr_disable_all(void) { struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); - if (cpuc->lbr_users && !vlbr_exclude_host()) + if (cpuc->lbr_users && !vlbr_exclude_host()) { + if (static_cpu_has(X86_FEATURE_ARCH_LBR)) + return __intel_pmu_arch_lbr_disable(); + __intel_pmu_lbr_disable(); + } } void intel_pmu_lbr_read_32(struct cpu_hw_events *cpuc)