From: Minchan Kim <minchan@kernel.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Sergey Senozhatsky <senozhatsky@chromium.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH v2 7/9] locking/rwlocks: introduce write_lock_nested
Date: Fri, 19 Nov 2021 10:21:37 -0800 [thread overview]
Message-ID: <YZfrMTAXV56HFWJY@google.com> (raw)
In-Reply-To: <20211119103516.24uhxrkdcy4vq25k@linutronix.de>
On Fri, Nov 19, 2021 at 11:35:16AM +0100, Sebastian Andrzej Siewior wrote:
> On 2021-11-15 10:59:07 [-0800], Minchan Kim wrote:
> > diff --git a/include/linux/rwlock_rt.h b/include/linux/rwlock_rt.h
> > index 49c1f3842ed5..efd6da62c893 100644
> > --- a/include/linux/rwlock_rt.h
> > +++ b/include/linux/rwlock_rt.h
> > @@ -28,6 +28,7 @@ extern void rt_read_lock(rwlock_t *rwlock);
> > extern int rt_read_trylock(rwlock_t *rwlock);
> > extern void rt_read_unlock(rwlock_t *rwlock);
> > extern void rt_write_lock(rwlock_t *rwlock);
> > +extern void rt_write_lock_nested(rwlock_t *rwlock, int subclass);
> > extern int rt_write_trylock(rwlock_t *rwlock);
> > extern void rt_write_unlock(rwlock_t *rwlock);
> >
> > @@ -83,6 +84,11 @@ static __always_inline void write_lock(rwlock_t *rwlock)
> > rt_write_lock(rwlock);
> > }
> >
> > +static __always_inline void write_lock_nested(rwlock_t *rwlock, int subclass)
> > +{
> > + rt_write_lock_nested(rwlock, subclass);
> > +}
> > +
>
> These two hunks as-is don't work. You need a CONFIG_DEBUG_LOCK_ALLOC block and
> in the !CONFIG_DEBUG_LOCK_ALLOC case you need
>
> #define rt_write_lock_nested(lock, subclass) rt_write_lock(((void)(subclass), (lock)))
Guess you meant #define write_lock_nested.
>
> > static __always_inline void write_lock_bh(rwlock_t *rwlock)
> > {
> > local_bh_disable();
> > diff --git a/kernel/locking/spinlock_rt.c b/kernel/locking/spinlock_rt.c
> > index b2e553f9255b..b82d346f1e00 100644
> > --- a/kernel/locking/spinlock_rt.c
> > +++ b/kernel/locking/spinlock_rt.c
> > @@ -239,6 +239,18 @@ void __sched rt_write_lock(rwlock_t *rwlock)
> > }
> > EXPORT_SYMBOL(rt_write_lock);
> >
> > +#ifdef CONFIG_DEBUG_LOCK_ALLOC
> > +void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass)
> > +{
> > + ___might_sleep(__FILE__, __LINE__, 0);
>
> This _must_ be rtlock_might_resched() like it is done in rt_write_lock()
> above.
I should have Cced you. Thanks for the catch.
If it's fine, Andrew, could you fold it?
Thank you.
From 81f8721bc76d5f8c94770e53c6ad2e41aec8ab21 Mon Sep 17 00:00:00 2001
From: Minchan Kim <minchan@kernel.org>
Date: Fri, 19 Nov 2021 10:15:00 -0800
Subject: [PATCH] locking/rwlocks: fix write_lock_nested for RT
Fix build break of write_lock_nested for RT.
Suggested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Minchan Kim <minchan@kernel.org>
---
include/linux/rwlock_rt.h | 4 ++++
kernel/locking/spinlock_rt.c | 2 +-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/linux/rwlock_rt.h b/include/linux/rwlock_rt.h
index efd6da62c893..8544ff05e594 100644
--- a/include/linux/rwlock_rt.h
+++ b/include/linux/rwlock_rt.h
@@ -84,10 +84,14 @@ static __always_inline void write_lock(rwlock_t *rwlock)
rt_write_lock(rwlock);
}
+#ifdef CONFIG_DEBUG_LOCK_ALLOC
static __always_inline void write_lock_nested(rwlock_t *rwlock, int subclass)
{
rt_write_lock_nested(rwlock, subclass);
}
+#else
+#define write_lock_nested(lock, subclass) rt_write_lock(((void)(subclass), (lock)))
+#endif
static __always_inline void write_lock_bh(rwlock_t *rwlock)
{
diff --git a/kernel/locking/spinlock_rt.c b/kernel/locking/spinlock_rt.c
index b82d346f1e00..b501aef820d5 100644
--- a/kernel/locking/spinlock_rt.c
+++ b/kernel/locking/spinlock_rt.c
@@ -242,7 +242,7 @@ EXPORT_SYMBOL(rt_write_lock);
#ifdef CONFIG_DEBUG_LOCK_ALLOC
void __sched rt_write_lock_nested(rwlock_t *rwlock, int subclass)
{
- ___might_sleep(__FILE__, __LINE__, 0);
+ rtlock_might_resched();
rwlock_acquire(&rwlock->dep_map, subclass, 0, _RET_IP_);
rwbase_write_lock(&rwlock->rwbase, TASK_RTLOCK_WAIT);
rcu_read_lock();
--
2.34.0.rc2.393.gf8c9666880-goog
next prev parent reply other threads:[~2021-11-19 18:22 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-15 18:59 [PATCH v2 0/9] zsmalloc: remove bit_spin_lock Minchan Kim
2021-11-15 18:59 ` [PATCH v2 1/9] zsmalloc: introduce some helper functions Minchan Kim
2021-11-15 18:59 ` [PATCH v2 2/9] zsmalloc: rename zs_stat_type to class_stat_type Minchan Kim
2021-11-15 18:59 ` [PATCH v2 3/9] zsmalloc: decouple class actions from zspage works Minchan Kim
2021-11-15 18:59 ` [PATCH v2 4/9] zsmalloc: introduce obj_allocated Minchan Kim
2021-11-15 18:59 ` [PATCH v2 5/9] zsmalloc: move huge compressed obj from page to zspage Minchan Kim
2021-11-15 18:59 ` [PATCH v2 6/9] zsmalloc: remove zspage isolation for migration Minchan Kim
2021-11-15 18:59 ` [PATCH v2 7/9] locking/rwlocks: introduce write_lock_nested Minchan Kim
2021-11-16 10:27 ` Peter Zijlstra
2021-11-19 10:35 ` Sebastian Andrzej Siewior
2021-11-19 18:21 ` Minchan Kim [this message]
2021-11-20 15:38 ` Sebastian Andrzej Siewior
2021-11-20 3:50 ` kernel test robot
2021-11-15 18:59 ` [PATCH v2 8/9] zsmalloc: replace per zpage lock with pool->migrate_lock Minchan Kim
2021-11-15 18:59 ` [PATCH v2 9/9] zsmalloc: replace get_cpu_var with local_lock Minchan Kim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YZfrMTAXV56HFWJY@google.com \
--to=minchan@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bigeasy@linutronix.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=peterz@infradead.org \
--cc=senozhatsky@chromium.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).