Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-12 Thread Jamie Lokier
Scott Tsai wrote: > I do have a newbie question, when exactly would vrtio have to handle > concurrent access from multiple threads? > My current reading of the code suggests: > 1. when CONFIG_IOTHREAD is true > 2. when CONFIG_KVM is true and the guest machine has multiple CPUs It's enough to have

Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Thu, Nov 12, 2009 at 02:37:26AM +0800, Scott Tsai wrote: > On Thu, Nov 12, 2009 at 2:09 AM, Michael S. Tsirkin wrote: > >> I do have a newbie question, when exactly would vrtio have to handle > >> concurrent access from multiple threads? > >> My current reading of the code suggests: > >> 1. whe

Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Scott Tsai
On Thu, Nov 12, 2009 at 2:09 AM, Michael S. Tsirkin wrote: >> I do have a newbie question, when exactly would vrtio have to handle >> concurrent access from multiple threads? >> My current reading of the code suggests: >> 1. when CONFIG_IOTHREAD is true >> 2. when CONFIG_KVM is true and the guest

Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Thu, Nov 12, 2009 at 01:18:11AM +0800, Scott Tsai wrote: > On Wed, Nov 11, 2009 at 10:08 PM, Michael S. Tsirkin wrote: > > On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: > >> If you don't need real barriers, then why does the kvm code have them? > > > > We need real barriers but AF

Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Thu, Nov 12, 2009 at 01:18:11AM +0800, Scott Tsai wrote: > On Wed, Nov 11, 2009 at 10:08 PM, Michael S. Tsirkin wrote: > > On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: > >> If you don't need real barriers, then why does the kvm code have them? > > > > We need real barriers but AF

Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Scott Tsai
On Wed, Nov 11, 2009 at 10:08 PM, Michael S. Tsirkin wrote: > On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: >> If you don't need real barriers, then why does the kvm code have them? > > We need real barriers but AFAIK kvm does not have them :( > IOW: virtio is currently broken with k

Re: [Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Paul Brook
On Wednesday 11 November 2009, Michael S. Tsirkin wrote: > On Wed, Nov 11, 2009 at 02:16:00PM +, Paul Brook wrote: > > On Wednesday 11 November 2009, Michael S. Tsirkin wrote: > > > On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: > > > > If you don't need real barriers, then why doe

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Wed, Nov 11, 2009 at 02:16:00PM +, Paul Brook wrote: > On Wednesday 11 November 2009, Michael S. Tsirkin wrote: > > On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: > > > If you don't need real barriers, then why does the kvm code have them? > > > > We need real barriers but AFAI

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Paul Brook
On Wednesday 11 November 2009, Michael S. Tsirkin wrote: > On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: > > If you don't need real barriers, then why does the kvm code have them? > > We need real barriers but AFAIK kvm does not have them :( > IOW: virtio is currently broken with kvm

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Wed, Nov 11, 2009 at 01:45:35PM +, Paul Brook wrote: > If you don't need real barriers, then why does the kvm code have them? We need real barriers but AFAIK kvm does not have them :( IOW: virtio is currently broken with kvm, and my patch did not fix this. The comment that I added says as m

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Paul Brook
> > > > > wmb must be at least a compiler barrier, even without SMP. > > > > > > > > Why? > > > > > > Because virtio code might run on a separate thread from guest. > > > If compiler reorders writes, guest might see inconsistent data. > > > > If you've got threads running in parallel (which may be

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Wed, Nov 11, 2009 at 01:01:03PM +, Paul Brook wrote: > A "compiler memory barrier" provides absolutely no guarantees in a > multithreaded environment. Claims including words "absolutely no" have absolutely no chance to be correct. -- MST

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Wed, Nov 11, 2009 at 01:01:03PM +, Paul Brook wrote: > On Wednesday 11 November 2009, Michael S. Tsirkin wrote: > > On Wed, Nov 11, 2009 at 01:34:12AM +, Paul Brook wrote: > > > On Monday 26 October 2009, Michael S. Tsirkin wrote: > > > > wmb must be at least a compiler barrier, even wit

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Paul Brook
On Wednesday 11 November 2009, Michael S. Tsirkin wrote: > On Wed, Nov 11, 2009 at 01:34:12AM +, Paul Brook wrote: > > On Monday 26 October 2009, Michael S. Tsirkin wrote: > > > wmb must be at least a compiler barrier, even without SMP. > > > > Why? > > Because virtio code might run on a separ

[Qemu-devel] Re: [PATCH] qemu/virtio: make wmb compiler barrier + comments

2009-11-11 Thread Michael S. Tsirkin
On Wed, Nov 11, 2009 at 01:34:12AM +, Paul Brook wrote: > On Monday 26 October 2009, Michael S. Tsirkin wrote: > > wmb must be at least a compiler barrier, even without SMP. > > Why? Because virtio code might run on a separate thread from guest. If compiler reorders writes, guest might see in