From: Dominique Martinet <asmadeus@codewreck.org>
To: Hillf Danton <hdanton@sina.com>
Cc: Christian Schoenebeck <linux_oss@crudebyte.com>,
v9fs-developer@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Marco Elver <elver@google.com>
Subject: Re: [PATCH] 9p/virtio: add a read barrier in p9_virtio_zc_request
Date: Tue, 13 Dec 2022 20:00:45 +0900 [thread overview]
Message-ID: <Y5hbXanne5IryJBV@codewreck.org> (raw)
In-Reply-To: <20221213065901.3523-1-hdanton@sina.com>
(Your mailer breaks threads, please have a look at how to make it send
In-Reply-To and/or References headers)
Hillf Danton wrote on Tue, Dec 13, 2022 at 02:59:01PM +0800:
> On 10 Dec 2022 09:10:44 +0900 Dominique Martinet <asmadeus@codewreck.org>
> > @@ -533,6 +533,12 @@ p9_virtio_zc_request(struct p9_client *client, struct p9_req_t *req,
> > p9_debug(P9_DEBUG_TRANS, "virtio request kicked\n");
> > err = wait_event_killable(req->wq,
> > READ_ONCE(req->status) >= REQ_STATUS_RCVD);
> > +
> > + /* Make sure our req is coherent with regard to updates in other
> > + * threads - echoes to wmb() in the callback like p9_client_rpc
> > + */
> > + smp_rmb();
> > +
> > // RERROR needs reply (== error string) in static data
> > if (READ_ONCE(req->status) == REQ_STATUS_RCVD &&
> > unlikely(req->rc.sdata[4] == P9_RERROR))
>
> No sense can be made without checking err before req->status,
> given the comment below. Worse after this change.
Hmm, I don't see how it's worse (well, it makes it more likely for
req->status to be RCVD after the barrier without the rest of the data
being coherent I guess), but it's definitely incorrect, yes...
Thanks for bringing it up.
Having another look I also don't see how this can possibly be safe at
all: if a process is killed during waiting here, p9_virtio_zc_request
will drop pages it reserved for the response (in the need_drop case) and
sg lists will be freed but the response can still come for a while --
these need to be dropped only after flush has been handled.
If these buffers are reused while the response comes we'll be overriding
some random data...
This isn't an easy fix, I'll just drop this patch for now; but I guess
we should try to address that next cycle.
Perhaps I can try to find time to dust off my async flush code, some
other fix might have resolved the race I used to see with it...
--
Dominique
next parent reply other threads:[~2022-12-13 11:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20221213065901.3523-1-hdanton@sina.com>
2022-12-13 11:00 ` Dominique Martinet [this message]
2022-12-10 0:10 [PATCH] 9p/virtio: add a read barrier in p9_virtio_zc_request Dominique Martinet
2022-12-12 13:35 ` Christian Schoenebeck
2022-12-13 4:03 ` Dominique Martinet
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=Y5hbXanne5IryJBV@codewreck.org \
--to=asmadeus@codewreck.org \
--cc=elver@google.com \
--cc=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux_oss@crudebyte.com \
--cc=v9fs-developer@lists.sourceforge.net \
/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