KVM Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/5] perf: oprofile spring cleanup
@ 2021-04-14 13:44 Marc Zyngier
  2021-04-14 13:44 ` [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers Marc Zyngier
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Marc Zyngier @ 2021-04-14 13:44 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390, linux-sh
  Cc: Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

This small series builds on top of the work that was started with [1].

It recently became apparent that KVM/arm64 is the last bit of the
kernel that still uses perf_num_counters().

As I went ahead to address this, it became obvious that all traces of
oprofile had been eradicated from all architectures but arm64, s390
and sh (plus a bit of cruft in the core perf code). With KVM fixed,
perf_num_counters() and perf_pmu_name() are finally gone.

Thanks,

	M.

[1] https://lore.kernel.org/lkml/20210215050618.hgftdmfmslbdrg3j@vireshk-i7

Marc Zyngier (5):
  KVM: arm64: Divorce the perf code from oprofile helpers
  arm64: Get rid of oprofile leftovers
  s390: Get rid of oprofile leftovers
  sh: Get rid of oprofile leftovers
  perf: Get rid of oprofile leftovers

 arch/arm64/kvm/perf.c         |  7 +------
 arch/arm64/kvm/pmu-emul.c     |  2 +-
 arch/s390/kernel/perf_event.c | 21 ---------------------
 arch/sh/kernel/perf_event.c   | 18 ------------------
 drivers/perf/arm_pmu.c        | 30 ------------------------------
 include/kvm/arm_pmu.h         |  4 ++++
 include/linux/perf_event.h    |  2 --
 kernel/events/core.c          |  5 -----
 8 files changed, 6 insertions(+), 83 deletions(-)

-- 
2.29.2

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers
  2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
@ 2021-04-14 13:44 ` Marc Zyngier
  2021-04-15  6:59   ` Keqian Zhu
  2021-04-22 10:43   ` Will Deacon
  2021-04-14 13:44 ` [PATCH 2/5] arm64: Get rid of oprofile leftovers Marc Zyngier
                   ` (4 subsequent siblings)
  5 siblings, 2 replies; 16+ messages in thread
From: Marc Zyngier @ 2021-04-14 13:44 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390, linux-sh
  Cc: Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

KVM/arm64 is the sole user of perf_num_counters(), and really
could do without it. Stop using the obsolete API by relying on
the existing probing code.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/arm64/kvm/perf.c     | 7 +------
 arch/arm64/kvm/pmu-emul.c | 2 +-
 include/kvm/arm_pmu.h     | 4 ++++
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c
index 739164324afe..b8b398670ef2 100644
--- a/arch/arm64/kvm/perf.c
+++ b/arch/arm64/kvm/perf.c
@@ -50,12 +50,7 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
 
 int kvm_perf_init(void)
 {
-	/*
-	 * Check if HW_PERF_EVENTS are supported by checking the number of
-	 * hardware performance counters. This could ensure the presence of
-	 * a physical PMU and CONFIG_PERF_EVENT is selected.
-	 */
-	if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0)
+	if (kvm_pmu_probe_pmuver() != 0xf)
 		static_branch_enable(&kvm_arm_pmu_available);
 
 	return perf_register_guest_info_callbacks(&kvm_guest_cbs);
diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
index e32c6e139a09..fd167d4f4215 100644
--- a/arch/arm64/kvm/pmu-emul.c
+++ b/arch/arm64/kvm/pmu-emul.c
@@ -739,7 +739,7 @@ void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u64 data,
 	kvm_pmu_create_perf_event(vcpu, select_idx);
 }
 
-static int kvm_pmu_probe_pmuver(void)
+int kvm_pmu_probe_pmuver(void)
 {
 	struct perf_event_attr attr = { };
 	struct perf_event *event;
diff --git a/include/kvm/arm_pmu.h b/include/kvm/arm_pmu.h
index 6fd3cda608e4..864b9997efb2 100644
--- a/include/kvm/arm_pmu.h
+++ b/include/kvm/arm_pmu.h
@@ -61,6 +61,7 @@ int kvm_arm_pmu_v3_get_attr(struct kvm_vcpu *vcpu,
 int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu,
 			    struct kvm_device_attr *attr);
 int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu);
+int kvm_pmu_probe_pmuver(void);
 #else
 struct kvm_pmu {
 };
@@ -116,6 +117,9 @@ static inline u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1)
 {
 	return 0;
 }
+
+static inline int kvm_pmu_probe_pmuver(void) { return 0xf; }
+
 #endif
 
 #endif
-- 
2.29.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 2/5] arm64: Get rid of oprofile leftovers
  2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
  2021-04-14 13:44 ` [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers Marc Zyngier
@ 2021-04-14 13:44 ` Marc Zyngier
  2021-04-22 10:45   ` Will Deacon
  2021-04-14 13:44 ` [PATCH 3/5] s390: " Marc Zyngier
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Marc Zyngier @ 2021-04-14 13:44 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390, linux-sh
  Cc: Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

perf_pmu_name() and perf_num_counters() are now unused. Drop them.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/perf/arm_pmu.c | 30 ------------------------------
 1 file changed, 30 deletions(-)

diff --git a/drivers/perf/arm_pmu.c b/drivers/perf/arm_pmu.c
index 2d10d84fb79c..d4f7f1f9cc77 100644
--- a/drivers/perf/arm_pmu.c
+++ b/drivers/perf/arm_pmu.c
@@ -581,33 +581,6 @@ static const struct attribute_group armpmu_common_attr_group = {
 	.attrs = armpmu_common_attrs,
 };
 
-/* Set at runtime when we know what CPU type we are. */
-static struct arm_pmu *__oprofile_cpu_pmu;
-
-/*
- * Despite the names, these two functions are CPU-specific and are used
- * by the OProfile/perf code.
- */
-const char *perf_pmu_name(void)
-{
-	if (!__oprofile_cpu_pmu)
-		return NULL;
-
-	return __oprofile_cpu_pmu->name;
-}
-EXPORT_SYMBOL_GPL(perf_pmu_name);
-
-int perf_num_counters(void)
-{
-	int max_events = 0;
-
-	if (__oprofile_cpu_pmu != NULL)
-		max_events = __oprofile_cpu_pmu->num_events;
-
-	return max_events;
-}
-EXPORT_SYMBOL_GPL(perf_num_counters);
-
 static int armpmu_count_irq_users(const int irq)
 {
 	int cpu, count = 0;
@@ -979,9 +952,6 @@ int armpmu_register(struct arm_pmu *pmu)
 	if (ret)
 		goto out_destroy;
 
-	if (!__oprofile_cpu_pmu)
-		__oprofile_cpu_pmu = pmu;
-
 	pr_info("enabled with %s PMU driver, %d counters available%s\n",
 		pmu->name, pmu->num_events,
 		has_nmi ? ", using NMIs" : "");
-- 
2.29.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 3/5] s390: Get rid of oprofile leftovers
  2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
  2021-04-14 13:44 ` [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers Marc Zyngier
  2021-04-14 13:44 ` [PATCH 2/5] arm64: Get rid of oprofile leftovers Marc Zyngier
@ 2021-04-14 13:44 ` Marc Zyngier
  2021-04-15 10:38   ` Heiko Carstens
  2021-04-14 13:44 ` [PATCH 4/5] sh: " Marc Zyngier
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Marc Zyngier @ 2021-04-14 13:44 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390, linux-sh
  Cc: Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

perf_pmu_name() and perf_num_counters() are unused. Drop them.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/s390/kernel/perf_event.c | 21 ---------------------
 1 file changed, 21 deletions(-)

diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c
index 1e75cc983546..ea7729bebaa0 100644
--- a/arch/s390/kernel/perf_event.c
+++ b/arch/s390/kernel/perf_event.c
@@ -23,27 +23,6 @@
 #include <asm/sysinfo.h>
 #include <asm/unwind.h>
 
-const char *perf_pmu_name(void)
-{
-	if (cpum_cf_avail() || cpum_sf_avail())
-		return "CPU-Measurement Facilities (CPU-MF)";
-	return "pmu";
-}
-EXPORT_SYMBOL(perf_pmu_name);
-
-int perf_num_counters(void)
-{
-	int num = 0;
-
-	if (cpum_cf_avail())
-		num += PERF_CPUM_CF_MAX_CTR;
-	if (cpum_sf_avail())
-		num += PERF_CPUM_SF_MAX_CTR;
-
-	return num;
-}
-EXPORT_SYMBOL(perf_num_counters);
-
 static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs)
 {
 	struct stack_frame *stack = (struct stack_frame *) regs->gprs[15];
-- 
2.29.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 4/5] sh: Get rid of oprofile leftovers
  2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
                   ` (2 preceding siblings ...)
  2021-04-14 13:44 ` [PATCH 3/5] s390: " Marc Zyngier
@ 2021-04-14 13:44 ` Marc Zyngier
  2021-04-14 19:09   ` Geert Uytterhoeven
  2021-04-14 13:44 ` [PATCH 5/5] perf: " Marc Zyngier
  2021-04-22 12:48 ` [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
  5 siblings, 1 reply; 16+ messages in thread
From: Marc Zyngier @ 2021-04-14 13:44 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390, linux-sh
  Cc: Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

perf_pmu_name() and perf_num_counters() are unused. Drop them.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 arch/sh/kernel/perf_event.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/arch/sh/kernel/perf_event.c b/arch/sh/kernel/perf_event.c
index 445e3ece4c23..1d2507f22437 100644
--- a/arch/sh/kernel/perf_event.c
+++ b/arch/sh/kernel/perf_event.c
@@ -57,24 +57,6 @@ static inline int sh_pmu_initialized(void)
 	return !!sh_pmu;
 }
 
-const char *perf_pmu_name(void)
-{
-	if (!sh_pmu)
-		return NULL;
-
-	return sh_pmu->name;
-}
-EXPORT_SYMBOL_GPL(perf_pmu_name);
-
-int perf_num_counters(void)
-{
-	if (!sh_pmu)
-		return 0;
-
-	return sh_pmu->num_events;
-}
-EXPORT_SYMBOL_GPL(perf_num_counters);
-
 /*
  * Release the PMU if this is the last perf_event.
  */
-- 
2.29.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 5/5] perf: Get rid of oprofile leftovers
  2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
                   ` (3 preceding siblings ...)
  2021-04-14 13:44 ` [PATCH 4/5] sh: " Marc Zyngier
@ 2021-04-14 13:44 ` Marc Zyngier
  2021-04-22 10:47   ` Will Deacon
  2021-04-22 12:48 ` [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
  5 siblings, 1 reply; 16+ messages in thread
From: Marc Zyngier @ 2021-04-14 13:44 UTC (permalink / raw)
  To: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390, linux-sh
  Cc: Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

perf_pmu_name() and perf_num_counters() are unused. Drop them.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 include/linux/perf_event.h | 2 --
 kernel/events/core.c       | 5 -----
 2 files changed, 7 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 3f7f89ea5e51..51154ed9a206 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -951,8 +951,6 @@ extern void perf_event_itrace_started(struct perf_event *event);
 extern int perf_pmu_register(struct pmu *pmu, const char *name, int type);
 extern void perf_pmu_unregister(struct pmu *pmu);
 
-extern int perf_num_counters(void);
-extern const char *perf_pmu_name(void);
 extern void __perf_event_task_sched_in(struct task_struct *prev,
 				       struct task_struct *task);
 extern void __perf_event_task_sched_out(struct task_struct *prev,
diff --git a/kernel/events/core.c b/kernel/events/core.c
index 03db40f6cba9..88cb0ba5690b 100644
--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -580,11 +580,6 @@ static u64 perf_event_time(struct perf_event *event);
 
 void __weak perf_event_print_debug(void)	{ }
 
-extern __weak const char *perf_pmu_name(void)
-{
-	return "pmu";
-}
-
 static inline u64 perf_clock(void)
 {
 	return local_clock();
-- 
2.29.2


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 4/5] sh: Get rid of oprofile leftovers
  2021-04-14 13:44 ` [PATCH 4/5] sh: " Marc Zyngier
@ 2021-04-14 19:09   ` Geert Uytterhoeven
  0 siblings, 0 replies; 16+ messages in thread
From: Geert Uytterhoeven @ 2021-04-14 19:09 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: KVM list, kvmarm, Linux ARM, Linux Kernel Mailing List,
	linux-s390, Linux-sh list, Mark Rutland, Will Deacon,
	Rich Felker, Yoshinori Sato, Peter Zijlstra,
	Arnaldo Carvalho de Melo, Christian Borntraeger, Heiko Carstens,
	nathan, Viresh Kumar, James Morse, Suzuki K Poulose,
	Alexandru Elisei, Android Kernel Team

On Wed, Apr 14, 2021 at 3:53 PM Marc Zyngier <maz@kernel.org> wrote:
> perf_pmu_name() and perf_num_counters() are unused. Drop them.
>
> Signed-off-by: Marc Zyngier <maz@kernel.org>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers
  2021-04-14 13:44 ` [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers Marc Zyngier
@ 2021-04-15  6:59   ` Keqian Zhu
       [not found]     ` <87h7k7n81z.wl-maz@kernel.org>
  2021-04-22 10:43   ` Will Deacon
  1 sibling, 1 reply; 16+ messages in thread
From: Keqian Zhu @ 2021-04-15  6:59 UTC (permalink / raw)
  To: Marc Zyngier, kvm, kvmarm, linux-arm-kernel, linux-kernel,
	linux-s390, linux-sh
  Cc: Rich Felker, Yoshinori Sato, Peter Zijlstra, Viresh Kumar,
	Heiko Carstens, Arnaldo Carvalho de Melo, nathan,
	Christian Borntraeger, kernel-team, Will Deacon

Hi Marc,

On 2021/4/14 21:44, Marc Zyngier wrote:
> KVM/arm64 is the sole user of perf_num_counters(), and really
> could do without it. Stop using the obsolete API by relying on
> the existing probing code.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  arch/arm64/kvm/perf.c     | 7 +------
>  arch/arm64/kvm/pmu-emul.c | 2 +-
>  include/kvm/arm_pmu.h     | 4 ++++
>  3 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c
> index 739164324afe..b8b398670ef2 100644
> --- a/arch/arm64/kvm/perf.c
> +++ b/arch/arm64/kvm/perf.c
> @@ -50,12 +50,7 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
>  
>  int kvm_perf_init(void)
>  {
> -	/*
> -	 * Check if HW_PERF_EVENTS are supported by checking the number of
> -	 * hardware performance counters. This could ensure the presence of
> -	 * a physical PMU and CONFIG_PERF_EVENT is selected.
> -	 */
> -	if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0)
> +	if (kvm_pmu_probe_pmuver() != 0xf)
The probe() function may be called many times (kvm_arm_pmu_v3_set_attr also calls it).
I don't know whether the first calling is enough. If so, can we use a static variable
in it, so the following calling can return the result right away?

Thanks,
Keqian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/5] s390: Get rid of oprofile leftovers
  2021-04-14 13:44 ` [PATCH 3/5] s390: " Marc Zyngier
@ 2021-04-15 10:38   ` Heiko Carstens
  2021-04-15 10:47     ` Marc Zyngier
  0 siblings, 1 reply; 16+ messages in thread
From: Heiko Carstens @ 2021-04-15 10:38 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	nathan, Viresh Kumar, James Morse, Suzuki K Poulose,
	Alexandru Elisei, kernel-team

On Wed, Apr 14, 2021 at 02:44:07PM +0100, Marc Zyngier wrote:
> perf_pmu_name() and perf_num_counters() are unused. Drop them.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  arch/s390/kernel/perf_event.c | 21 ---------------------
>  1 file changed, 21 deletions(-)

Acked-by: Heiko Carstens <hca@linux.ibm.com>

...or do you want me to pick this up and route via the s390 tree(?).

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/5] s390: Get rid of oprofile leftovers
  2021-04-15 10:38   ` Heiko Carstens
@ 2021-04-15 10:47     ` Marc Zyngier
  2021-04-15 12:12       ` Heiko Carstens
  0 siblings, 1 reply; 16+ messages in thread
From: Marc Zyngier @ 2021-04-15 10:47 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	nathan, Viresh Kumar, James Morse, Suzuki K Poulose,
	Alexandru Elisei, kernel-team

On Thu, 15 Apr 2021 11:38:52 +0100,
Heiko Carstens <hca@linux.ibm.com> wrote:
> 
> On Wed, Apr 14, 2021 at 02:44:07PM +0100, Marc Zyngier wrote:
> > perf_pmu_name() and perf_num_counters() are unused. Drop them.
> > 
> > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > ---
> >  arch/s390/kernel/perf_event.c | 21 ---------------------
> >  1 file changed, 21 deletions(-)
> 
> Acked-by: Heiko Carstens <hca@linux.ibm.com>
> 
> ...or do you want me to pick this up and route via the s390 tree(?).

Either way work for me, but I just want to make sure the last patch
doesn't get applied before the previous ones.

Thanks,

	M.

-- 
Without deviation from the norm, progress is not possible.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers
       [not found]     ` <87h7k7n81z.wl-maz@kernel.org>
@ 2021-04-15 11:34       ` Keqian Zhu
  0 siblings, 0 replies; 16+ messages in thread
From: Keqian Zhu @ 2021-04-15 11:34 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Rich Felker, Yoshinori Sato, Peter Zijlstra,
	Viresh Kumar, Heiko Carstens, Arnaldo Carvalho de Melo, nathan,
	Christian Borntraeger, kernel-team, Will Deacon

Hi Marc,

On 2021/4/15 18:42, Marc Zyngier wrote:
> On Thu, 15 Apr 2021 07:59:26 +0100,
> Keqian Zhu <zhukeqian1@huawei.com> wrote:
>>
>> Hi Marc,
>>
>> On 2021/4/14 21:44, Marc Zyngier wrote:
>>> KVM/arm64 is the sole user of perf_num_counters(), and really
>>> could do without it. Stop using the obsolete API by relying on
>>> the existing probing code.
>>>
>>> Signed-off-by: Marc Zyngier <maz@kernel.org>
>>> ---
>>>  arch/arm64/kvm/perf.c     | 7 +------
>>>  arch/arm64/kvm/pmu-emul.c | 2 +-
>>>  include/kvm/arm_pmu.h     | 4 ++++
>>>  3 files changed, 6 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c
>>> index 739164324afe..b8b398670ef2 100644
>>> --- a/arch/arm64/kvm/perf.c
>>> +++ b/arch/arm64/kvm/perf.c
>>> @@ -50,12 +50,7 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
>>>  
>>>  int kvm_perf_init(void)
>>>  {
>>> -	/*
>>> -	 * Check if HW_PERF_EVENTS are supported by checking the number of
>>> -	 * hardware performance counters. This could ensure the presence of
>>> -	 * a physical PMU and CONFIG_PERF_EVENT is selected.
>>> -	 */
>>> -	if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0)
>>> +	if (kvm_pmu_probe_pmuver() != 0xf)
>> The probe() function may be called many times
>> (kvm_arm_pmu_v3_set_attr also calls it).  I don't know whether the
>> first calling is enough. If so, can we use a static variable in it,
>> so the following calling can return the result right away?
> 
> No, because that wouldn't help with crappy big-little implementations
> that could have PMUs with different versions. We want to find the
> version at the point where the virtual PMU is created, which is why we
> call the probe function once per vcpu.
I see.

But AFAICS the pmuver is placed in kvm->arch, and the probe function is called
once per VM. Maybe I miss something.

> 
> This of course is broken in other ways (BL+KVM is a total disaster
> when it comes to PMU), but making this static would just make it
> worse.
OK.

Thanks,
Keqian

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 3/5] s390: Get rid of oprofile leftovers
  2021-04-15 10:47     ` Marc Zyngier
@ 2021-04-15 12:12       ` Heiko Carstens
  0 siblings, 0 replies; 16+ messages in thread
From: Heiko Carstens @ 2021-04-15 12:12 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Mark Rutland, Will Deacon, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	nathan, Viresh Kumar, James Morse, Suzuki K Poulose,
	Alexandru Elisei, kernel-team

On Thu, Apr 15, 2021 at 11:47:26AM +0100, Marc Zyngier wrote:
> On Thu, 15 Apr 2021 11:38:52 +0100,
> Heiko Carstens <hca@linux.ibm.com> wrote:
> > 
> > On Wed, Apr 14, 2021 at 02:44:07PM +0100, Marc Zyngier wrote:
> > > perf_pmu_name() and perf_num_counters() are unused. Drop them.
> > > 
> > > Signed-off-by: Marc Zyngier <maz@kernel.org>
> > > ---
> > >  arch/s390/kernel/perf_event.c | 21 ---------------------
> > >  1 file changed, 21 deletions(-)
> > 
> > Acked-by: Heiko Carstens <hca@linux.ibm.com>
> > 
> > ...or do you want me to pick this up and route via the s390 tree(?).
> 
> Either way work for me, but I just want to make sure the last patch
> doesn't get applied before the previous ones.

Ok, I applied this one to the s390 tree. Thanks!

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers
  2021-04-14 13:44 ` [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers Marc Zyngier
  2021-04-15  6:59   ` Keqian Zhu
@ 2021-04-22 10:43   ` Will Deacon
  1 sibling, 0 replies; 16+ messages in thread
From: Will Deacon @ 2021-04-22 10:43 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Mark Rutland, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

On Wed, Apr 14, 2021 at 02:44:05PM +0100, Marc Zyngier wrote:
> KVM/arm64 is the sole user of perf_num_counters(), and really
> could do without it. Stop using the obsolete API by relying on
> the existing probing code.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  arch/arm64/kvm/perf.c     | 7 +------
>  arch/arm64/kvm/pmu-emul.c | 2 +-
>  include/kvm/arm_pmu.h     | 4 ++++
>  3 files changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/arch/arm64/kvm/perf.c b/arch/arm64/kvm/perf.c
> index 739164324afe..b8b398670ef2 100644
> --- a/arch/arm64/kvm/perf.c
> +++ b/arch/arm64/kvm/perf.c
> @@ -50,12 +50,7 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
>  
>  int kvm_perf_init(void)
>  {
> -	/*
> -	 * Check if HW_PERF_EVENTS are supported by checking the number of
> -	 * hardware performance counters. This could ensure the presence of
> -	 * a physical PMU and CONFIG_PERF_EVENT is selected.
> -	 */
> -	if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0)
> +	if (kvm_pmu_probe_pmuver() != 0xf)

Took me a while to figure out that this returns 0xf if the hardware has a
PMUVer of 0x0, so it's all good:

Acked-by: Will Deacon <will@kernel.org>

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] arm64: Get rid of oprofile leftovers
  2021-04-14 13:44 ` [PATCH 2/5] arm64: Get rid of oprofile leftovers Marc Zyngier
@ 2021-04-22 10:45   ` Will Deacon
  0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2021-04-22 10:45 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Mark Rutland, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

On Wed, Apr 14, 2021 at 02:44:06PM +0100, Marc Zyngier wrote:
> perf_pmu_name() and perf_num_counters() are now unused. Drop them.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  drivers/perf/arm_pmu.c | 30 ------------------------------
>  1 file changed, 30 deletions(-)

Nice! This was some of the first code I ever wrote in the kernel but I can't
say I miss it:

Acked-by: Will Deacon <will@kernel.org>

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 5/5] perf: Get rid of oprofile leftovers
  2021-04-14 13:44 ` [PATCH 5/5] perf: " Marc Zyngier
@ 2021-04-22 10:47   ` Will Deacon
  0 siblings, 0 replies; 16+ messages in thread
From: Will Deacon @ 2021-04-22 10:47 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvm, kvmarm, linux-arm-kernel, linux-kernel, linux-s390,
	linux-sh, Mark Rutland, Rich Felker, Yoshinori Sato,
	Peter Zijlstra, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Heiko Carstens, nathan, Viresh Kumar, James Morse,
	Suzuki K Poulose, Alexandru Elisei, kernel-team

On Wed, Apr 14, 2021 at 02:44:09PM +0100, Marc Zyngier wrote:
> perf_pmu_name() and perf_num_counters() are unused. Drop them.
> 
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> ---
>  include/linux/perf_event.h | 2 --
>  kernel/events/core.c       | 5 -----
>  2 files changed, 7 deletions(-)

Acked-by: Will Deacon <will@kernel.org>

Will

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/5] perf: oprofile spring cleanup
  2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
                   ` (4 preceding siblings ...)
  2021-04-14 13:44 ` [PATCH 5/5] perf: " Marc Zyngier
@ 2021-04-22 12:48 ` Marc Zyngier
  5 siblings, 0 replies; 16+ messages in thread
From: Marc Zyngier @ 2021-04-22 12:48 UTC (permalink / raw)
  To: kvm, kvmarm, linux-sh, linux-s390, linux-kernel,
	linux-arm-kernel, Marc Zyngier
  Cc: Heiko Carstens, Arnaldo Carvalho de Melo, Christian Borntraeger,
	Mark Rutland, kernel-team, James Morse, nathan, Alexandru Elisei,
	Will Deacon, Suzuki K Poulose, Viresh Kumar, Rich Felker,
	Peter Zijlstra, Yoshinori Sato

On Wed, 14 Apr 2021 14:44:04 +0100, Marc Zyngier wrote:
> This small series builds on top of the work that was started with [1].
> 
> It recently became apparent that KVM/arm64 is the last bit of the
> kernel that still uses perf_num_counters().
> 
> As I went ahead to address this, it became obvious that all traces of
> oprofile had been eradicated from all architectures but arm64, s390
> and sh (plus a bit of cruft in the core perf code). With KVM fixed,
> perf_num_counters() and perf_pmu_name() are finally gone.
> 
> [...]

Applied to kvm-arm64/kill_oprofile_dependency, thanks!

[1/5] KVM: arm64: Divorce the perf code from oprofile helpers
      commit: 5421db1be3b11c5e469cce3760d5c8a013a90f2c
[2/5] arm64: Get rid of oprofile leftovers
      commit: e9c74a686a45e54b2e1c4586b14c84f3ee2f2014
[3/5] s390: Get rid of oprofile leftovers
      commit: 8c3f7913a106aa8b94d331cb59709c84a9a1d55b
[4/5] sh: Get rid of oprofile leftovers
      commit: ac21ecf5ad32b89909bee2b50161ce93d6462b7d
[5/5] perf: Get rid of oprofile leftovers
      commit: 7f318847a0f37b96d8927e8d30ae7b8f149b11f1

Cheers,

	M.
-- 
Without deviation from the norm, progress is not possible.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, back to index

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-14 13:44 [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier
2021-04-14 13:44 ` [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers Marc Zyngier
2021-04-15  6:59   ` Keqian Zhu
     [not found]     ` <87h7k7n81z.wl-maz@kernel.org>
2021-04-15 11:34       ` Keqian Zhu
2021-04-22 10:43   ` Will Deacon
2021-04-14 13:44 ` [PATCH 2/5] arm64: Get rid of oprofile leftovers Marc Zyngier
2021-04-22 10:45   ` Will Deacon
2021-04-14 13:44 ` [PATCH 3/5] s390: " Marc Zyngier
2021-04-15 10:38   ` Heiko Carstens
2021-04-15 10:47     ` Marc Zyngier
2021-04-15 12:12       ` Heiko Carstens
2021-04-14 13:44 ` [PATCH 4/5] sh: " Marc Zyngier
2021-04-14 19:09   ` Geert Uytterhoeven
2021-04-14 13:44 ` [PATCH 5/5] perf: " Marc Zyngier
2021-04-22 10:47   ` Will Deacon
2021-04-22 12:48 ` [PATCH 0/5] perf: oprofile spring cleanup Marc Zyngier

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org
	public-inbox-index kvm

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git