Re: [PATCH v6] perf: Sharing PMU counters across compatible events

Peter Zijlstra
2019-11-06T08:56:29Z

On Tue, Nov 05, 2019 at 11:51:42PM +0000, Song Liu wrote:

> > We allocate a separate perf_event for perf_event_dup->master. This needs
> > extra attention, because perf_event_alloc() may sleep. To allocate the
> > master event properly, a new pointer, tmp_master, is added to perf_event.
> > tmp_master carries a separate perf_event into list_[add|del]_event().
> > The master event has valid ->ctx and holds ctx->refcount.
>
> If we do GFP_ATOMIC in perf_event_alloc(), maybe with an extra option, we
> don't need the tmp_master hack. So we only allocate master when we will
> use it.

You can't, that's broken on -RT. ctx->lock is a raw_spinlock_t and
allocator locks are spinlock_t.