Re: [PATCH v5 4/5] sched/core: Prevent race condition between cpuset and __sched_setscheduler()
From: Juri Lelli
Date: Thu Nov 08 2018 - 11:23:57 EST
Hi,
On 08/11/18 10:49, Waiman Long wrote:
> On 10/04/2018 05:04 AM, Juri Lelli wrote:
[...]
> > +/**
> > + * cpuset_read_only_lock - Grab the callback_lock from cpuset subsystem.
> > + *
> > + * Description: As described in full details the comment above cpuset_mutex
> > + * and callback_lock definitions, holding callback_lock gives the holder
> > + * read-only access to cpusets. Even though it might look counter-intuitive
> > + * (as callback_lock is a spinlock), in fact a task must hold both
> > + * callback_lock _and_ cpuset_mutex to modify cpusets (write access).
> > + */
> > +void cpuset_read_only_lock(void)
> > +{
> > + raw_spin_lock(&callback_lock);
> > +}
> > +
> > +/**
> > + * cpuset_read_only_unlock - Release the callback_lock from cpuset subsystem.
> > + */
> > +void cpuset_read_only_unlock(void)
> > +{
> > + raw_spin_unlock(&callback_lock);
> > +}
> > +
>
> Maybe you can drop the "_only" part to be consistent with the rwlock
> APIs (read_lock/write_lock).
I called it this way because it looked more descriptive of which kind of
guarantee the holder gets using these. Can change of course, what others
think?
Thanks for reviewing!
Best,
- Juri