Re: [GIT PULL] SafeSetID LSM changes for 5.4

From: Paul E. McKenney
Date: Mon Oct 21 2019 - 22:13:11 EST


On Mon, Oct 21, 2019 at 08:58:11AM +0200, Ingo Molnar wrote:
>
> * Paul E. McKenney <paulmck@xxxxxxxxxx> wrote:
>
> > --- a/include/linux/rcupdate.h
> > +++ b/include/linux/rcupdate.h
> > @@ -383,20 +383,22 @@ do { \
> > } while (0)
> >
> > /**
> > - * rcu_swap_protected() - swap an RCU and a regular pointer
> > - * @rcu_ptr: RCU pointer
> > + * rcu_replace() - replace an RCU pointer, returning its old value
> > + * @rcu_ptr: RCU pointer, whose old value is returned
> > * @ptr: regular pointer
> > - * @c: the conditions under which the dereference will take place
> > + * @c: the lockdep conditions under which the dereference will take place
> > *
> > - * Perform swap(@rcu_ptr, @ptr) where @rcu_ptr is an RCU-annotated pointer and
> > - * @c is the argument that is passed to the rcu_dereference_protected() call
> > - * used to read that pointer.
> > + * Perform a replacement, where @rcu_ptr is an RCU-annotated
> > + * pointer and @c is the lockdep argument that is passed to the
> > + * rcu_dereference_protected() call used to read that pointer. The old
> > + * value of @rcu_ptr is returned, and @rcu_ptr is set to @ptr.
> > */
> > -#define rcu_swap_protected(rcu_ptr, ptr, c) do { \
> > +#define rcu_replace(rcu_ptr, ptr, c) \
> > +({ \
> > typeof(ptr) __tmp = rcu_dereference_protected((rcu_ptr), (c)); \
> > rcu_assign_pointer((rcu_ptr), (ptr)); \
> > - (ptr) = __tmp; \
> > -} while (0)
> > + __tmp; \
> > +})
>
> One small suggestion, would it make sense to name it "rcu_replace_pointer()"?
>
> This would make it fit into the pointer handling family of RCU functions:
> rcu_assign_pointer(), rcu_access_pointer(), RCU_INIT_POINTER() et al?

Easy enough to make the change. I will do that tomorrow and test over
the following night.

> rcu_swap() would also look a bit weird if used in MM code. ;-)

How much RCU swap should we configure on this system? About same amount
as reader-writer swap! ;-)

Thanx, Paul