Re: [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem

From: Ingo Molnar
Date: Wed Apr 24 2019 - 06:32:03 EST



* Oleg Nesterov <oleg@xxxxxxxxxx> wrote:

> Turn DEFINE_STATIC_PERCPU_RWSEM() into __DEFINE_PERCPU_RWSEM() with the
> additional "is_static" argument to introduce DEFINE_PERCPU_RWSEM().
>
> Change cgroup.c to use DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem).
>
> Signed-off-by: Oleg Nesterov <oleg@xxxxxxxxxx>
> ---
> include/linux/percpu-rwsem.h | 8 ++++++--
> kernel/cgroup/cgroup.c | 3 +--
> 2 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/include/linux/percpu-rwsem.h b/include/linux/percpu-rwsem.h
> index 6887636..2809b44 100644
> --- a/include/linux/percpu-rwsem.h
> +++ b/include/linux/percpu-rwsem.h
> @@ -17,14 +17,18 @@ struct percpu_rw_semaphore {
> int readers_block;
> };
>
> -#define DEFINE_STATIC_PERCPU_RWSEM(name) \
> +#define __DEFINE_PERCPU_RWSEM(name, is_static) \
> static DEFINE_PER_CPU(unsigned int, __percpu_rwsem_rc_##name); \
> -static struct percpu_rw_semaphore name = { \
> +is_static struct percpu_rw_semaphore name = { \
> .rss = __RCU_SYNC_INITIALIZER(name.rss), \
> .read_count = &__percpu_rwsem_rc_##name, \
> .rw_sem = __RWSEM_INITIALIZER(name.rw_sem), \
> .writer = __RCUWAIT_INITIALIZER(name.writer), \
> }
> +#define DEFINE_PERCPU_RWSEM(name) \
> + __DEFINE_PERCPU_RWSEM(name, /* not static */)
> +#define DEFINE_STATIC_PERCPU_RWSEM(name) \
> + __DEFINE_PERCPU_RWSEM(name, static)

Which tree is this against? It doesn't apply to tip:master nor latest
-git.

Thanks,

Ingo