Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932323AbdCUKZS (ORCPT ); Tue, 21 Mar 2017 06:25:18 -0400 Received: from mail-lf0-f54.google.com ([209.85.215.54]:36262 "EHLO mail-lf0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756954AbdCUKZP (ORCPT ); Tue, 21 Mar 2017 06:25:15 -0400 Subject: Re: [PATCH net-next 1/8] ptr_ring: introduce batch dequeuing To: Jason Wang , mst@redhat.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <1490069087-4783-1-git-send-email-jasowang@redhat.com> <1490069087-4783-2-git-send-email-jasowang@redhat.com> From: Sergei Shtylyov Message-ID: <9ecd2a27-4f93-2b3f-cb91-c558976973a2@cogentembedded.com> Date: Tue, 21 Mar 2017 13:25:10 +0300 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <1490069087-4783-2-git-send-email-jasowang@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1066 Lines: 43 Hello! On 3/21/2017 7:04 AM, Jason Wang wrote: > Signed-off-by: Jason Wang > --- > include/linux/ptr_ring.h | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 65 insertions(+) > > diff --git a/include/linux/ptr_ring.h b/include/linux/ptr_ring.h > index 6c70444..4771ded 100644 > --- a/include/linux/ptr_ring.h > +++ b/include/linux/ptr_ring.h > @@ -247,6 +247,22 @@ static inline void *__ptr_ring_consume(struct ptr_ring *r) > return ptr; > } > > +static inline int __ptr_ring_consume_batched(struct ptr_ring *r, > + void **array, int n) > +{ > + void *ptr; > + int i = 0; > + > + while (i < n) { Hm, why not *for*? > + ptr = __ptr_ring_consume(r); > + if (!ptr) > + break; > + array[i++] = ptr; > + } > + > + return i; > +} > + > /* > * Note: resize (below) nests producer lock within consumer lock, so if you > * call this in interrupt or BH context, you must disable interrupts/BH when > @@ -297,6 +313,55 @@ static inline void *ptr_ring_consume_bh(struct ptr_ring *r) [...] MBR, Sergei