[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191021065811.GA17098@gmail.com>
Date: Mon, 21 Oct 2019 08:58:11 +0200
From: Ingo Molnar <mingo@...nel.org>
To: "Paul E. McKenney" <paulmck@...nel.org>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Micah Morton <mortonm@...omium.org>,
Jann Horn <jannh@...gle.com>,
Bart Van Assche <bart.vanassche@....com>,
Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
linux-security-module <linux-security-module@...r.kernel.org>
Subject: Re: [GIT PULL] SafeSetID LSM changes for 5.4
* Paul E. McKenney <paulmck@...nel.org> 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?
rcu_swap() would also look a bit weird if used in MM code. ;-)
Thanks,
Ingo
Powered by blists - more mailing lists