From: Haotian Wang <haotian.wang@sifive.com>
To: mst@redhat.com, jasowang@redhat.com, kishon@ti.com,
lorenzo.pieralisi@arm.com, bhelgaas@google.com
Cc: haotian.wang@duke.edu, linux-pci@vger.kernel.org
Subject: Re: [PATCH] pci: endpoint: functions: Add a virtnet EP function
Date: Thu, 5 Sep 2019 12:15:16 -0400 [thread overview]
Message-ID: <20190905161516.2845-1-haotian.wang@sifive.com> (raw)
In-Reply-To: <20190905025823-mutt-send-email-mst@kernel.org>
On Thu, Sep 5, 2019 at 3:07 AM Michael S. Tsirkin <mst@redhat.com> wrote:
> > The host may write multiple 0 or 1's and the endpoint can only
> > detect one of them in an notif_poll usleep interval.
>
> Right. Notifications weren't designed to be implemented on top of RW
> memory like this: the assumption was all notifications are buffered.
I can implement notification as a counter instead of a pending bit to
simulate a buffer. There will be many troublesome cases illustrated by
the following example.
The host sends a notification about available buffers 0-3. The endpoint
will probably consume buffers 0-5 as the notification is polled and
there is a delay. Then for some following notifications, the endpoint
may realize there are no corresponding available buffers to consume.
Those useless function calls waste cycles.
> So if you implement modern instead, different queues can use
> different addresses.
Will start working on this after switching the endpoint to using
vringh.c.
> > The host may write
> > some non-2 value as the endpoint code just finishes detecting the last
> > non-2 value and reverting that value back to 2, effectively nullifying
> > the new non-2 value.
> >
> > The host may decide to write a non-2 value
> > immediately after the endpoint revert that value back to 2 but before
> > the endpoint code finishes the current loop of execution, effectively
> > making the value not reverted back to 2.
> >
> > All these and other problems are made worse by the fact that the PCI
> > host Linux usually runs on much faster cores than the one on PCI
> > endpoint. This is why relying completely on pending bits is not always
> > safe. Hence the "fallback" check using usleep hackery exists.
> > Nevertheless I welcome any suggestion, because I do not like this
> > treatment myself either.
>
> As long as you have a small number of queues, you can poll both
> of them. And to resolve racing with host, re-check
> rings after you write 2 into the selector
I assume your suggestion is based on modern virtio. vrings in legacy
virtio share a common notification read-write area.
> (btw you also need a bunch of memory barriers, atomics don't
> imply them automatically).
Thank you for the reminder. In this doc,
https://www.kernel.org/doc/html/latest/core-api/atomic_ops.html, it says
"atomic_cmpxchg must provide explicit memory barriers around the operation,
although if the comparison fails then no memory ordering guarantees are
required". My understanding of this sentence is that the arch-specific
implementer of atomic_cmpxchg already surrounds the operation with
barriers in a more efficient way. The second part of the sentence
implies the doc's target audience is the implementer of atomic_cmpxchg.
Please correct me if I misunderstand this doc.
Thank you for your feedback.
Best,
Haotian
prev parent reply other threads:[~2019-09-05 16:15 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-23 21:31 [PATCH] pci: endpoint: functions: Add a virtnet EP function Haotian Wang
2019-08-26 10:51 ` Kishon Vijay Abraham I
2019-08-26 21:59 ` Haotian Wang
2019-08-27 8:12 ` Kishon Vijay Abraham I
2019-08-27 18:01 ` Haotian Wang
2019-08-30 6:11 ` Jason Wang
2019-08-30 23:06 ` Haotian Wang
2019-09-02 3:50 ` Jason Wang
2019-09-02 20:05 ` Haotian Wang
2019-09-03 10:42 ` Jason Wang
2019-09-04 0:55 ` Haotian Wang
2019-09-04 21:58 ` Haotian Wang
2019-09-05 2:56 ` Jason Wang
2019-09-05 3:28 ` Haotian Wang
2019-11-25 12:49 ` Kishon Vijay Abraham I
2019-11-26 9:58 ` Jason Wang
2019-11-26 12:35 ` Kishon Vijay Abraham I
2019-11-26 21:55 ` Alan Mikhak
2019-11-26 22:01 ` Alan Mikhak
2019-11-27 3:04 ` Jason Wang
2019-09-03 6:25 ` Michael S. Tsirkin
2019-09-03 20:39 ` Haotian Wang
2019-09-05 7:07 ` Michael S. Tsirkin
2019-09-05 16:15 ` Haotian Wang [this message]
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=20190905161516.2845-1-haotian.wang@sifive.com \
--to=haotian.wang@sifive.com \
--cc=bhelgaas@google.com \
--cc=haotian.wang@duke.edu \
--cc=jasowang@redhat.com \
--cc=kishon@ti.com \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=mst@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 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).