[lkml]   [2010]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: [PATCH RFC] virtio: put last seen used index into ring itself
    On Thu, May 06, 2010 at 12:01:34PM +0930, Rusty Russell wrote:
    > On Thu, 6 May 2010 06:28:14 am Michael S. Tsirkin wrote:
    > > Rusty,
    > > this is a simplified form of a patch you posted in the past.
    > > I have a vhost patch that, using this feature, shows external
    > > to host bandwidth grow from 5 to 7 GB/s, by avoiding
    > > an interrupt in the window after previous interrupt
    > > was sent and before interrupts were disabled for the vq.
    > > With vhost under some external to host loads I see
    > > this window being hit about 30% sometimes.
    > Fascinating. So you use this to guess if the guest is still processing?


    > I haven't thought about it hard, but is that racy?

    I thought about this really hard and I don't think it's
    necessarily racy, as long as (pseudo code):
    disable interrupts
    write(last used)
    enable interrupts
    if read(used)
    goto start

    write used
    if (reached(read(last used), used))

    IOW, guest does read then write then read, host does write then read.

    Now, the only way to miss an interrupt is if we read last used
    value before it is written so we think guest is still processing.
    But if that happens, this means that host has written used before
    guest updated last used, and for this reason peek will see
    used value and restart polling.

    IOW, to miss an interrupt host must read a stale value.
    For this host must read before guest write, then
    host write already happened, so second read in
    guest will see an updated value host has written.

    Now, I also added an mb() in guest between read and write so
    that last used index write can not get ahead of used index read.
    It does feel good to have it there, but I can not say why
    it's helpful. Works fine without it, but then these
    subtle races might be hard to trigger. What do you think?

    > Obviously happy to apply this when you finalize it.
    > Thanks!
    > Rusty.

     \ /
      Last update: 2010-05-06 08:27    [W:4.998 / U:0.024 seconds]
    ©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site