Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1802477pxb; Sun, 17 Jan 2021 23:36:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJyIJCTuTEej3SMrX9BFfAaCzKuUJ2Dgi2au0vSPAmxpRJKj5h8wvcJUnwipdDfwDbehOlkH X-Received: by 2002:a17:906:76c9:: with SMTP id q9mr17017709ejn.484.1610955394069; Sun, 17 Jan 2021 23:36:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610955394; cv=none; d=google.com; s=arc-20160816; b=QWyWcBXuiHWsO2Pg0o8zZpR5AN163VSqQkPqJblyFbbIcyND93VA8mVxbwRiG7J2Xa xXmJRXiXoR/xTXLelIfaTYH3SVJwyF//KNDQO8dumVjMts82CDpz2vbM9VT1jtj7uFQ1 3LZ/HutjSaFxX9EJh3uWP0RXiCtJpvrg0nRpQvFohgxMBNtyutflWH/BT2GB5DI3psnu tbUzfGbnPgVi6n/9/JaJakCZBtqp0U+KVLTWgsn91hdAeQTXl680h9PwWmyw/x465olq QnUGNt9qAbpzANkiRbTXdqxf6JbObRsuIvJ0uKHexbPUQuYVRU8bKc7T3ghohRG6+Qo7 8ucg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:ironport-sdr:ironport-sdr; bh=DoIvcrPZkMjdDQ3MnLDERwDXEccvcfeQa8dpjqyqltQ=; b=XM5OcgCecrJe6PT70jPMKzMHi3pun+SnMSszQNIGBxih33qqkQYkSA8hgKdvrNPRTJ KNN9D0Y4MIBG0czOvyip6NYRQU51lRLb6N4PTUl2OwC+k/rOBXKCQgy/QpIzaTvyHo8t YISNVy2MffND9iqr2l9QFvbWuS38hXkt2fydrb2RKttigzbeo+iOMH3x3zBFCTWCJt6n QB69gv0raBGYp/NmdpbVRYwbpzDVOMUB/6lfrKrRa1nLWHvrEigB8fhr51VaLS3XPsl+ HCNSz3M5WOBlExgvw9E7Lffb8PiHkXPeVd9nIyBGdZdKj2nN7X83aOJBTySDQtcAKyqB ITZg== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gv15si1074627ejb.579.2021.01.17.23.36.10; Sun, 17 Jan 2021 23:36:34 -0800 (PST) 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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732390AbhARHaF (ORCPT + 99 others); Mon, 18 Jan 2021 02:30:05 -0500 Received: from mga09.intel.com ([134.134.136.24]:55805 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732414AbhARH3t (ORCPT ); Mon, 18 Jan 2021 02:29:49 -0500 IronPort-SDR: cJcGwg4jcOQ1DS6yBsJqFE6OzhdQReTO2Y19oLsH+wHdAR/wVZLgVqYYK2xCfk9L4d+6m/05DJ 2UbAlqMdJ6/w== X-IronPort-AV: E=McAfee;i="6000,8403,9867"; a="178919106" X-IronPort-AV: E=Sophos;i="5.79,355,1602572400"; d="scan'208";a="178919106" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jan 2021 23:28:00 -0800 IronPort-SDR: dMdvbW9dLZGVjiN08Vqhe0d/AtEdv3AusvFRu5hgJDKWpeIRq/oHEZC/RCWXsccHvmJD7V+fiF 17eqK5FfcCxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.79,355,1602572400"; d="scan'208";a="466280086" Received: from clx-ap-likexu.sh.intel.com ([10.239.48.108]) by fmsmga001.fm.intel.com with ESMTP; 17 Jan 2021 23:27:57 -0800 From: Like Xu To: Peter Zijlstra , Josh Poimboeuf , Jason Baron Cc: Ingo Molnar , Arnaldo Carvalho de Melo , Mark Rutland , Thomas Gleixner , Borislav Petkov , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86/perf: Use static_call for x86_pmu.guest_get_msrs Date: Mon, 18 Jan 2021 15:21:51 +0800 Message-Id: <20210118072151.44481-1-like.xu@linux.intel.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Clean up that CONFIG_RETPOLINE crud and replace the indirect call x86_pmu.guest_get_msrs with static_call(). Suggested-by: Peter Zijlstra (Intel) Signed-off-by: Like Xu --- arch/x86/events/core.c | 16 ++++++++++++++++ arch/x86/events/intel/core.c | 20 -------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index e37de298a495..2eec3c8d0a13 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c @@ -81,6 +81,8 @@ DEFINE_STATIC_CALL_NULL(x86_pmu_swap_task_ctx, *x86_pmu.swap_task_ctx); DEFINE_STATIC_CALL_NULL(x86_pmu_drain_pebs, *x86_pmu.drain_pebs); DEFINE_STATIC_CALL_NULL(x86_pmu_pebs_aliases, *x86_pmu.pebs_aliases); +DEFINE_STATIC_CALL_NULL(x86_pmu_guest_get_msrs, *x86_pmu.guest_get_msrs); + u64 __read_mostly hw_cache_event_ids [PERF_COUNT_HW_CACHE_MAX] [PERF_COUNT_HW_CACHE_OP_MAX] @@ -665,6 +667,18 @@ void x86_pmu_disable_all(void) } } +struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr) +{ + struct perf_guest_switch_msr *ret = NULL; + + ret = static_call(x86_pmu_guest_get_msrs)(nr); + if (!ret) + *nr = 0; + + return ret; +} +EXPORT_SYMBOL_GPL(perf_guest_get_msrs); + /* * There may be PMI landing after enabled=0. The PMI hitting could be before or * after disable_all. @@ -1923,6 +1937,8 @@ static void x86_pmu_static_call_update(void) static_call_update(x86_pmu_drain_pebs, x86_pmu.drain_pebs); static_call_update(x86_pmu_pebs_aliases, x86_pmu.pebs_aliases); + + static_call_update(x86_pmu_guest_get_msrs, x86_pmu.guest_get_msrs); } static void _x86_pmu_read(struct perf_event *event) diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c index d4569bfa83e3..93adf53cce5f 100644 --- a/arch/x86/events/intel/core.c +++ b/arch/x86/events/intel/core.c @@ -3680,26 +3680,6 @@ static int intel_pmu_hw_config(struct perf_event *event) return 0; } -#ifdef CONFIG_RETPOLINE -static struct perf_guest_switch_msr *core_guest_get_msrs(int *nr); -static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr); -#endif - -struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr) -{ -#ifdef CONFIG_RETPOLINE - if (x86_pmu.guest_get_msrs == intel_guest_get_msrs) - return intel_guest_get_msrs(nr); - else if (x86_pmu.guest_get_msrs == core_guest_get_msrs) - return core_guest_get_msrs(nr); -#endif - if (x86_pmu.guest_get_msrs) - return x86_pmu.guest_get_msrs(nr); - *nr = 0; - return NULL; -} -EXPORT_SYMBOL_GPL(perf_guest_get_msrs); - static struct perf_guest_switch_msr *intel_guest_get_msrs(int *nr) { struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events); -- 2.29.2