* [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem
@ 2019-04-23 16:32 Oleg Nesterov
2019-04-24 10:31 ` Ingo Molnar
0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2019-04-23 16:32 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Paul E. McKenney, Peter Zijlstra, Tejun Heo, linux-kernel
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@redhat.com>
---
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)
extern int __percpu_down_read(struct percpu_rw_semaphore *, int);
extern void __percpu_up_read(struct percpu_rw_semaphore *);
diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index 3f2b4bd..2510017 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -101,7 +101,7 @@ static DEFINE_SPINLOCK(cgroup_idr_lock);
*/
static DEFINE_SPINLOCK(cgroup_file_kn_lock);
-struct percpu_rw_semaphore cgroup_threadgroup_rwsem;
+DEFINE_PERCPU_RWSEM(cgroup_threadgroup_rwsem);
#define cgroup_assert_mutex_or_rcu_locked() \
RCU_LOCKDEP_WARN(!rcu_read_lock_held() && \
@@ -5432,7 +5432,6 @@ int __init cgroup_init(void)
int ssid;
BUILD_BUG_ON(CGROUP_SUBSYS_COUNT > 16);
- BUG_ON(percpu_init_rwsem(&cgroup_threadgroup_rwsem));
BUG_ON(cgroup_init_cftypes(NULL, cgroup_base_files));
BUG_ON(cgroup_init_cftypes(NULL, cgroup1_base_files));
--
2.5.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem
2019-04-23 16:32 [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem Oleg Nesterov
@ 2019-04-24 10:31 ` Ingo Molnar
2019-04-24 11:00 ` Oleg Nesterov
0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2019-04-24 10:31 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Paul E. McKenney, Peter Zijlstra, Tejun Heo, linux-kernel
* Oleg Nesterov <oleg@redhat.com> 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@redhat.com>
> ---
> 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem
2019-04-24 10:31 ` Ingo Molnar
@ 2019-04-24 11:00 ` Oleg Nesterov
2019-04-24 11:02 ` Ingo Molnar
0 siblings, 1 reply; 5+ messages in thread
From: Oleg Nesterov @ 2019-04-24 11:00 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Paul E. McKenney, Peter Zijlstra, Tejun Heo, linux-kernel
On 04/24, Ingo Molnar wrote:
>
> > -#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
OOPS, sorry Ingo!
I forgot that the change above depends on another cleanup I sent to Paul,
[PATCH] rcu/sync: kill rcu_sync_type/gp_type
https://lore.kernel.org/lkml/20190423120724.GA6132@redhat.com/
which does
- .rss = __RCU_SYNC_INITIALIZER(name.rss, RCU_SCHED_SYNC), \
+ .rss = __RCU_SYNC_INITIALIZER(name.rss), \
so lets forget it for now, or may be Paul can take this patch too.
Sorry,
Oleg.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem
2019-04-24 11:00 ` Oleg Nesterov
@ 2019-04-24 11:02 ` Ingo Molnar
2019-04-24 18:34 ` Paul E. McKenney
0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2019-04-24 11:02 UTC (permalink / raw)
To: Oleg Nesterov; +Cc: Paul E. McKenney, Peter Zijlstra, Tejun Heo, linux-kernel
* Oleg Nesterov <oleg@redhat.com> wrote:
> On 04/24, Ingo Molnar wrote:
> >
> > > -#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
>
> OOPS, sorry Ingo!
>
> I forgot that the change above depends on another cleanup I sent to Paul,
>
> [PATCH] rcu/sync: kill rcu_sync_type/gp_type
> https://lore.kernel.org/lkml/20190423120724.GA6132@redhat.com/
>
> which does
>
> - .rss = __RCU_SYNC_INITIALIZER(name.rss, RCU_SCHED_SYNC), \
> + .rss = __RCU_SYNC_INITIALIZER(name.rss), \
>
> so lets forget it for now, or may be Paul can take this patch too.
No problem, and both rwsem patches you sent seem fine to me:
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Thanks,
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem
2019-04-24 11:02 ` Ingo Molnar
@ 2019-04-24 18:34 ` Paul E. McKenney
0 siblings, 0 replies; 5+ messages in thread
From: Paul E. McKenney @ 2019-04-24 18:34 UTC (permalink / raw)
To: Ingo Molnar; +Cc: Oleg Nesterov, Peter Zijlstra, Tejun Heo, linux-kernel
On Wed, Apr 24, 2019 at 01:02:56PM +0200, Ingo Molnar wrote:
>
> * Oleg Nesterov <oleg@redhat.com> wrote:
>
> > On 04/24, Ingo Molnar wrote:
> > >
> > > > -#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
> >
> > OOPS, sorry Ingo!
> >
> > I forgot that the change above depends on another cleanup I sent to Paul,
> >
> > [PATCH] rcu/sync: kill rcu_sync_type/gp_type
> > https://lore.kernel.org/lkml/20190423120724.GA6132@redhat.com/
> >
> > which does
> >
> > - .rss = __RCU_SYNC_INITIALIZER(name.rss, RCU_SCHED_SYNC), \
> > + .rss = __RCU_SYNC_INITIALIZER(name.rss), \
> >
> > so lets forget it for now, or may be Paul can take this patch too.
>
> No problem, and both rwsem patches you sent seem fine to me:
>
> Reviewed-by: Ingo Molnar <mingo@kernel.org>
I queued patches with Ingo's reviewed-by. Thank you both!
Thanx, Paul
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-04-24 18:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 16:32 [PATCH] locking/percpu-rwsem: Add DEFINE_PERCPU_RWSEM(), use it to initialize cgroup_threadgroup_rwsem Oleg Nesterov
2019-04-24 10:31 ` Ingo Molnar
2019-04-24 11:00 ` Oleg Nesterov
2019-04-24 11:02 ` Ingo Molnar
2019-04-24 18:34 ` Paul E. McKenney
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.