Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b3d9468a authored by Gleb Natapov's avatar Gleb Natapov Committed by Ingo Molnar
Browse files

perf, x86: Expose perf capability to other modules



KVM needs to know perf capability to decide which PMU it can expose to a
guest.

Signed-off-by: default avatarGleb Natapov <gleb@redhat.com>
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1320929850-10480-8-git-send-email-gleb@redhat.com


Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent c1d6f42f
Loading
Loading
Loading
Loading
+15 −0
Original line number Original line Diff line number Diff line
@@ -95,6 +95,15 @@ union cpuid10_edx {
	unsigned int full;
	unsigned int full;
};
};


struct x86_pmu_capability {
	int		version;
	int		num_counters_gp;
	int		num_counters_fixed;
	int		bit_width_gp;
	int		bit_width_fixed;
	unsigned int	events_mask;
	int		events_mask_len;
};


/*
/*
 * Fixed-purpose performance events:
 * Fixed-purpose performance events:
@@ -216,6 +225,7 @@ struct perf_guest_switch_msr {
};
};


extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
extern struct perf_guest_switch_msr *perf_guest_get_msrs(int *nr);
extern void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap);
#else
#else
static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
{
{
@@ -223,6 +233,11 @@ static inline perf_guest_switch_msr *perf_guest_get_msrs(int *nr)
	return NULL;
	return NULL;
}
}


static inline void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
{
	memset(cap, 0, sizeof(*cap));
}

static inline void perf_events_lapic_init(void)	{ }
static inline void perf_events_lapic_init(void)	{ }
#endif
#endif


+12 −0
Original line number Original line Diff line number Diff line
@@ -1696,3 +1696,15 @@ unsigned long perf_misc_flags(struct pt_regs *regs)


	return misc;
	return misc;
}
}

void perf_get_x86_pmu_capability(struct x86_pmu_capability *cap)
{
	cap->version		= x86_pmu.version;
	cap->num_counters_gp	= x86_pmu.num_counters;
	cap->num_counters_fixed	= x86_pmu.num_counters_fixed;
	cap->bit_width_gp	= x86_pmu.cntval_bits;
	cap->bit_width_fixed	= x86_pmu.cntval_bits;
	cap->events_mask	= (unsigned int)x86_pmu.events_maskl;
	cap->events_mask_len	= x86_pmu.events_mask_len;
}
EXPORT_SYMBOL_GPL(perf_get_x86_pmu_capability);