From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 135F15A for ; Wed, 20 Mar 2019 05:40:43 +0100 (CET) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 21:40:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,247,1549958400"; d="scan'208";a="284170051" Received: from dpdk-tbie.sh.intel.com ([10.67.104.173]) by orsmga004.jf.intel.com with ESMTP; 19 Mar 2019 21:40:41 -0700 Date: Wed, 20 Mar 2019 12:40:26 +0800 From: Tiwei Bie To: Kevin Traynor Cc: Maxime Coquelin , Jens Freimann , zhihong.wang@intel.com, dev@dpdk.org Message-ID: <20190320044026.GA23715@dpdk-tbie.sh.intel.com> References: <20190319064312.13743-1-tiwei.bie@intel.com> <20190319064312.13743-6-tiwei.bie@intel.com> <20190319094432.iap4i7ffs6soukr7@jenstp.localdomain> <20190319100939.GA3839@dpdk-tbie.sh.intel.com> <20190319134751.ibgaalfravjm77lh@jenstp.localdomain> <1d05e311-c60b-cb1d-ff2b-974e01a0451b@redhat.com> <64884489-8cc7-7c3f-5b65-09f46112adb0@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <64884489-8cc7-7c3f-5b65-09f46112adb0@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 05/10] net/virtio: refactor virtqueue structure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2019 04:40:44 -0000 On Tue, Mar 19, 2019 at 02:59:38PM +0000, Kevin Traynor wrote: > On 19/03/2019 13:50, Maxime Coquelin wrote: > > > > > > On 3/19/19 2:47 PM, Jens Freimann wrote: > >> On Tue, Mar 19, 2019 at 02:28:30PM +0100, Maxime Coquelin wrote: > >>> > >>> > >>> On 3/19/19 11:09 AM, Tiwei Bie wrote: > >>>> On Tue, Mar 19, 2019 at 10:44:32AM +0100, Jens Freimann wrote: > >>>>> On Tue, Mar 19, 2019 at 02:43:07PM +0800, Tiwei Bie wrote: > >>>>>> Put split ring and packed ring specific fields into separate > >>>>>> sub-structures, and also union them as they won't be available > >>>>>> at the same time. > >>>>>> > >>>>>> Signed-off-by: Tiwei Bie > >>>>>> --- > >>>>>> drivers/net/virtio/virtio_ethdev.c           | 71 +++++++++--------- > >>>>>> drivers/net/virtio/virtio_rxtx.c             | 66 ++++++++--------- > >>>>>> drivers/net/virtio/virtio_rxtx_simple.h      |  2 +- > >>>>>> drivers/net/virtio/virtio_rxtx_simple_neon.c |  2 +- > >>>>>> drivers/net/virtio/virtio_rxtx_simple_sse.c  |  2 +- > >>>>>> drivers/net/virtio/virtqueue.c               |  6 +- > >>>>>> drivers/net/virtio/virtqueue.h               | 77 +++++++++++--------- > >>>>>> 7 files changed, 117 insertions(+), 109 deletions(-) > >>>>>> > >>>>> [snip] > >>>>> ... > >>>>>> diff --git a/drivers/net/virtio/virtqueue.h > >>>>>> b/drivers/net/virtio/virtqueue.h > >>>>>> index 80c0c43c3..48b3912e6 100644 > >>>>>> --- a/drivers/net/virtio/virtqueue.h > >>>>>> +++ b/drivers/net/virtio/virtqueue.h > >>>>>> @@ -191,17 +191,22 @@ struct vq_desc_extra { > >>>>>> > >>>>>> struct virtqueue { > >>>>>>     struct virtio_hw  *hw; /**< virtio_hw structure pointer. */ > >>>>>> -    struct vring vq_ring;  /**< vring keeping desc, used and avail */ > >>>>>> -    struct vring_packed ring_packed;  /**< vring keeping descs */ > >>>>>> -    bool used_wrap_counter; > >>>>>> -    uint16_t cached_flags; /**< cached flags for descs */ > >>>>>> -    uint16_t event_flags_shadow; > >>>>>> +    union { > >>>>>> +        struct { > >>>>>> +            /**< vring keeping desc, used and avail */ > >>>>>> +            struct vring ring; > >>>>>> +        } vq_split; > >>>>>> > >>>>>> -    /** > >>>>>> -     * Last consumed descriptor in the used table, > >>>>>> -     * trails vq_ring.used->idx. > >>>>>> -     */ > >>>>>> -    uint16_t vq_used_cons_idx; > >>>>>> +        struct { > >>>>>> +            /**< vring keeping descs and events */ > >>>>>> +            struct vring_packed ring; > >>>>>> +            bool used_wrap_counter; > >>>>>> +            uint16_t cached_flags; /**< cached flags for descs */ > >>>>>> +            uint16_t event_flags_shadow; > >>>>>> +        } vq_packed; > >>>>>> +    }; > >>>>>> + > >>>>>> +    uint16_t vq_used_cons_idx; /**< last consumed descriptor */ > >>>>>>     uint16_t vq_nentries;  /**< vring desc numbers */ > >>>>>>     uint16_t vq_free_cnt;  /**< num of desc available */ > >>>>>>     uint16_t vq_avail_idx; /**< sync until needed */ > >>>>> > >>>>> Honest question: What do we really gain by putting it in a union? We > >>>>> save a little memory. But we also make code less readable IMHO. > >>>> > >>>> I think it will make it clear that fields like used_wrap_counter > >>>> are only available in packed ring which will make the code more > >>>> readable. > >>>> > >>>>> > >>>>> If we do this, can we at least shorten some variable names, like drop > >>>>> the vq_ prefix? (It's used everywhere like vq->vq_packed*, so with > >>>>> vq->packed* we don't loose any context). > >>>> > >>>> I prefer to have consistent prefix like most fields in this > >>>> structure (although some fields don't really follow this). > >>> > >>> As Jens, I tend to agree that the vq_ prefix is quite redundant. > >>> However, I think it is better to keep it in this patch for consistency. > >>> > >>> Maybe it can be remove in a separate patch later? > >> > >> I thought it might be convenient to change it now as we are touching > >> all related code anyway. But I also don't want to block the patch > >> because of > >> this cosmetic thing. So let's defer it to a later patch set. > > > > OK, when I meant later, I meant to remove vq_ prefix for all fields, not > > only vq_split & vq_packed. > > > > But yes, that's just cosmetic so let's keep it as is for now. > > > > I agree the vq_ prefix is not needed and I think the code is more > readable in general seeing the packed/split name when using the struct. > > Please also consider that cosmetic changes in multiple places likely > mean backports will not apply cleanly to the stable branches anymore, so > it does have a cost. Yeah, agree. > Although in this case, iirc packed rings are not in > 18.11, so fixes might need dedicated backports from authors anyway, and > there haven't been too many virtio backports to date. > > >> > >> regards, > >> Jens > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id EACFFA00E6 for ; Wed, 20 Mar 2019 05:40:45 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C5F31B19; Wed, 20 Mar 2019 05:40:45 +0100 (CET) Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by dpdk.org (Postfix) with ESMTP id 135F15A for ; Wed, 20 Mar 2019 05:40:43 +0100 (CET) X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2019 21:40:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,247,1549958400"; d="scan'208";a="284170051" Received: from dpdk-tbie.sh.intel.com ([10.67.104.173]) by orsmga004.jf.intel.com with ESMTP; 19 Mar 2019 21:40:41 -0700 Date: Wed, 20 Mar 2019 12:40:26 +0800 From: Tiwei Bie To: Kevin Traynor Cc: Maxime Coquelin , Jens Freimann , zhihong.wang@intel.com, dev@dpdk.org Message-ID: <20190320044026.GA23715@dpdk-tbie.sh.intel.com> References: <20190319064312.13743-1-tiwei.bie@intel.com> <20190319064312.13743-6-tiwei.bie@intel.com> <20190319094432.iap4i7ffs6soukr7@jenstp.localdomain> <20190319100939.GA3839@dpdk-tbie.sh.intel.com> <20190319134751.ibgaalfravjm77lh@jenstp.localdomain> <1d05e311-c60b-cb1d-ff2b-974e01a0451b@redhat.com> <64884489-8cc7-7c3f-5b65-09f46112adb0@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <64884489-8cc7-7c3f-5b65-09f46112adb0@redhat.com> User-Agent: Mutt/1.9.4 (2018-02-28) Subject: Re: [dpdk-dev] [PATCH 05/10] net/virtio: refactor virtqueue structure X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Message-ID: <20190320044026.LPCcS0UOKMa0JRbrhIcse3a850rM-46sxvQoWx0uiyw@z> On Tue, Mar 19, 2019 at 02:59:38PM +0000, Kevin Traynor wrote: > On 19/03/2019 13:50, Maxime Coquelin wrote: > > > > > > On 3/19/19 2:47 PM, Jens Freimann wrote: > >> On Tue, Mar 19, 2019 at 02:28:30PM +0100, Maxime Coquelin wrote: > >>> > >>> > >>> On 3/19/19 11:09 AM, Tiwei Bie wrote: > >>>> On Tue, Mar 19, 2019 at 10:44:32AM +0100, Jens Freimann wrote: > >>>>> On Tue, Mar 19, 2019 at 02:43:07PM +0800, Tiwei Bie wrote: > >>>>>> Put split ring and packed ring specific fields into separate > >>>>>> sub-structures, and also union them as they won't be available > >>>>>> at the same time. > >>>>>> > >>>>>> Signed-off-by: Tiwei Bie > >>>>>> --- > >>>>>> drivers/net/virtio/virtio_ethdev.c           | 71 +++++++++--------- > >>>>>> drivers/net/virtio/virtio_rxtx.c             | 66 ++++++++--------- > >>>>>> drivers/net/virtio/virtio_rxtx_simple.h      |  2 +- > >>>>>> drivers/net/virtio/virtio_rxtx_simple_neon.c |  2 +- > >>>>>> drivers/net/virtio/virtio_rxtx_simple_sse.c  |  2 +- > >>>>>> drivers/net/virtio/virtqueue.c               |  6 +- > >>>>>> drivers/net/virtio/virtqueue.h               | 77 +++++++++++--------- > >>>>>> 7 files changed, 117 insertions(+), 109 deletions(-) > >>>>>> > >>>>> [snip] > >>>>> ... > >>>>>> diff --git a/drivers/net/virtio/virtqueue.h > >>>>>> b/drivers/net/virtio/virtqueue.h > >>>>>> index 80c0c43c3..48b3912e6 100644 > >>>>>> --- a/drivers/net/virtio/virtqueue.h > >>>>>> +++ b/drivers/net/virtio/virtqueue.h > >>>>>> @@ -191,17 +191,22 @@ struct vq_desc_extra { > >>>>>> > >>>>>> struct virtqueue { > >>>>>>     struct virtio_hw  *hw; /**< virtio_hw structure pointer. */ > >>>>>> -    struct vring vq_ring;  /**< vring keeping desc, used and avail */ > >>>>>> -    struct vring_packed ring_packed;  /**< vring keeping descs */ > >>>>>> -    bool used_wrap_counter; > >>>>>> -    uint16_t cached_flags; /**< cached flags for descs */ > >>>>>> -    uint16_t event_flags_shadow; > >>>>>> +    union { > >>>>>> +        struct { > >>>>>> +            /**< vring keeping desc, used and avail */ > >>>>>> +            struct vring ring; > >>>>>> +        } vq_split; > >>>>>> > >>>>>> -    /** > >>>>>> -     * Last consumed descriptor in the used table, > >>>>>> -     * trails vq_ring.used->idx. > >>>>>> -     */ > >>>>>> -    uint16_t vq_used_cons_idx; > >>>>>> +        struct { > >>>>>> +            /**< vring keeping descs and events */ > >>>>>> +            struct vring_packed ring; > >>>>>> +            bool used_wrap_counter; > >>>>>> +            uint16_t cached_flags; /**< cached flags for descs */ > >>>>>> +            uint16_t event_flags_shadow; > >>>>>> +        } vq_packed; > >>>>>> +    }; > >>>>>> + > >>>>>> +    uint16_t vq_used_cons_idx; /**< last consumed descriptor */ > >>>>>>     uint16_t vq_nentries;  /**< vring desc numbers */ > >>>>>>     uint16_t vq_free_cnt;  /**< num of desc available */ > >>>>>>     uint16_t vq_avail_idx; /**< sync until needed */ > >>>>> > >>>>> Honest question: What do we really gain by putting it in a union? We > >>>>> save a little memory. But we also make code less readable IMHO. > >>>> > >>>> I think it will make it clear that fields like used_wrap_counter > >>>> are only available in packed ring which will make the code more > >>>> readable. > >>>> > >>>>> > >>>>> If we do this, can we at least shorten some variable names, like drop > >>>>> the vq_ prefix? (It's used everywhere like vq->vq_packed*, so with > >>>>> vq->packed* we don't loose any context). > >>>> > >>>> I prefer to have consistent prefix like most fields in this > >>>> structure (although some fields don't really follow this). > >>> > >>> As Jens, I tend to agree that the vq_ prefix is quite redundant. > >>> However, I think it is better to keep it in this patch for consistency. > >>> > >>> Maybe it can be remove in a separate patch later? > >> > >> I thought it might be convenient to change it now as we are touching > >> all related code anyway. But I also don't want to block the patch > >> because of > >> this cosmetic thing. So let's defer it to a later patch set. > > > > OK, when I meant later, I meant to remove vq_ prefix for all fields, not > > only vq_split & vq_packed. > > > > But yes, that's just cosmetic so let's keep it as is for now. > > > > I agree the vq_ prefix is not needed and I think the code is more > readable in general seeing the packed/split name when using the struct. > > Please also consider that cosmetic changes in multiple places likely > mean backports will not apply cleanly to the stable branches anymore, so > it does have a cost. Yeah, agree. > Although in this case, iirc packed rings are not in > 18.11, so fixes might need dedicated backports from authors anyway, and > there haven't been too many virtio backports to date. > > >> > >> regards, > >> Jens >