From: "Michael S. Tsirkin" <mst@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: virtio-dev@lists.oasis-open.org,
virtualization@lists.linux-foundation.org
Subject: Re: [virtio-dev] packed ring layout proposal v2
Date: Fri, 10 Feb 2017 17:20:17 +0200 [thread overview]
Message-ID: <20170210170548-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <c229269b-1702-ffec-62e8-002c7c142904@redhat.com>
On Fri, Feb 10, 2017 at 12:32:49PM +0100, Paolo Bonzini wrote:
>
>
> On 09/02/2017 19:24, Michael S. Tsirkin wrote:
> >> I don't know. Power of 2 ring size is pretty standard, I'd rather avoid
> >> the complication and the gratuitous difference with 1.0.
> >
> > I thought originally there's a reason 1.0 rings had to be powers of two
> > but now I don't see why. OK, we can make it a feature flag later if we
> > want to.
>
> The reason is that it allows indices to be free running.
Well what I meant is that with qsize not a power of 2 you can still do
this but have to do everything mod N*qsize as opposed to mod 2^16. So
you need a branch there - easiest to do if you do signed math.
int nheads = avail - last_avail;
/*Check and handle index wrap-around */
if (unlikely(nheads < 0)) {
nheads += N_qsize;
}
if (nheads < 0 || nheads > vdev->vq[i].vring.num) {
error_report(...);
return -1;
}
This can only catch bugs if N > 1
> This is an
> example of QEMU code that requires that:
>
> nheads = vring_avail_idx(&vdev->vq[i]) - vdev->vq[i].last_avail_idx;
> /* Check it isn't doing strange things with descriptor numbers. */
> if (nheads > vdev->vq[i].vring.num) {
> error_report("VQ %d size 0x%x Guest index 0x%x "
> "inconsistent with Host index 0x%x: delta 0x%x",
> i, vdev->vq[i].vring.num,
> vring_avail_idx(&vdev->vq[i]),
> vdev->vq[i].last_avail_idx, nheads);
> return -1;
> }
>
> Paolo
Same thing here, this never triggers if vring.num == 2^16
--
MST
next prev parent reply other threads:[~2017-02-10 15:20 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20160915223915.qjlnlvf2w7u37bu3@redhat.com>
2017-02-08 13:37 ` packed ring layout proposal v2 Christian Borntraeger
2017-02-09 17:43 ` Michael S. Tsirkin
[not found] ` <20170209181955-mutt-send-email-mst@kernel.org>
2017-02-09 18:27 ` Christian Borntraeger
2017-02-08 17:41 ` [virtio-dev] " Paolo Bonzini
2017-02-08 19:59 ` Michael S. Tsirkin
[not found] ` <20170208214435-mutt-send-email-mst@kernel.org>
2017-02-09 15:48 ` Paolo Bonzini
2017-02-09 16:11 ` Cornelia Huck
2017-02-09 18:24 ` Michael S. Tsirkin
[not found] ` <20170209202203-mutt-send-email-mst@kernel.org>
2017-02-10 11:32 ` Paolo Bonzini
[not found] ` <c229269b-1702-ffec-62e8-002c7c142904@redhat.com>
2017-02-10 15:20 ` Michael S. Tsirkin [this message]
2017-02-10 16:17 ` Paolo Bonzini
[not found] ` <20170209171105.075a9d9c.cornelia.huck@de.ibm.com>
2017-02-22 16:43 ` Michael S. Tsirkin
[not found] ` <20170222181333-mutt-send-email-mst@kernel.org>
2017-03-07 15:53 ` Cornelia Huck
2017-03-07 20:33 ` Michael S. Tsirkin
[not found] ` <20170307223057-mutt-send-email-mst@kernel.org>
2017-07-10 16:27 ` Amnon Ilan
2017-02-22 4:27 ` packed ring layout proposal - todo list Michael S. Tsirkin
2017-02-22 14:46 ` [virtio-dev] packed ring layout proposal v2 Chien, Roger S
[not found] ` <20170222054336-mutt-send-email-mst@kernel.org>
2017-02-22 9:19 ` [virtio-dev] packed ring layout proposal - todo list Gray, Mark D
[not found] ` <738D45BC1F695740A983F43CFE1B7EA94E93CA7E@IRSMSX108.ger.corp.intel.com>
2017-02-22 15:13 ` Michael S. Tsirkin
2017-02-28 4:29 ` Yuanhan Liu
[not found] ` <20170228042943.GH18844@yliu-dev.sh.intel.com>
2017-03-01 1:07 ` Michael S. Tsirkin
2017-03-08 7:09 ` Yuanhan Liu
[not found] ` <20170308070948.GC18844@yliu-dev.sh.intel.com>
2017-03-08 7:56 ` Yuanhan Liu
[not found] ` <20170308075624.GF18844@yliu-dev.sh.intel.com>
2017-03-29 12:39 ` Michael S. Tsirkin
2017-04-01 7:30 ` Yuanhan Liu
2017-02-28 5:02 ` [virtio-dev] packed ring layout proposal v2 Yuanhan Liu
2017-02-28 5:47 ` [RFC] packed (virtio-net) headers Yuanhan Liu
[not found] ` <20170228050218.GI18844@yliu-dev.sh.intel.com>
2017-03-01 1:02 ` [virtio-dev] packed ring layout proposal v2 Michael S. Tsirkin
[not found] ` <20170301024951-mutt-send-email-mst@kernel.org>
2017-03-01 3:57 ` Yuanhan Liu
[not found] ` <20170301035715.GP18844@yliu-dev.sh.intel.com>
2017-03-01 4:14 ` Michael S. Tsirkin
2017-03-01 4:57 ` Yuanhan Liu
[not found] ` <20170228054719.GJ18844@yliu-dev.sh.intel.com>
2017-03-01 1:28 ` [RFC] packed (virtio-net) headers Michael S. Tsirkin
2017-07-16 6:00 ` [virtio-dev] packed ring layout proposal v2 Lior Narkis
[not found] ` <DB5PR05MB176690DF180908ABCDDA0860D3A30@DB5PR05MB1766.eurprd05.prod.outlook.com>
2017-07-18 16:23 ` Michael S. Tsirkin
2017-07-19 7:41 ` Lior Narkis
[not found] ` <DB5PR05MB1766461893DB3FE20D338B96D3A60@DB5PR05MB1766.eurprd05.prod.outlook.com>
2017-07-20 13:06 ` Michael S. Tsirkin
2017-09-11 7:47 ` packed ring layout proposal v3 Jason Wang
2017-09-12 16:20 ` [virtio-dev] " Willem de Bruijn
[not found] ` <0f0e1b94-2a46-689c-dbb3-0d578cc8df33@redhat.com>
2017-09-12 16:23 ` [virtio-dev] " Willem de Bruijn
[not found] ` <CAF=yD-+LtZO=Fcw6Y-v0dnxkmwqW1+CqzopyQEApOjOAszgqMg@mail.gmail.com>
2017-09-13 1:26 ` Jason Wang
2017-09-14 8:23 ` Ilya Lesokhin
2017-09-20 9:11 ` [virtio-dev] " Liang, Cunming
2017-09-25 22:24 ` Michael S. Tsirkin
[not found] ` <20170926011826-mutt-send-email-mst@kernel.org>
2017-09-26 23:38 ` Steven Luong (sluong)
[not found] ` <7A0DC0C9-F148-4161-B2D1-8D8D14D8B9A1@cisco.com>
2017-09-27 23:49 ` Michael S. Tsirkin
2017-09-28 9:44 ` Liang, Cunming
2017-09-28 21:13 ` Michael S. Tsirkin
[not found] ` <D0158A423229094DA7ABF71CF2FA0DA34E1AD49B@SHSMSX152.ccr.corp.intel.com>
2017-10-01 4:08 ` Michael S. Tsirkin
2017-10-04 12:39 ` Jens Freimann
2017-10-04 12:58 ` Michael S. Tsirkin
[not found] ` <20171004155532-mutt-send-email-mst@kernel.org>
2017-10-10 9:56 ` Liang, Cunming
[not found] ` <D0158A423229094DA7ABF71CF2FA0DA34E7DE4D3@SHSMSX104.ccr.corp.intel.com>
2017-10-11 12:22 ` Jens Freimann
2017-09-21 13:36 ` Liang, Cunming
2017-09-28 21:27 ` Michael S. Tsirkin
2017-10-08 6:16 ` Ilya Lesokhin
[not found] ` <AM4PR0501MB27236B71E1B02176F1844ACBD4770@AM4PR0501MB2723.eurprd05.prod.outlook.com>
2017-10-25 16:20 ` Michael S. Tsirkin
2017-10-29 9:05 ` Ilya Lesokhin
[not found] ` <AM4PR0501MB2723177BF4E5EE32CC878E8CD4580@AM4PR0501MB2723.eurprd05.prod.outlook.com>
2017-10-29 14:21 ` Michael S. Tsirkin
2017-10-29 14:34 ` Ilya Lesokhin
[not found] ` <AM4PR0501MB272332C92A384C97D6975D8DD4580@AM4PR0501MB2723.eurprd05.prod.outlook.com>
2017-10-30 2:08 ` Michael S. Tsirkin
2017-10-30 6:30 ` Ilya Lesokhin
[not found] ` <AM4PR0501MB27233D93937CA1F2E5AD13DBD4590@AM4PR0501MB2723.eurprd05.prod.outlook.com>
2017-10-30 16:30 ` Michael S. Tsirkin
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=20170210170548-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
--cc=virtualization@lists.linux-foundation.org \
/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).