Re: [PATCH] perf/x86/intel: Export mem events only if there's PEBs support

From: Jiri Olsa
Date: Tue Aug 28 2018 - 04:19:16 EST


On Tue, Aug 28, 2018 at 10:12:32AM +0200, Peter Zijlstra wrote:
> On Mon, Aug 27, 2018 at 11:06:24AM +0200, Jiri Olsa wrote:
> > +static __init struct attribute **get_hsw_events_attrs(bool *alloc)
> > {
> > + if (boot_cpu_has(X86_FEATURE_RTM)) {
> > + *alloc = true;
> > + return merge_attr(hsw_events_attrs, hsw_tsx_events_attrs);
> > + }
> > + return hsw_events_attrs;
> > }
>
>
>
> > @@ -4357,6 +4374,15 @@ __init int intel_pmu_init(void)
> > WARN_ON(!x86_pmu.format_attrs);
> > }
> >
> > + if (x86_pmu.pebs && mem_attr) {
> > + struct attribute **attr = x86_pmu.cpu_events;
> > +
> > + x86_pmu.cpu_events = merge_attr(x86_pmu.cpu_events, mem_attr);
> > +
> > + if (alloc_events)
> > + kfree(attr);
> > + }
> > +
> > if (x86_pmu.num_counters > INTEL_PMC_MAX_GENERIC) {
> > WARN(1, KERN_ERR "hw perf events %d > max(%d), clipping!",
> > x86_pmu.num_counters, INTEL_PMC_MAX_GENERIC);
>
>
> static __init struct attribute **
> get_events_attrs(struct attribute **base,
> struct attribute **mem,
> struct attribute **tsx)
> {
> struct attribute **attrs = base;
> struct attribute **old;
>
> if (mem) {
> old = attrs;
> attrs = merge_attrs(attrs, mem);
> if (old != base)
> kfree(old);
> }
>
> if (tsx && boot_cpu_has(X86_FEATURE_RTM)) {
> old = attrs;
> attrs = merge_attrs(attrs, tsx);
> if (old != base)
> kfree(old);
> }
>
> return attrs;
> }
>
> Would that not help to concentrate things a little more?

looks like it would ;-) will check and repost

thanks,
jirka