From: Oleg Nesterov <oleg@redhat.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
linux-rt-users <linux-rt-users@vger.kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Daniel Bristot de Oliveira <bristot@redhat.com>,
Clark Williams <williams@redhat.com>,
Juri Lelli <juri.lelli@redhat.com>,
jack@suse.com, Waiman Long <longman@redhat.com>,
Davidlohr Bueso <dave@stgolabs.net>
Subject: Re: [RT WARNING] DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current) with fsfreeze (4.19.25-rt16)
Date: Fri, 3 May 2019 17:37:48 +0200 [thread overview]
Message-ID: <20190503153747.GC20802@redhat.com> (raw)
In-Reply-To: <20190503141633.GB2606@hirez.programming.kicks-ass.net>
On 05/03, Peter Zijlstra wrote:
>
> On Thu, May 02, 2019 at 12:09:32PM +0200, Oleg Nesterov wrote:
>
> > > +static void readers_block(struct percpu_rw_semaphore *sem)
> > > +{
> > > + wait_event_cmd(sem->writer, !sem->readers_block,
> > > + __up_read(&sem->rw_sem), __down_read(&sem->rw_sem));
> > > +}
> > > +
> > > +static void block_readers(struct percpu_rw_semaphore *sem)
> > > +{
> > > + wait_event_exclusive_cmd(sem->writer, !sem->readers_block,
> > > + __up_write(&sem->rw_sem),
> > > + __down_write(&sem->rw_sem));
> > > + /*
> > > + * Notify new readers to block; up until now, and thus throughout the
> > > + * longish rcu_sync_enter() above, new readers could still come in.
> > > + */
> > > + WRITE_ONCE(sem->readers_block, 1);
> > > +}
> >
> > So iiuc, despite it name block_readers() also serializes the writers, ->rw_sem
> > can be dropped by down_write_non_owner() so the new writer can take this lock.
>
> I don't think block_readers() is sufficient to serialize writers;
> suppose two concurrent callers when !->readers_block. Without ->rwsem
> that case would not serialize.
Of course. I meant that the next writer can enter block_readers() if
up_non_owner() drops ->rw_sem, but it will block in wait_event(!readers_block).
(And if we change this code to use wait_event(xchg(readers_block) == 0) we
can remove rw_sem altogether).
The main problem is that this is sub-optimal. We can have a lot of readers
sleeping in __down_read() when percpu_down_write() succeeds, then after
percpu_down_write_non_owner() does up_write() they all will be woken just
to hang in readers_block(). Plus the new readers will need to pass the
lock-check-unlock-schedule path.
Peter, just in case... I see another patch from you but I need to run away
till Monday.
Oleg.
next prev parent reply other threads:[~2019-05-03 15:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-26 9:34 [RT WARNING] DEBUG_LOCKS_WARN_ON(rt_mutex_owner(lock) != current) with fsfreeze (4.19.25-rt16) Juri Lelli
2019-03-28 10:17 ` Sebastian Andrzej Siewior
2019-04-19 8:56 ` Juri Lelli
2019-04-30 12:51 ` Sebastian Andrzej Siewior
2019-04-30 13:28 ` Peter Zijlstra
2019-04-30 13:45 ` Sebastian Andrzej Siewior
2019-04-30 14:01 ` Peter Zijlstra
2019-04-30 14:15 ` Oleg Nesterov
2019-04-30 14:29 ` Peter Zijlstra
2019-04-30 14:42 ` Oleg Nesterov
2019-04-30 14:44 ` Peter Zijlstra
2019-04-30 14:53 ` Oleg Nesterov
2019-05-01 17:09 ` Peter Zijlstra
2019-05-01 17:26 ` Waiman Long
2019-05-01 18:54 ` Peter Zijlstra
2019-05-01 19:22 ` Davidlohr Bueso
2019-05-01 19:25 ` Peter Zijlstra
2019-05-02 10:09 ` Oleg Nesterov
2019-05-02 11:42 ` Oleg Nesterov
2019-05-03 14:50 ` Peter Zijlstra
2019-05-03 15:25 ` Peter Zijlstra
2019-05-06 16:50 ` Oleg Nesterov
2019-06-19 9:50 ` Peter Zijlstra
2019-05-03 14:16 ` Peter Zijlstra
2019-05-03 15:37 ` Oleg Nesterov [this message]
2019-05-03 15:46 ` Peter Zijlstra
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=20190503153747.GC20802@redhat.com \
--to=oleg@redhat.com \
--cc=bigeasy@linutronix.de \
--cc=bristot@redhat.com \
--cc=dave@stgolabs.net \
--cc=jack@suse.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=longman@redhat.com \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/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 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.