Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-12-09 Thread Xiao Guangrong
On 12/5/18 1:16 AM, Paolo Bonzini wrote: On 04/12/18 16:49, Christophe de Dinechin wrote: Linux and QEMU's own qht work just fine with compile-time directives. Wouldn’t it work fine without any compile-time directive at all? Yes, that's what I meant. Though there are certainly cases

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-12-04 Thread Paolo Bonzini
On 04/12/18 16:49, Christophe de Dinechin wrote: >> Linux and QEMU's own qht work just fine with compile-time directives. > > Wouldn’t it work fine without any compile-time directive at all? Yes, that's what I meant. Though there are certainly cases in which the difference without proper

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-12-04 Thread Christophe de Dinechin
> On 27 Nov 2018, at 14:51, Paolo Bonzini wrote: > > On 27/11/18 13:49, Christophe de Dinechin wrote: >> So this is not really >> helping. Also, the ThreadLocal structure itself is not necessarily aligned >> within struct Threads. Therefore, it’s possible that “requests” for example >> could

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-28 Thread Xiao Guangrong
On 11/27/18 8:49 PM, Christophe de Dinechin wrote: (I did not finish the review, but decided to send what I already had). On 22 Nov 2018, at 08:20, guangrong.x...@gmail.com wrote: From: Xiao Guangrong This modules implements the lockless and efficient threaded workqueue. I’m not

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-27 Thread Emilio G. Cota
On Tue, Nov 27, 2018 at 13:49:13 +0100, Christophe de Dinechin wrote: > (I did not finish the review, but decided to send what I already had). > > > On 22 Nov 2018, at 08:20, guangrong.x...@gmail.com wrote: > > > > From: Xiao Guangrong > > > > This modules implements the lockless and efficient

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-27 Thread Paolo Bonzini
On 27/11/18 13:49, Christophe de Dinechin wrote: > So this is not really > helping. Also, the ThreadLocal structure itself is not necessarily aligned > within struct Threads. Therefore, it’s possible that “requests” for example > could be on the same cache line as request_fill_bitmap if planets

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-27 Thread Christophe de Dinechin
(I did not finish the review, but decided to send what I already had). > On 22 Nov 2018, at 08:20, guangrong.x...@gmail.com wrote: > > From: Xiao Guangrong > > This modules implements the lockless and efficient threaded workqueue. I’m not entirely convinced that it’s either “lockless” or

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-27 Thread Xiao Guangrong
On 11/26/18 6:28 PM, Paolo Bonzini wrote: On 26/11/18 09:18, Xiao Guangrong wrote: +static uint64_t get_free_request_bitmap(Threads *threads, ThreadLocal *thread) +{ +    uint64_t request_fill_bitmap, request_done_bitmap, result_bitmap; + +    request_fill_bitmap =

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-27 Thread Xiao Guangrong
On 11/27/18 2:55 AM, Emilio G. Cota wrote: On Mon, Nov 26, 2018 at 15:57:25 +0800, Xiao Guangrong wrote: On 11/23/18 7:02 PM, Dr. David Alan Gilbert wrote: +#include "qemu/osdep.h" +#include "qemu/bitmap.h" +#include "qemu/threaded-workqueue.h" + +#define SMP_CACHE_BYTES 64 That's

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-27 Thread Xiao Guangrong
On 11/27/18 2:49 AM, Emilio G. Cota wrote: On Mon, Nov 26, 2018 at 16:06:37 +0800, Xiao Guangrong wrote: +/* after the user fills the request, the bit is flipped. */ +uint64_t request_fill_bitmap QEMU_ALIGNED(SMP_CACHE_BYTES); +/* after handles the request, the thread flips the

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Xiao Guangrong
On 11/26/18 6:56 PM, Dr. David Alan Gilbert wrote: * Xiao Guangrong (guangrong.x...@gmail.com) wrote: On 11/23/18 7:02 PM, Dr. David Alan Gilbert wrote: +#include "qemu/osdep.h" +#include "qemu/bitmap.h" +#include "qemu/threaded-workqueue.h" + +#define SMP_CACHE_BYTES 64 That's

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Emilio G. Cota
On Mon, Nov 26, 2018 at 15:57:25 +0800, Xiao Guangrong wrote: > > > On 11/23/18 7:02 PM, Dr. David Alan Gilbert wrote: > > > > +#include "qemu/osdep.h" > > > +#include "qemu/bitmap.h" > > > +#include "qemu/threaded-workqueue.h" > > > + > > > +#define SMP_CACHE_BYTES 64 > > > > That's

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Emilio G. Cota
On Mon, Nov 26, 2018 at 16:06:37 +0800, Xiao Guangrong wrote: > > > +/* after the user fills the request, the bit is flipped. */ > > > +uint64_t request_fill_bitmap QEMU_ALIGNED(SMP_CACHE_BYTES); > > > +/* after handles the request, the thread flips the bit. */ > > > +uint64_t

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Dr. David Alan Gilbert
* Xiao Guangrong (guangrong.x...@gmail.com) wrote: > > > On 11/23/18 7:02 PM, Dr. David Alan Gilbert wrote: > > > > +#include "qemu/osdep.h" > > > +#include "qemu/bitmap.h" > > > +#include "qemu/threaded-workqueue.h" > > > + > > > +#define SMP_CACHE_BYTES 64 > > > > That's architecture

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Paolo Bonzini
On 26/11/18 09:18, Xiao Guangrong wrote: >> >>> +static uint64_t get_free_request_bitmap(Threads *threads, >>> ThreadLocal *thread) >>> +{ >>> +    uint64_t request_fill_bitmap, request_done_bitmap, result_bitmap; >>> + >>> +    request_fill_bitmap = >>> atomic_rcu_read(>request_fill_bitmap); >>>

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Xiao Guangrong
On 11/24/18 8:17 AM, Emilio G. Cota wrote: On Thu, Nov 22, 2018 at 15:20:25 +0800, guangrong.x...@gmail.com wrote: +static uint64_t get_free_request_bitmap(Threads *threads, ThreadLocal *thread) +{ +uint64_t request_fill_bitmap, request_done_bitmap, result_bitmap; + +

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-26 Thread Xiao Guangrong
On 11/24/18 8:12 AM, Emilio G. Cota wrote: On Thu, Nov 22, 2018 at 15:20:25 +0800, guangrong.x...@gmail.com wrote: + /* + * the bit in these two bitmaps indicates the index of the @requests This @ is not ASCII, is it? Good eyes. :) Will fix it. + * respectively. If it's the

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-25 Thread Xiao Guangrong
On 11/23/18 7:02 PM, Dr. David Alan Gilbert wrote: +#include "qemu/osdep.h" +#include "qemu/bitmap.h" +#include "qemu/threaded-workqueue.h" + +#define SMP_CACHE_BYTES 64 That's architecture dependent isn't it? Yes, it's arch dependent indeed. I just used 64 for simplification and i

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-23 Thread Emilio G. Cota
On Thu, Nov 22, 2018 at 15:20:25 +0800, guangrong.x...@gmail.com wrote: > +static uint64_t get_free_request_bitmap(Threads *threads, ThreadLocal > *thread) > +{ > +uint64_t request_fill_bitmap, request_done_bitmap, result_bitmap; > + > +request_fill_bitmap =

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-23 Thread Emilio G. Cota
On Thu, Nov 22, 2018 at 15:20:25 +0800, guangrong.x...@gmail.com wrote: > + /* > + * the bit in these two bitmaps indicates the index of the @requests This @ is not ASCII, is it? > + * respectively. If it's the same, the corresponding request is free > + * and owned by the user,

Re: [Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-23 Thread Dr. David Alan Gilbert
* guangrong.x...@gmail.com (guangrong.x...@gmail.com) wrote: > From: Xiao Guangrong > > This modules implements the lockless and efficient threaded workqueue. > > Three abstracted objects are used in this module: > - Request. > It not only contains the data that the workqueue fetches out >

[Qemu-devel] [PATCH v3 2/5] util: introduce threaded workqueue

2018-11-21 Thread guangrong . xiao
From: Xiao Guangrong This modules implements the lockless and efficient threaded workqueue. Three abstracted objects are used in this module: - Request. It not only contains the data that the workqueue fetches out to finish the request but also offers the space to save the result