All of lore.kernel.org
 help / color / mirror / Atom feed
* virtio-gpu vq code isn't thread safe
@ 2015-06-16  4:55 Dave Airlie
  2015-06-16  7:12 ` Gerd Hoffmann
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Airlie @ 2015-06-16  4:55 UTC (permalink / raw)
  To: Gerd Hoffmann, dri-devel, Michael S. Tsirkin

Hey Gerd,

This probably doesn't matter yet, but they virtgpu_vq buffer
allocation code you added isn't threadsafe.

I'm not sure what was wrong with the original code I wrote, you never
contacted me with reasons for rewriting it, but the Linux kmalloc
isn't that slow, but if we want some form of cached allocator you
probably should just use kmem_cache_create instead of what you have
there.

The second any code hits that from two threads its going to explode as
the free buffers list isn't protected with a lock of any kind, I know
userspace might not be able to hit this at present, but this is a big
problem when we add the 3D code.

Dave.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: virtio-gpu vq code isn't thread safe
  2015-06-16  4:55 virtio-gpu vq code isn't thread safe Dave Airlie
@ 2015-06-16  7:12 ` Gerd Hoffmann
  2015-06-16  7:29   ` Dave Airlie
  0 siblings, 1 reply; 3+ messages in thread
From: Gerd Hoffmann @ 2015-06-16  7:12 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel, Michael S. Tsirkin

On Di, 2015-06-16 at 14:55 +1000, Dave Airlie wrote:
> Hey Gerd,
> 
> This probably doesn't matter yet, but they virtgpu_vq buffer
> allocation code you added isn't threadsafe.

Right, I'll add a lock (or do you have a patch already?)

> I'm not sure what was wrong with the original code I wrote, you never
> contacted me with reasons for rewriting it, but the Linux kmalloc
> isn't that slow, but if we want some form of cached allocator you
> probably should just use kmem_cache_create instead of what you have
> there.

That came up during patch review.  Problem isn't kmalloc performance,
kmalloc (ENOMEM) but error handling.  When we allocate stuff in advance
a bunch of nasty error paths simply can't happen.

cheers,
  Gerd


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: virtio-gpu vq code isn't thread safe
  2015-06-16  7:12 ` Gerd Hoffmann
@ 2015-06-16  7:29   ` Dave Airlie
  0 siblings, 0 replies; 3+ messages in thread
From: Dave Airlie @ 2015-06-16  7:29 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: dri-devel, Michael S. Tsirkin

On 16 June 2015 at 17:12, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On Di, 2015-06-16 at 14:55 +1000, Dave Airlie wrote:
>> Hey Gerd,
>>
>> This probably doesn't matter yet, but they virtgpu_vq buffer
>> allocation code you added isn't threadsafe.
>
> Right, I'll add a lock (or do you have a patch already?)

I've got a patch in my tree to add a spinlock around it,

http://cgit.freedesktop.org/~airlied/linux/commit/?h=virtio-gpu&id=e5adb6e41394ac16dbbaffc961e196103f7b07fa

but I'd need to rebase it out and send it, feel free to steal and add
my S-o-b to it.

Dave.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-16  7:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-16  4:55 virtio-gpu vq code isn't thread safe Dave Airlie
2015-06-16  7:12 ` Gerd Hoffmann
2015-06-16  7:29   ` Dave Airlie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.