Re: [PATCH V2 13/23] perf/x86/intel/lbr: Factor out intel_pmu_store_lbr
From: Peter Zijlstra
Date: Tue Jun 30 2020 - 11:44:03 EST
On Fri, Jun 26, 2020 at 11:20:10AM -0700, kan.liang@xxxxxxxxxxxxxxx wrote:
> -static inline u64 rdlbr_from(unsigned int idx)
> +static inline u64 rdlbr_from(unsigned int idx, struct lbr_entry *lbr)
> {
> u64 val;
>
> + if (lbr)
> + return lbr->from;
> +
> rdmsrl(x86_pmu.lbr_from + idx, val);
>
> return lbr_from_signext_quirk_rd(val);
> }
>
> -static inline u64 rdlbr_to(unsigned int idx)
> +static inline u64 rdlbr_to(unsigned int idx, struct lbr_entry *lbr)
> {
> u64 val;
>
> + if (lbr)
> + return lbr->to;
> +
> rdmsrl(x86_pmu.lbr_to + idx, val);
>
> return val;
> }
>
> -static inline u64 rdlbr_info(unsigned int idx)
> +static inline u64 rdlbr_info(unsigned int idx, struct lbr_entry *lbr)
> {
> u64 val;
>
> + if (lbr)
> + return lbr->info;
> +
> rdmsrl(x86_pmu.lbr_info + idx, val);
>
> return val;
These should probably be __always_inline, just to make sure the compiler
doesn't do anything stupid.