From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: Re: [PATCH 09/12] ring: introduce lockless ring buffer Date: Fri, 29 Jun 2018 11:59:46 +0800 Message-ID: <73324779-b76f-3081-adbb-590bc2030833@gmail.com> References: <20180604095520.8563-1-xiaoguangrong@tencent.com> <20180604095520.8563-10-xiaoguangrong@tencent.com> <355310d0-a33d-dab1-1781-2de37dd648f7@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Cc: kvm@vger.kernel.org, Xiao Guangrong , qemu-devel@nongnu.org, peterx@redhat.com, dgilbert@redhat.com, wei.w.wang@intel.com, jiang.biao2@zte.com.cn To: Jason Wang , pbonzini@redhat.com, mst@redhat.com, mtosatti@redhat.com Return-path: In-Reply-To: <355310d0-a33d-dab1-1781-2de37dd648f7@redhat.com> Content-Language: en-US List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel2=m.gmane.org@nongnu.org Sender: "Qemu-devel" List-Id: kvm.vger.kernel.org On 06/28/2018 09:36 PM, Jason Wang wrote: > > > On 2018年06月04日 17:55, guangrong.xiao@gmail.com wrote: >> From: Xiao Guangrong >> >> It's the simple lockless ring buffer implement which supports both >> single producer vs. single consumer and multiple producers vs. >> single consumer. >> >> Finally, it fetches the valid data out, set the entry to the initialized >> state and update ring->out to make the entry be usable to the producer: >> >>        data = *entry; >>        *entry = NULL; >>        ring->out++; >> >> Memory barrier is omitted here, please refer to the comment in the code. >> >> (1)https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/kfifo.h >> (2)http://dpdk.org/doc/api/rte__ring_8h.html >> >> Signed-off-by: Xiao Guangrong >> --- > > May I ask why you need a MPSC ring here? Can we just use N SPSC ring for submitting pages and another N SPSC ring for passing back results? Sure. We had this option in our mind, however, it is not scalable which will slow the main thread down, instead, we'd rather to speed up main thread and move reasonable workload to the threads.