> 
> Where was the cpus_read lock taken?

I am pretty sure that's leftover of when I was reading some CPU mask :-(

> 
> > +   cpus_read_unlock();
> > +
> > +   return ERR_PTR(ret);
> > +}
> > +

[...]

> > +static ssize_t
> > +write_event_write(struct file *filp, const char __user *ubuf, size_t cnt, 
> > loff_t *pos)
> > +{
> > +   struct remote_event_format_selftest *evt_test;
> > +   struct simple_rb_per_cpu *cpu_buffer;
> > +   unsigned long val;
> > +   int ret;
> > +
> > +   ret = kstrtoul_from_user(ubuf, cnt, 10, &val);
> > +   if (ret)
> > +           return ret;
> > +
> > +   guard(mutex)(&simple_rbs_lock);
> > +
> > +   if (!remote_event_selftest.enabled)
> > +           return -ENODEV;
> > +
> 
> You want a guard(preempt)(); here...
> 
> > +   cpu_buffer = *this_cpu_ptr(&simple_rbs);
> 
> Otherwise this triggers:
> 
>  BUG: using smp_processor_id() in preemptible [00000000] code: bash/1096
>  caller is write_event_write+0xe0/0x230 [remote_test]
> 
> -- Steve

Ha, of course! And also for a per-CPU ring-buffer, that is way better to make
sure we actually do all the writing from the same CPU even though in that case
the simple_rbs_lock protect us.

> 
> > +   if (!cpu_buffer)
> > +           return -ENODEV;
> > +
> > +   evt_test = simple_ring_buffer_reserve(cpu_buffer,
> > +                                         sizeof(struct 
> > remote_event_format_selftest),
> > +                                         trace_clock_global());
> > +   if (!evt_test)
> > +           return -ENODEV;
> > +
> > +   evt_test->hdr.id = REMOTE_TEST_EVENT_ID;
> > +   evt_test->id = val;
> > +
> > +   simple_ring_buffer_commit(cpu_buffer);
> > +
> > +   return cnt;
> > +}
> > +

Reply via email to