Re: [PATCH tip/core/rcu 6/9] bpf/cgroup: Replace rcu_swap_protected() with rcu_replace()

From: Andrii Nakryiko
Date: Thu Oct 03 2019 - 13:25:47 EST


On Wed, Oct 2, 2019 at 6:45 PM <paulmck@xxxxxxxxxx> wrote:
>
> From: "Paul E. McKenney" <paulmck@xxxxxxxxxx>
>
> This commit replaces the use of rcu_swap_protected() with the more
> intuitively appealing rcu_replace() as a step towards removing
> rcu_swap_protected().
>
> Link: https://lore.kernel.org/lkml/CAHk-=wiAsJLw1egFEE=Z7-GGtM6wcvtyytXZA1+BHqta4gg6Hw@xxxxxxxxxxxxxx/
> Reported-by: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Signed-off-by: Paul E. McKenney <paulmck@xxxxxxxxxx>
> Cc: Alexei Starovoitov <ast@xxxxxxxxxx>
> Cc: Daniel Borkmann <daniel@xxxxxxxxxxxxx>
> Cc: Martin KaFai Lau <kafai@xxxxxx>
> Cc: Song Liu <songliubraving@xxxxxx>
> Cc: Yonghong Song <yhs@xxxxxx>
> Cc: <netdev@xxxxxxxxxxxxxxx>
> Cc: <bpf@xxxxxxxxxxxxxxx>
> ---

Acked-by: Andrii Nakryiko <andriin@xxxxxx>

> kernel/bpf/cgroup.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/kernel/bpf/cgroup.c b/kernel/bpf/cgroup.c
> index ddd8add..06a0657 100644
> --- a/kernel/bpf/cgroup.c
> +++ b/kernel/bpf/cgroup.c
> @@ -180,8 +180,8 @@ static void activate_effective_progs(struct cgroup *cgrp,
> enum bpf_attach_type type,
> struct bpf_prog_array *old_array)
> {
> - rcu_swap_protected(cgrp->bpf.effective[type], old_array,
> - lockdep_is_held(&cgroup_mutex));
> + old_array = rcu_replace(cgrp->bpf.effective[type], old_array,
> + lockdep_is_held(&cgroup_mutex));
> /* free prog array after grace period, since __cgroup_bpf_run_*()
> * might be still walking the array
> */
> --
> 2.9.5
>