Skip to content

Commit 2934e3d

Browse files
sean-jcPeter Zijlstra
authored andcommitted
perf: Stop pretending that perf can handle multiple guest callbacks
Drop the 'int' return value from the perf (un)register callbacks helpers and stop pretending perf can support multiple callbacks. The 'int' returns are not future proofing anything as none of the callers take action on an error. It's also not obvious that there will ever be co-tenant hypervisors, and if there are, that allowing multiple callbacks to be registered is desirable or even correct. Opportunistically rename callbacks=>cbs in the affected declarations to match their definitions. No functional change intended. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Reviewed-by: Paolo Bonzini <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent f4b027c commit 2934e3d

File tree

4 files changed

+16
-23
lines changed

4 files changed

+16
-23
lines changed

arch/arm64/include/asm/kvm_host.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,8 @@ unsigned long kvm_mmio_read_buf(const void *buf, unsigned int len);
675675
int kvm_handle_mmio_return(struct kvm_vcpu *vcpu);
676676
int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa);
677677

678-
int kvm_perf_init(void);
679-
int kvm_perf_teardown(void);
678+
void kvm_perf_init(void);
679+
void kvm_perf_teardown(void);
680680

681681
long kvm_hypercall_pv_features(struct kvm_vcpu *vcpu);
682682
gpa_t kvm_init_stolen_time(struct kvm_vcpu *vcpu);

arch/arm64/kvm/perf.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ static struct perf_guest_info_callbacks kvm_guest_cbs = {
4848
.get_guest_ip = kvm_get_guest_ip,
4949
};
5050

51-
int kvm_perf_init(void)
51+
void kvm_perf_init(void)
5252
{
53-
return perf_register_guest_info_callbacks(&kvm_guest_cbs);
53+
perf_register_guest_info_callbacks(&kvm_guest_cbs);
5454
}
5555

56-
int kvm_perf_teardown(void)
56+
void kvm_perf_teardown(void)
5757
{
58-
return perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
58+
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
5959
}

include/linux/perf_event.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,8 +1252,8 @@ static inline struct perf_guest_info_callbacks *perf_get_guest_cbs(void)
12521252
*/
12531253
return rcu_dereference(perf_guest_cbs);
12541254
}
1255-
extern int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
1256-
extern int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *callbacks);
1255+
extern void perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs);
1256+
extern void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs);
12571257

12581258
extern void perf_event_exec(void);
12591259
extern void perf_event_comm(struct task_struct *tsk, bool exec);
@@ -1497,10 +1497,10 @@ perf_sw_event(u32 event_id, u64 nr, struct pt_regs *regs, u64 addr) { }
14971497
static inline void
14981498
perf_bp_event(struct perf_event *event, void *data) { }
14991499

1500-
static inline int perf_register_guest_info_callbacks
1501-
(struct perf_guest_info_callbacks *callbacks) { return 0; }
1502-
static inline int perf_unregister_guest_info_callbacks
1503-
(struct perf_guest_info_callbacks *callbacks) { return 0; }
1500+
static inline void perf_register_guest_info_callbacks
1501+
(struct perf_guest_info_callbacks *cbs) { }
1502+
static inline void perf_unregister_guest_info_callbacks
1503+
(struct perf_guest_info_callbacks *cbs) { }
15041504

15051505
static inline void perf_event_mmap(struct vm_area_struct *vma) { }
15061506

kernel/events/core.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6521,31 +6521,24 @@ static void perf_pending_event(struct irq_work *entry)
65216521
perf_swevent_put_recursion_context(rctx);
65226522
}
65236523

6524-
/*
6525-
* We assume there is only KVM supporting the callbacks.
6526-
* Later on, we might change it to a list if there is
6527-
* another virtualization implementation supporting the callbacks.
6528-
*/
65296524
struct perf_guest_info_callbacks __rcu *perf_guest_cbs;
65306525

6531-
int perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
6526+
void perf_register_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
65326527
{
65336528
if (WARN_ON_ONCE(rcu_access_pointer(perf_guest_cbs)))
6534-
return -EBUSY;
6529+
return;
65356530

65366531
rcu_assign_pointer(perf_guest_cbs, cbs);
6537-
return 0;
65386532
}
65396533
EXPORT_SYMBOL_GPL(perf_register_guest_info_callbacks);
65406534

6541-
int perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
6535+
void perf_unregister_guest_info_callbacks(struct perf_guest_info_callbacks *cbs)
65426536
{
65436537
if (WARN_ON_ONCE(rcu_access_pointer(perf_guest_cbs) != cbs))
6544-
return -EINVAL;
6538+
return;
65456539

65466540
rcu_assign_pointer(perf_guest_cbs, NULL);
65476541
synchronize_rcu();
6548-
return 0;
65496542
}
65506543
EXPORT_SYMBOL_GPL(perf_unregister_guest_info_callbacks);
65516544

0 commit comments

Comments
 (0)