On Tue, Aug 04, 2015 at 08:58:15AM +0000, Kaixu Xia wrote: > diff --git a/kernel/events/core.c b/kernel/events/core.c > index 6251b53..726ca1b 100644 > --- a/kernel/events/core.c > +++ b/kernel/events/core.c > @@ -8599,6 +8599,25 @@ struct perf_event_attr *perf_event_attrs(struct > perf_event *event) > return &event->attr; > } > > +u64 perf_event_read_internal(struct perf_event *event)
Maybe: perf_event_read_local(), as this is this function only works for events active on the current CPU. > +{ > + if (!event) > + return -EINVAL; > + > + if (unlikely(event->state != PERF_EVENT_STATE_ACTIVE)) > + return -EINVAL; You can return perf_event_count() in that case. > + > + if (event->oncpu != raw_smp_processor_id() && That _must_ be smp_processor_id(). If that gives a warning (ie. preemption is not disabled or we're not affine to this one cpu) then the warning is valid. > + event->ctx->task != current) Write it like: if (event->ctx->task != current && event->oncpu != smp_processor_id()) That way you'll not evaluate smp_processor_id() for current task events. > + return -EINVAL; > + > + if (unlikely(event->attr.inherit)) > + return -EINVAL; This should be in your accept function, inherited events should never get this far. You need IRQs disabled while calling __perf_event_read(), did you test with lockdep enabled? > + __perf_event_read(event); > + return perf_event_count(event); > +} Also, you probably want a WARN_ON(in_nmi()) there, this function is _NOT_ NMI safe. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/