From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: NeilBrown <neilb@suse.de>
Cc: Chuck Lever <chuck.lever@oracle.com>,
Lorenzo Bianconi <lorenzo@kernel.org>,
linux-nfs@vger.kernel.org, jlayton@kernel.org
Subject: Re: [PATCH v4 2/2] NFSD: add rpc_status entry in nfsd debug filesystem
Date: Fri, 4 Aug 2023 10:02:57 +0200 [thread overview]
Message-ID: <ZMywsSb9Qz7K3V/f@lore-rh-laptop> (raw)
In-Reply-To: <169058229140.32308.9984914710358617790@noble.neil.brown.name>
[-- Attachment #1: Type: text/plain, Size: 2394 bytes --]
> On Sat, 29 Jul 2023, Chuck Lever wrote:
> > On Fri, Jul 28, 2023 at 08:44:04PM +0200, Lorenzo Bianconi wrote:
[...]
> >
> > Neil said:
> >
> > > I suggest you add add a counter to the rqstp which is incremented from
> > > even to odd after parsing a request - including he v4 parsing needed to
> > > have a sable ->opcnt - and then incremented from odd to even when the
> > > request is complete.
> > > Then this code samples the counter, skips the rqst if the counter is
> > > even, and resamples the counter after collecting the data. If it has
> > > changed, the drop the record.
> >
> > I don't see a check if the status counter is even.
>
> ...and there does need to be one. If the counter is even, then the
> fields are meaningless and unstable. The RQ_BUSY check is, I think,
> meant to check if the fields are meaningful, but they aren't meaningful
> until some time after RQ_BUSY is clear.
>
> I would replace the "RQ_BUSY not set" test with "counter is even"
ack, I will fix it.
>
> >
> > Also, as above, I'm not sure atomic_read() is necessary here. Maybe
> > just READ_ONCE() ? Neil, any thoughts?
>
> Agree - we don't need an atomic as there is a single writer.
> I think
> smp_store_release(rqstp->counter, rqstp->counter|1)
> to increment it after parsing the request. This makes it abundantly
> clear the value will be odd, and ensures that if another thread sees the
> 'odd' value, then it can also see the results of the parse.
>
> To increment after processing the request,
> smp_store_release(rqstp->counter, rqstp->counter + 1)
>
> Then
> counter = smp_load_acquire(rqstp->counter);
> if ((counter & 1) == 0)
> to test if it is even before reading the state. This ensure that if it
> sees "odd' it will see the results of the parse.
>
> and
> if ((smp_load_acquire(counter) == counter) continue;
>
> before trusting that the data we read was consistent.
>
> Note that we "release" *after* something and "acquire" *before"
> something.
> I think it helps to always think about what the access is "before" or
> "after" when reasoning about barriers.
> checkpatch will want a comment before these acquire and release
> operation. I recommend using the corresponding word "before" or "after"
> in that comment.
ack, I will add it.
Regards,
Lorenzo
>
> NeilBrown
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2023-08-04 8:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-28 18:44 [PATCH v4 0/2] add rpc_status handler in nfsd debug filesystem Lorenzo Bianconi
2023-07-28 18:44 ` [PATCH v4 1/2] SUNRPC: add verbose parameter to __svc_print_addr() Lorenzo Bianconi
2023-07-28 22:13 ` NeilBrown
2023-07-31 16:11 ` Jeff Layton
2023-07-31 22:15 ` NeilBrown
2023-07-28 18:44 ` [PATCH v4 2/2] NFSD: add rpc_status entry in nfsd debug filesystem Lorenzo Bianconi
2023-07-28 19:22 ` Chuck Lever
2023-07-28 22:11 ` NeilBrown
2023-08-04 8:02 ` Lorenzo Bianconi [this message]
2023-08-04 7:56 ` Lorenzo Bianconi
2023-08-04 14:02 ` Chuck Lever
2023-07-28 22:23 ` NeilBrown
2023-08-02 8:58 ` Lorenzo Bianconi
2023-07-29 5:18 ` kernel test robot
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=ZMywsSb9Qz7K3V/f@lore-rh-laptop \
--to=lorenzo.bianconi@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=lorenzo@kernel.org \
--cc=neilb@suse.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