From nobody Mon Apr 6 23:07:14 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2BFAC64991 for ; Thu, 1 Sep 2022 17:33:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234189AbiIARdL (ORCPT ); Thu, 1 Sep 2022 13:33:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233027AbiIARdI (ORCPT ); Thu, 1 Sep 2022 13:33:08 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43306844D3 for ; Thu, 1 Sep 2022 10:33:03 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id b9-20020a170903228900b001730a0e11e5so12189504plh.19 for ; Thu, 01 Sep 2022 10:33:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date; bh=ofkPShsbSyFZI8RD89m1othYee0wghfvC+xOO3506Ww=; b=f2dd3K7JeejrjsilIf7B/bJPMfWDAesXu74GJj5UL5npsZ7j6ECo4hfl8eZJB/bNr3 bCdkXlUWwDY6FJNayKbHXBSl2B8PDA5tdlW2msiT3NoNm4HmjyaBEeGzlyiyjn5rnxZ4 x8FPhCZ8agVZtma2hSpCkQ4MqpAyumxQUFlpVImng5LLoStpvYNZDxOVJetkEHnN4Psn 8fc7dncVnaSCBIo+BZ4MoBd/NJLiK4AdFy/0T8gXysm5dZO6tHNKbWoN7o90lBA2G+Ys TI1GTbTnjTe4wn0NvwvBWRH2jesFS/3QxI/DLTPdIptUvfv4oJPvutgdLoa8wIN6Te/j I0PA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date; bh=ofkPShsbSyFZI8RD89m1othYee0wghfvC+xOO3506Ww=; b=Ev+7KWOV90xZIvhe/8qROIu2yu1jHCZvndj+kZBvYUhiYXoS+QKEjRXX2LxQZkUWuH F7b/Rwh+eGIBv377PCVMBQ6F+KZilWn06stuc4T5msoQT3/Gz6A0fgAH/PhWREPjr5Ua jlgY3hSfvKyZEB8L9w+6ay6R8OAYSyHknTi4H407ueSamBqZUDsX4Ol0CGNEcJ8LqvwE BeIdwJdIgwT5T4c+zEWympPRHr3d8Iu+xU5NP8BjwWlRKdfWSYYEYTUBBkDVAS1vaSLD i5KZ4ixu5dGt1WS1tmZouPRjqCg99b8Yz8x299hIj0liG/KSITy2GM8Xuv4X2CQ5+T1w dqkg== X-Gm-Message-State: ACgBeo0D8pka6u3LlBkqkjha+3TQw0TMqjkkzQ1Zx1aS3jKs9AGTLkUf woWkdu6MUP1bRv9Z31lHnCVvZJzgQHw= X-Google-Smtp-Source: AA6agR4P+E5miP9Nzqe0YpKuXmcmAYUmB55ligejTXr1uwXWZNlQ62OIme5k2Kuvg5q1JpWRl1OlVS+7czk= X-Received: from zagreus.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5c37]) (user=seanjc job=sendgmr) by 2002:a17:90a:e655:b0:1fe:4ec3:aba with SMTP id ep21-20020a17090ae65500b001fe4ec30abamr236338pjb.182.1662053582852; Thu, 01 Sep 2022 10:33:02 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 1 Sep 2022 17:32:54 +0000 In-Reply-To: <20220901173258.925729-1-seanjc@google.com> Mime-Version: 1.0 References: <20220901173258.925729-1-seanjc@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220901173258.925729-2-seanjc@google.com> Subject: [PATCH v4 1/5] perf/x86/core: Remove unnecessary stubs provided for KVM-only helpers From: Sean Christopherson To: Peter Zijlstra , Ingo Molnar , Arnaldo Carvalho de Melo , Sean Christopherson , Paolo Bonzini Cc: Mark Rutland , Alexander Shishkin , Jiri Olsa , Namhyung Kim , linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, Like Xu Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove CONFIG_PERF_EVENT=3Dn stubs for functions that are effectively KVM-only. KVM selects PERF_EVENT and will never consume the stubs. Dropping the unnecessary stubs will allow simplifying x86_perf_get_lbr() by getting rid of the impossible-to-hit error path (which KVM doesn't even check). Opportunstically reorganize the declarations to collapse multiple CONFIG_PERF_EVENTS #ifdefs. Signed-off-by: Sean Christopherson Reported-by: kernel test robot --- arch/x86/include/asm/perf_event.h | 53 ++++++++----------------------- 1 file changed, 13 insertions(+), 40 deletions(-) diff --git a/arch/x86/include/asm/perf_event.h b/arch/x86/include/asm/perf_= event.h index f6fc8dd51ef4..f839eb55f298 100644 --- a/arch/x86/include/asm/perf_event.h +++ b/arch/x86/include/asm/perf_event.h @@ -525,46 +525,18 @@ extern u64 perf_get_hw_event_config(int hw_event); extern void perf_check_microcode(void); extern void perf_clear_dirty_counters(void); extern int x86_perf_rdpmc_index(struct perf_event *event); -#else -static inline void perf_get_x86_pmu_capability(struct x86_pmu_capability *= cap) -{ - memset(cap, 0, sizeof(*cap)); -} =20 -static inline u64 perf_get_hw_event_config(int hw_event) -{ - return 0; -} - -static inline void perf_events_lapic_init(void) { } -static inline void perf_check_microcode(void) { } -#endif - -#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_INTEL) +#ifdef CONFIG_CPU_SUP_INTEL extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *da= ta); extern int x86_perf_get_lbr(struct x86_pmu_lbr *lbr); -#else -struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr, void *data); -static inline int x86_perf_get_lbr(struct x86_pmu_lbr *lbr) -{ - return -1; -} -#endif +extern void intel_pt_handle_vmx(int on); +#endif /* CONFIG_CPU_SUP_INTEL */ =20 -#ifdef CONFIG_CPU_SUP_INTEL - extern void intel_pt_handle_vmx(int on); -#else -static inline void intel_pt_handle_vmx(int on) -{ +#ifdef CONFIG_CPU_SUP_AMD +extern void amd_pmu_enable_virt(void); +extern void amd_pmu_disable_virt(void); =20 -} -#endif - -#if defined(CONFIG_PERF_EVENTS) && defined(CONFIG_CPU_SUP_AMD) - extern void amd_pmu_enable_virt(void); - extern void amd_pmu_disable_virt(void); - -#if defined(CONFIG_PERF_EVENTS_AMD_BRS) +#ifdef CONFIG_PERF_EVENTS_AMD_BRS =20 #define PERF_NEEDS_LOPWR_CB 1 =20 @@ -582,12 +554,13 @@ static inline void perf_lopwr_cb(bool lopwr_in) static_call_mod(perf_lopwr_cb)(lopwr_in); } =20 -#endif /* PERF_NEEDS_LOPWR_CB */ +#endif /* CONFIG_PERF_EVENTS_AMD_BRS */ +#endif /* CONFIG_CPU_SUP_AMD */ =20 -#else - static inline void amd_pmu_enable_virt(void) { } - static inline void amd_pmu_disable_virt(void) { } -#endif +#else /* !CONFIG_PERF_EVENTS */ +static inline void perf_events_lapic_init(void) { } +static inline void perf_check_microcode(void) { } +#endif /* CONFIG_PERF_EVENTS */ =20 #define arch_perf_out_copy_user copy_from_user_nmi =20 --=20 2.37.2.789.g6183377224-goog