1. 22 Aug, 2013 1 commit
  2. 19 Aug, 2013 2 commits
  3. 15 Mar, 2013 3 commits
    • Stefan Hajnoczi's avatar
      threadpool: drop global thread pool · c4d9d196
      Stefan Hajnoczi authored
      Now that each AioContext has a ThreadPool and the main loop AioContext
      can be fetched with bdrv_get_aio_context(), we can eliminate the concept
      of a global thread pool from thread-pool.c.
      The submit functions must take a ThreadPool* argument.
      block/raw-posix.c and block/raw-win32.c use
      aio_get_thread_pool(bdrv_get_aio_context(bs)) to fetch the main loop's
      tests/test-thread-pool.c must be updated to reflect the new
      thread_pool_submit() function prototypes.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    • Stefan Hajnoczi's avatar
      threadpool: add thread_pool_new() and thread_pool_free() · f7311ccc
      Stefan Hajnoczi authored
      ThreadPool is tied to an AioContext through its event notifier, which
      dictates in which AioContext the work item's callback function will be
      In order to support multiple AioContexts we need to support multiple
      ThreadPool instances.
      This patch adds the new/free functions.  The free function deserves
      special attention because it quiesces remaining worker threads.  This
      requires a new condition variable and a "stopping" flag to let workers
      know they should terminate once idle.
      We never needed to do this before since the global threadpool was not
      explicitly destroyed until process termination.
      Also stash the AioContext pointer in ThreadPool so that we can call
      aio_set_event_notifier() in thread_pool_free().  We didn't need to hold
      onto AioContext previously since there was no free function.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    • Stefan Hajnoczi's avatar
      threadpool: move globals into struct ThreadPool · b811203c
      Stefan Hajnoczi authored
      Move global variables into a struct so multiple thread pools can be
      supported in the future.
      This patch does not change thread-pool.h interfaces.  There is still a
      global thread pool and it is not yet possible to create/destroy
      individual thread pools.  Moving the variables into a struct first makes
      later patches easier to review.
      Signed-off-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      Reviewed-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
  4. 19 Dec, 2012 2 commits
  5. 14 Nov, 2012 1 commit
  6. 31 Oct, 2012 2 commits
    • Paolo Bonzini's avatar
      threadpool: do not take lock in event_notifier_ready · 19d092cf
      Paolo Bonzini authored
      The ordering is:
          worker thread                         consumer thread
          write ret                             event_notifier_test_and_clear
          wmb()                                 read state
          write state                           rmb()
          event_notifier_set                    read ret
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    • Paolo Bonzini's avatar
      aio: add generic thread-pool facility · d354c7ec
      Paolo Bonzini authored
      Add a generic thread-pool.  The code is roughly based on posix-aio-compat.c,
      with some changes, especially the following:
      - use QemuSemaphore instead of QemuCond;
      - separate the state of the thread from the return code of the worker
      function.  The return code is totally opaque for the thread pool;
      - do not busy wait when doing cancellation.
      A more generic threadpool (but still specific to I/O so that in the future
      it can use special scheduling classes or PI mutexes) can have many uses:
      it allows more flexibility in raw-posix.c and can more easily be extended
      to Win32, and it will also be used to do an msync of the persistent bitmap.
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>