qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] v6: [PATCH 0/3]: Threadlets: A generic task offloading


From: Amit Shah
Subject: Re: [Qemu-devel] v6: [PATCH 0/3]: Threadlets: A generic task offloading framework
Date: Wed, 27 Oct 2010 13:27:32 +0530
User-agent: Mutt/1.5.21 (2010-09-15)

On (Sat) Oct 23 2010 [13:05:48], Stefan Hajnoczi wrote:
> >> >You cannot access guest memory using QEMU RAM functions (or use the
> >> >virtqueue_pop() function which uses them) from a thread without taking
> >> >the QEMU global mutex.
> >> >
> >> >The abort stack trace is a result of accessing guest RAM from two
> >> >threads simultaneously.
> >> >
> >> >In general it is not safe to use QEMU functions from a thread unless
> >> >they are explicitly written to work outside the QEMU global mutex.
> >> >Most functions assume the global mutex, which serializes I/O thread
> >> >and vcpu changes to global state, is held.
> >>
> >> Yes, threadlets are only meant to be used to make synchronous system
> >> calls asynchronous.  They are not meant to add parallelism to QEMU
> >> (yet).
> >
> > Yes -- I realised that.  (But I don't see why the virtio rings get
> > modified elsewhere other than the only function I push/pop from above.)
> 
> The particular race condition triggered by virtqueue_pop() is because
> guest RAM access functions try to optimize frequently accessed memory
> to keep lookup time to a minimum.  The current RAM block is put onto
> the beginning of the lookup list so the next access to it will be
> faster.  When two threads are looking up guest memory simultaneously
> one may be modifying the list while the other traverses it...

Right, thanks.

> > Anyway, just one question as I've still not read the code: does a
> > running work item in a threadlet block migration?  Do the remaining work
> > items in a threadlet get migrated fine?
> 
> There's no migration support in the threadlets infrastructure itself.
> 
> Threadlets users need to think about how to safely migrate, either
> through cancellation or waiting for all pending work to complete.  For
> example, migration will quiesce aio requests using qemu_aio_flush() so
> there is no outstanding work to be migrated.

The problem then is that the API doesn't have functions to either stall
all pending work in a threadlet or cancel all work or even block the
caller till all work is finished.  I think the API relies on the work
signalling some sort of completion, which means callers (or threadlet
users) have to keep track of all the work scheduled, which might be
uneecessary.

                Amit



reply via email to

[Prev in Thread] Current Thread [Next in Thread]