From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Trond Myklebust <trondmy@primarydata.com>
Cc: Schumaker Anna <anna.schumaker@netapp.com>,
List Linux NFS Mailing <linux-nfs@vger.kernel.org>,
List Linux Kernel Mailing <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>
Subject: Re: [PATCH v2] NFSv4: replace seqcount_t with a seqlock_t
Date: Mon, 31 Oct 2016 11:46:41 +0100 [thread overview]
Message-ID: <20161031104641.3rdkonbyxgs6azec@linutronix.de> (raw)
In-Reply-To: <747E2CCB-3D83-40FD-8B31-46AB5A5E8592@primarydata.com>
On 2016-10-28 22:24:52 [+0000], Trond Myklebust wrote:
> > diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
> > index 5f4281ec5f72..a442d9867942 100644
> > --- a/fs/nfs/nfs4state.c
> > +++ b/fs/nfs/nfs4state.c
> > @@ -1497,8 +1498,18 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
> > * recovering after a network partition or a reboot from a
> > * server that doesn't support a grace period.
> > */
> > + /*
> > + * XXX
> > + * This mutex is wrong. It protects against multiple writer. However
>
> There is only 1 recovery thread per client/server pair, which is why we know there is only a single writer. No need for a mutex here.
This isn't documented but it should.
> > + * write_seqlock() should have been used for this task. This would avoid
> > + * preemption while the seqlock is held which is good because the writer
> > + * shouldn't be preempted as it would let the reader spin for no good
>
> Recovery involves sending RPC calls to a server. There is no avoiding preemption if we have to recover state. The point of the sequence counter is to signal to processes that may have raced with this recovery thread that they may need to replay their locks.
Then the sequence counter is the wrong mechanism used here. As I
explained: the call can be preempted and once it is, the reader will
spin and waste cycles.
What is wrong with a rwsem? Are the reader not preemptible?
> > + * reason. There are a few memory allocations and kthread_run() so we
> > + * have this mutex now.
> > + */
> > + mutex_lock(&sp->so_reclaim_seqlock_mutex);
> > + write_seqcount_begin(&sp->so_reclaim_seqlock.seqcount);
> > spin_lock(&sp->so_lock);
> > - raw_write_seqcount_begin(&sp->so_reclaim_seqcount);
> > restart:
> > list_for_each_entry(state, &sp->so_states, open_states) {
> > if (!test_and_clear_bit(ops->state_flag_bit, &state->flags))
> > @@ -1566,14 +1577,14 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
> > spin_lock(&sp->so_lock);
> > goto restart;
> > }
> > - raw_write_seqcount_end(&sp->so_reclaim_seqcount);
> > spin_unlock(&sp->so_lock);
> > + write_seqcount_end(&sp->so_reclaim_seqlock.seqcount);
>
> This will reintroduce lockdep checking. We don’t need or want that...
Why isn't lockdep welcome? And what kind warning will it introduce? How
do I trigger this? I tried various things but never got close to this.
Sebastian
next prev parent reply other threads:[~2016-10-31 10:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 16:47 [RFC PATCH] NFSv4: replace seqcount_t with a seqlock_t Sebastian Andrzej Siewior
2016-10-25 6:52 ` [lkp] [NFSv4] 931437ee2c: BUG: sleeping function called from invalid context at mm/slab.h:393 kernel test robot
2016-10-28 21:08 ` Sebastian Andrzej Siewior
2016-10-28 21:05 ` [PATCH v2] NFSv4: replace seqcount_t with a seqlock_t Sebastian Andrzej Siewior
2016-10-28 22:24 ` Trond Myklebust
2016-10-31 10:46 ` Sebastian Andrzej Siewior [this message]
2016-10-31 13:19 ` [PATCH v3] NFSv4: replace seqcount_t with a rw_semaphore Sebastian Andrzej Siewior
2016-10-31 15:30 ` Trond Myklebust
2016-10-31 15:56 ` Sebastian Andrzej Siewior
2016-10-31 16:11 ` Trond Myklebust
2016-11-02 17:11 ` Sebastian Andrzej Siewior
2016-11-02 17:37 ` Trond Myklebust
2016-11-02 17:15 ` [PATCH v4] NFSv4: replace seqcount_t with a seqlock_t Sebastian Andrzej Siewior
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=20161031104641.3rdkonbyxgs6azec@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=anna.schumaker@netapp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=trondmy@primarydata.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 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).