Unified · Split
| @@ -50,13 +50,7 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = { · 49 unmodified lines | |||
| 50 | 50 | ||
| 51 | int kvm_perf_init(void) | 51 | int kvm_perf_init(void) |
| 52 | { | 52 | { |
| 53 | /* | 53 | if (kvm_pmu_probe_pmuver() != 0xf && !is_protected_kvm_enabled()) |
| 54 | * Check if HW_PERF_EVENTS are supported by checking the number of | ||
| 55 | * hardware performance counters. This could ensure the presence of | ||
| 56 | * a physical PMU and CONFIG_PERF_EVENT is selected. | ||
| 57 | */ | ||
| 58 | if (IS_ENABLED(CONFIG_ARM_PMU) && perf_num_counters() > 0 | ||
| 59 | && !is_protected_kvm_enabled()) | ||
| 60 | static_branch_enable(&kvm_arm_pmu_available); | 54 | static_branch_enable(&kvm_arm_pmu_available); |
| 61 | 55 | ||
| 62 | return perf_register_guest_info_callbacks(&kvm_guest_cbs); | 56 | return perf_register_guest_info_callbacks(&kvm_guest_cbs); |
| @@ -739,7 +739,7 @@ void kvm_pmu_set_counter_event_type(struct kvm_vcpu *vcpu, u64 data, · 738 unmodified lines | |||
| 739 | kvm_pmu_create_perf_event(vcpu, select_idx); | 739 | kvm_pmu_create_perf_event(vcpu, select_idx); |
| 740 | } | 740 | } |
| 741 | 741 | ||
| 742 | static int kvm_pmu_probe_pmuver(void) | 742 | int kvm_pmu_probe_pmuver(void) |
| 743 | { | 743 | { |
| 744 | struct perf_event_attr attr = { }; | 744 | struct perf_event_attr attr = { }; |
| 745 | struct perf_event *event; | 745 | struct perf_event *event; |
| @@ -23,27 +23,6 @@ · 22 unmodified lines | |||
| 23 | #include <asm/sysinfo.h> | 23 | #include <asm/sysinfo.h> |
| 24 | #include <asm/unwind.h> | 24 | #include <asm/unwind.h> |
| 25 | 25 | ||
| 26 | const char *perf_pmu_name(void) | ||
| 27 | { | ||
| 28 | if (cpum_cf_avail() || cpum_sf_avail()) | ||
| 29 | return "CPU-Measurement Facilities (CPU-MF)"; | ||
| 30 | return "pmu"; | ||
| 31 | } | ||
| 32 | EXPORT_SYMBOL(perf_pmu_name); | ||
| 33 | |||
| 34 | int perf_num_counters(void) | ||
| 35 | { | ||
| 36 | int num = 0; | ||
| 37 | |||
| 38 | if (cpum_cf_avail()) | ||
| 39 | num += PERF_CPUM_CF_MAX_CTR; | ||
| 40 | if (cpum_sf_avail()) | ||
| 41 | num += PERF_CPUM_SF_MAX_CTR; | ||
| 42 | |||
| 43 | return num; | ||
| 44 | } | ||
| 45 | EXPORT_SYMBOL(perf_num_counters); | ||
| 46 | |||
| 47 | static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs) | 26 | static struct kvm_s390_sie_block *sie_block(struct pt_regs *regs) |
| 48 | { | 27 | { |
| 49 | struct stack_frame *stack = (struct stack_frame *) regs->gprs[15]; | 28 | struct stack_frame *stack = (struct stack_frame *) regs->gprs[15]; |
| @@ -57,24 +57,6 @@ static inline int sh_pmu_initialized(void) · 56 unmodified lines | |||
| 57 | return !!sh_pmu; | 57 | return !!sh_pmu; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | const char *perf_pmu_name(void) | ||
| 61 | { | ||
| 62 | if (!sh_pmu) | ||
| 63 | return NULL; | ||
| 64 | |||
| 65 | return sh_pmu->name; | ||
| 66 | } | ||
| 67 | EXPORT_SYMBOL_GPL(perf_pmu_name); | ||
| 68 | |||
| 69 | int perf_num_counters(void) | ||
| 70 | { | ||
| 71 | if (!sh_pmu) | ||
| 72 | return 0; | ||
| 73 | |||
| 74 | return sh_pmu->num_events; | ||
| 75 | } | ||
| 76 | EXPORT_SYMBOL_GPL(perf_num_counters); | ||
| 77 | |||
| 78 | /* | 60 | /* |
| 79 | * Release the PMU if this is the last perf_event. | 61 | * Release the PMU if this is the last perf_event. |
| 80 | */ | 62 | */ |
| @@ -581,33 +581,6 @@ static const struct attribute_group armpmu_common_attr_group = { · 580 unmodified lines | |||
| 581 | .attrs = armpmu_common_attrs, | 581 | .attrs = armpmu_common_attrs, |
| 582 | }; | 582 | }; |
| 583 | 583 | ||
| 584 | /* Set at runtime when we know what CPU type we are. */ | ||
| 585 | static struct arm_pmu *__oprofile_cpu_pmu; | ||
| 586 | |||
| 587 | /* | ||
| 588 | * Despite the names, these two functions are CPU-specific and are used | ||
| 589 | * by the OProfile/perf code. | ||
| 590 | */ | ||
| 591 | const char *perf_pmu_name(void) | ||
| 592 | { | ||
| 593 | if (!__oprofile_cpu_pmu) | ||
| 594 | return NULL; | ||
| 595 | |||
| 596 | return __oprofile_cpu_pmu->name; | ||
| 597 | } | ||
| 598 | EXPORT_SYMBOL_GPL(perf_pmu_name); | ||
| 599 | |||
| 600 | int perf_num_counters(void) | ||
| 601 | { | ||
| 602 | int max_events = 0; | ||
| 603 | |||
| 604 | if (__oprofile_cpu_pmu != NULL) | ||
| 605 | max_events = __oprofile_cpu_pmu->num_events; | ||
| 606 | |||
| 607 | return max_events; | ||
| 608 | } | ||
| 609 | EXPORT_SYMBOL_GPL(perf_num_counters); | ||
| 610 | |||
| 611 | static int armpmu_count_irq_users(const int irq) | 584 | static int armpmu_count_irq_users(const int irq) |
| 612 | { | 585 | { |
| 613 | int cpu, count = 0; | 586 | int cpu, count = 0; |
| @@ -979,9 +952,6 @@ int armpmu_register(struct arm_pmu *pmu) · 365 unmodified lines | |||
| 979 | if (ret) | 952 | if (ret) |
| 980 | goto out_destroy; | 953 | goto out_destroy; |
| 981 | 954 | ||
| 982 | if (!__oprofile_cpu_pmu) | ||
| 983 | __oprofile_cpu_pmu = pmu; | ||
| 984 | |||
| 985 | pr_info("enabled with %s PMU driver, %d counters available%s\n", | 955 | pr_info("enabled with %s PMU driver, %d counters available%s\n", |
| 986 | pmu->name, pmu->num_events, | 956 | pmu->name, pmu->num_events, |
| 987 | has_nmi ? ", using NMIs" : ""); | 957 | has_nmi ? ", using NMIs" : ""); |
| @@ -61,6 +61,7 @@ int kvm_arm_pmu_v3_get_attr(struct kvm_vcpu *vcpu, · 60 unmodified lines | |||
| 61 | int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu, | 61 | int kvm_arm_pmu_v3_has_attr(struct kvm_vcpu *vcpu, |
| 62 | struct kvm_device_attr *attr); | 62 | struct kvm_device_attr *attr); |
| 63 | int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu); | 63 | int kvm_arm_pmu_v3_enable(struct kvm_vcpu *vcpu); |
| 64 | int kvm_pmu_probe_pmuver(void); | ||
| 64 | #else | 65 | #else |
| 65 | struct kvm_pmu { | 66 | struct kvm_pmu { |
| 66 | }; | 67 | }; |
| @@ -116,6 +117,9 @@ static inline u64 kvm_pmu_get_pmceid(struct kvm_vcpu *vcpu, bool pmceid1) · 49 unmodified lines | |||
| 116 | { | 117 | { |
| 117 | return 0; | 118 | return 0; |
| 118 | } | 119 | } |
| 120 | |||
| 121 | static inline int kvm_pmu_probe_pmuver(void) { return 0xf; } | ||
| 122 | |||
| 119 | #endif | 123 | #endif |
| 120 | 124 | ||
| 121 | #endif | 125 | #endif |
| @@ -951,8 +951,6 @@ extern void perf_event_itrace_started(struct perf_event *event); · 950 unmodified lines | |||
| 951 | extern int perf_pmu_register(struct pmu *pmu, const char *name, int type); | 951 | extern int perf_pmu_register(struct pmu *pmu, const char *name, int type); |
| 952 | extern void perf_pmu_unregister(struct pmu *pmu); | 952 | extern void perf_pmu_unregister(struct pmu *pmu); |
| 953 | 953 | ||
| 954 | extern int perf_num_counters(void); | ||
| 955 | extern const char *perf_pmu_name(void); | ||
| 956 | extern void __perf_event_task_sched_in(struct task_struct *prev, | 954 | extern void __perf_event_task_sched_in(struct task_struct *prev, |
| 957 | struct task_struct *task); | 955 | struct task_struct *task); |
| 958 | extern void __perf_event_task_sched_out(struct task_struct *prev, | 956 | extern void __perf_event_task_sched_out(struct task_struct *prev, |
| @@ -580,11 +580,6 @@ static u64 perf_event_time(struct perf_event *event); · 579 unmodified lines | |||
| 580 | 580 | ||
| 581 | void __weak perf_event_print_debug(void) { } | 581 | void __weak perf_event_print_debug(void) { } |
| 582 | 582 | ||
| 583 | extern __weak const char *perf_pmu_name(void) | ||
| 584 | { | ||
| 585 | return "pmu"; | ||
| 586 | } | ||
| 587 | |||
| 588 | static inline u64 perf_clock(void) | 583 | static inline u64 perf_clock(void) |
| 589 | { | 584 | { |
| 590 | return local_clock(); | 585 | return local_clock(); |