Re: [reboot] WARNING: CPU: 0 PID: 112 at kernel/events/core.c:5655 perf_swevent_add()

From: Fengguang Wu
Date: Sun Mar 30 2014 - 08:42:05 EST


This fix is not yet in linux-next, can anyone help merge it? Thanks!

On Tue, Mar 11, 2014 at 08:14:56PM +0800, Fengguang Wu wrote:
> Jiri,
>
> It works, thank you!
>
> Tested-by: Fengguang Wu <fengguang.wu@xxxxxxxxx>
>
> > ---
> > diff --git a/kernel/events/core.c b/kernel/events/core.c
> > index 661951a..a53857e 100644
> > --- a/kernel/events/core.c
> > +++ b/kernel/events/core.c
> > @@ -5423,6 +5423,8 @@ struct swevent_htable {
> >
> > /* Recursion avoidance in each contexts */
> > int recursion[PERF_NR_CONTEXTS];
> > +
> > + bool offline;
> > };
> >
> > static DEFINE_PER_CPU(struct swevent_htable, swevent_htable);
> > @@ -5669,8 +5671,10 @@ static int perf_swevent_add(struct perf_event *event, int flags)
> > hwc->state = !(flags & PERF_EF_START);
> >
> > head = find_swevent_head(swhash, event);
> > - if (WARN_ON_ONCE(!head))
> > + if (!head) {
> > + WARN_ON_ONCE(!swhash->offline);
> > return -EINVAL;
> > + }
> >
> > hlist_add_head_rcu(&event->hlist_entry, head);
> >
> > @@ -7850,6 +7854,7 @@ static void perf_event_init_cpu(int cpu)
> > struct swevent_htable *swhash = &per_cpu(swevent_htable, cpu);
> >
> > mutex_lock(&swhash->hlist_mutex);
> > + swhash->offline = false;
> > if (swhash->hlist_refcount > 0) {
> > struct swevent_hlist *hlist;
> >
> > @@ -7907,6 +7912,7 @@ static void perf_event_exit_cpu(int cpu)
> > perf_event_exit_cpu_context(cpu);
> >
> > mutex_lock(&swhash->hlist_mutex);
> > + swhash->offline = true;
> > swevent_hlist_release(swhash);
> > mutex_unlock(&swhash->hlist_mutex);
> > }
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/