Re: [PATCH v5 4/5] sched/core: Prevent race condition between cpuset and __sched_setscheduler()

From: Juri Lelli
Date: Thu Oct 04 2018 - 05:04:11 EST


On 03/10/18 15:42, Steven Rostedt wrote:
> On Mon, 3 Sep 2018 16:28:00 +0200
> Juri Lelli <juri.lelli@xxxxxxxxxx> wrote:
>
>
> > diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c
> > index 5b43f482fa0f..8dc26005bb1e 100644
> > --- a/kernel/cgroup/cpuset.c
> > +++ b/kernel/cgroup/cpuset.c
> > @@ -2410,6 +2410,24 @@ void __init cpuset_init_smp(void)
> > BUG_ON(!cpuset_migrate_mm_wq);
> > }
> >
> > +/**
> > + * cpuset_read_only_lock - Grab the callback_lock from another subsysytem
> > + *
> > + * Description: Gives the holder read-only access to cpusets.
> > + */
> > +void cpuset_read_only_lock(void)
> > +{
> > + raw_spin_lock(&callback_lock);
>
> This was confusing to figure out why grabbing a spinlock gives read
> only access. So I read the long comment above the definition of
> callback_lock. A couple of notes.
>
> 1) The above description needs to go into more detail as to why
> grabbing a spinlock is "read only".
>
> 2) The comment above the callback_lock needs to incorporate this, as
> reading that comment alone will not give anyone an idea that this
> exists.

Right, does the updated version below look any better?

Thanks for reviewing!

Best,

- Juri

--->8---