[v2,1/3] net/virtio: inline refill and offload helpers

Message ID 20181211134804.10318-2-maxime.coquelin@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series net/virtio: Rx paths improvements |

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Maxime Coquelin Dec. 11, 2018, 1:48 p.m. UTC
  Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 drivers/net/virtio/virtio_rxtx.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
  

Comments

Jens Freimann Dec. 19, 2018, 9:25 a.m. UTC | #1
On Tue, Dec 11, 2018 at 02:48:02PM +0100, Maxime Coquelin wrote:
>Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>---
> drivers/net/virtio/virtio_rxtx.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
>index eb891433e..e1c270b1c 100644
>--- a/drivers/net/virtio/virtio_rxtx.c
>+++ b/drivers/net/virtio/virtio_rxtx.c
>@@ -741,7 +741,7 @@ virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
> 	return 0;
> }
>
>-static void
>+static inline void
> virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
> {
> 	int error;
>@@ -757,7 +757,7 @@ virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
> 	}
> }
>
>-static void
>+static inline void
> virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
> {
> 	int error;
>@@ -769,7 +769,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
> 	}
> }
>
>-static void
>+static inline void
> virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
> {
> 	uint32_t s = mbuf->pkt_len;
>@@ -811,7 +811,7 @@ virtio_rx_stats_updated(struct virtnet_rx *rxvq, struct rte_mbuf *m)
> }
>
> /* Optionally fill offload information in structure */
>-static int
>+static inline int
> virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
> {
> 	struct rte_net_hdr_lens hdr_lens;

since these are all static functions, does declaring them inline
actually help or are they inlined anyway by the compiler?

regards,
Jens
  
Gavin Hu Dec. 19, 2018, 10:26 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Jens Freimann
> Sent: Wednesday, December 19, 2018 5:25 PM
> To: Maxime Coquelin <maxime.coquelin@redhat.com>
> Cc: dev@dpdk.org; tiwei.bie@intel.com; zhihong.wang@intel.com
> Subject: Re: [dpdk-dev] [PATCH v2 1/3] net/virtio: inline refill and offload
> helpers
> 
> On Tue, Dec 11, 2018 at 02:48:02PM +0100, Maxime Coquelin wrote:
> >Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> >---
> > drivers/net/virtio/virtio_rxtx.c | 8 ++++----
> > 1 file changed, 4 insertions(+), 4 deletions(-)
> >
> >diff --git a/drivers/net/virtio/virtio_rxtx.c
> >b/drivers/net/virtio/virtio_rxtx.c
> >index eb891433e..e1c270b1c 100644
> >--- a/drivers/net/virtio/virtio_rxtx.c
> >+++ b/drivers/net/virtio/virtio_rxtx.c
> >@@ -741,7 +741,7 @@ virtio_dev_tx_queue_setup_finish(struct
> rte_eth_dev *dev,
> > 	return 0;
> > }
> >
> >-static void
> >+static inline void
> > virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)  {
> > 	int error;
> >@@ -757,7 +757,7 @@ virtio_discard_rxbuf(struct virtqueue *vq, struct
> rte_mbuf *m)
> > 	}
> > }
> >
> >-static void
> >+static inline void
> > virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
> >{
> > 	int error;
> >@@ -769,7 +769,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq,
> struct rte_mbuf *m)
> > 	}
> > }
> >
> >-static void
> >+static inline void
> > virtio_update_packet_stats(struct virtnet_stats *stats, struct
> >rte_mbuf *mbuf)  {
> > 	uint32_t s = mbuf->pkt_len;
> >@@ -811,7 +811,7 @@ virtio_rx_stats_updated(struct virtnet_rx *rxvq,
> >struct rte_mbuf *m)  }
> >
> > /* Optionally fill offload information in structure */ -static int
> >+static inline int
> > virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) {
> > 	struct rte_net_hdr_lens hdr_lens;
> 
> since these are all static functions, does declaring them inline actually help
> or are they inlined anyway by the compiler?
> 
> regards,
> Jens

By disassembling the code, static function calls translate to "bl XXX", that means they are not inline.
Inline is not always working, maybe __rte_always_inline is required here? 
/Gavin
  
Jens Freimann Dec. 19, 2018, 10:53 a.m. UTC | #3
On Wed, Dec 19, 2018 at 10:26:10AM +0000, Gavin Hu (Arm Technology China) wrote:
>
>
>> -----Original Message-----
>> From: dev <dev-bounces@dpdk.org> On Behalf Of Jens Freimann
>> Sent: Wednesday, December 19, 2018 5:25 PM
>> To: Maxime Coquelin <maxime.coquelin@redhat.com>
>> Cc: dev@dpdk.org; tiwei.bie@intel.com; zhihong.wang@intel.com
>> Subject: Re: [dpdk-dev] [PATCH v2 1/3] net/virtio: inline refill and offload
>> helpers
>>
>> On Tue, Dec 11, 2018 at 02:48:02PM +0100, Maxime Coquelin wrote:
>> >Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>> >---
>> > drivers/net/virtio/virtio_rxtx.c | 8 ++++----
>> > 1 file changed, 4 insertions(+), 4 deletions(-)
>> >
>> >diff --git a/drivers/net/virtio/virtio_rxtx.c
>> >b/drivers/net/virtio/virtio_rxtx.c
>> >index eb891433e..e1c270b1c 100644
>> >--- a/drivers/net/virtio/virtio_rxtx.c
>> >+++ b/drivers/net/virtio/virtio_rxtx.c
>> >@@ -741,7 +741,7 @@ virtio_dev_tx_queue_setup_finish(struct
>> rte_eth_dev *dev,
>> > 	return 0;
>> > }
>> >
>> >-static void
>> >+static inline void
>> > virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)  {
>> > 	int error;
>> >@@ -757,7 +757,7 @@ virtio_discard_rxbuf(struct virtqueue *vq, struct
>> rte_mbuf *m)
>> > 	}
>> > }
>> >
>> >-static void
>> >+static inline void
>> > virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
>> >{
>> > 	int error;
>> >@@ -769,7 +769,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq,
>> struct rte_mbuf *m)
>> > 	}
>> > }
>> >
>> >-static void
>> >+static inline void
>> > virtio_update_packet_stats(struct virtnet_stats *stats, struct
>> >rte_mbuf *mbuf)  {
>> > 	uint32_t s = mbuf->pkt_len;
>> >@@ -811,7 +811,7 @@ virtio_rx_stats_updated(struct virtnet_rx *rxvq,
>> >struct rte_mbuf *m)  }
>> >
>> > /* Optionally fill offload information in structure */ -static int
>> >+static inline int
>> > virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) {
>> > 	struct rte_net_hdr_lens hdr_lens;
>>
>> since these are all static functions, does declaring them inline actually help
>> or are they inlined anyway by the compiler?
>>
>> regards,
>> Jens
>
>By disassembling the code, static function calls translate to "bl XXX", that means they are not inline.
>Inline is not always working, maybe __rte_always_inline is required here?

I think always_inline is only to force inline when no optimiziation is
done? https://gcc.gnu.org/onlinedocs/gcc/Inline.html

I don't know if there's a way to really force the compiler to inline
it or if it's better anyway to trust the compiler. 
It doesn't hurt to have the functions declared inline except that it
clutters code a bit, but I don't have strong feelings against leaving this
patch as is.  Leaving it to Maxime, so

Reviewed-by: Jens Freimann <jfreimann@redhat.com> 

regards,
Jens
  
Maxime Coquelin Dec. 19, 2018, 12:04 p.m. UTC | #4
On 12/19/18 11:53 AM, Jens Freimann wrote:
> On Wed, Dec 19, 2018 at 10:26:10AM +0000, Gavin Hu (Arm Technology 
> China) wrote:
>>
>>
>>> -----Original Message-----
>>> From: dev <dev-bounces@dpdk.org> On Behalf Of Jens Freimann
>>> Sent: Wednesday, December 19, 2018 5:25 PM
>>> To: Maxime Coquelin <maxime.coquelin@redhat.com>
>>> Cc: dev@dpdk.org; tiwei.bie@intel.com; zhihong.wang@intel.com
>>> Subject: Re: [dpdk-dev] [PATCH v2 1/3] net/virtio: inline refill and 
>>> offload
>>> helpers
>>>
>>> On Tue, Dec 11, 2018 at 02:48:02PM +0100, Maxime Coquelin wrote:
>>> >Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
>>> >---
>>> > drivers/net/virtio/virtio_rxtx.c | 8 ++++----
>>> > 1 file changed, 4 insertions(+), 4 deletions(-)
>>> >
>>> >diff --git a/drivers/net/virtio/virtio_rxtx.c
>>> >b/drivers/net/virtio/virtio_rxtx.c
>>> >index eb891433e..e1c270b1c 100644
>>> >--- a/drivers/net/virtio/virtio_rxtx.c
>>> >+++ b/drivers/net/virtio/virtio_rxtx.c
>>> >@@ -741,7 +741,7 @@ virtio_dev_tx_queue_setup_finish(struct
>>> rte_eth_dev *dev,
>>> >     return 0;
>>> > }
>>> >
>>> >-static void
>>> >+static inline void
>>> > virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)  {
>>> >     int error;
>>> >@@ -757,7 +757,7 @@ virtio_discard_rxbuf(struct virtqueue *vq, struct
>>> rte_mbuf *m)
>>> >     }
>>> > }
>>> >
>>> >-static void
>>> >+static inline void
>>> > virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
>>> >{
>>> >     int error;
>>> >@@ -769,7 +769,7 @@ virtio_discard_rxbuf_inorder(struct virtqueue *vq,
>>> struct rte_mbuf *m)
>>> >     }
>>> > }
>>> >
>>> >-static void
>>> >+static inline void
>>> > virtio_update_packet_stats(struct virtnet_stats *stats, struct
>>> >rte_mbuf *mbuf)  {
>>> >     uint32_t s = mbuf->pkt_len;
>>> >@@ -811,7 +811,7 @@ virtio_rx_stats_updated(struct virtnet_rx *rxvq,
>>> >struct rte_mbuf *m)  }
>>> >
>>> > /* Optionally fill offload information in structure */ -static int
>>> >+static inline int
>>> > virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr) {
>>> >     struct rte_net_hdr_lens hdr_lens;
>>>
>>> since these are all static functions, does declaring them inline 
>>> actually help
>>> or are they inlined anyway by the compiler?
>>>
>>> regards,
>>> Jens
>>
>> By disassembling the code, static function calls translate to "bl 
>> XXX", that means they are not inline.
>> Inline is not always working, maybe __rte_always_inline is required here?
> 
> I think always_inline is only to force inline when no optimiziation is
> done? https://gcc.gnu.org/onlinedocs/gcc/Inline.html
> 
> I don't know if there's a way to really force the compiler to inline
> it or if it's better anyway to trust the compiler. It doesn't hurt to 
> have the functions declared inline except that it
> clutters code a bit, but I don't have strong feelings against leaving this
> patch as is.  Leaving it to Maxime, so

I need to consider the use of __rte_always_inline generally in
virtio_rxtx.c.

In this specific case, inline seems enough.

> 
> Reviewed-by: Jens Freimann <jfreimann@redhat.com>

Thanks,
Maxime

> regards,
> Jens
  

Patch

diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index eb891433e..e1c270b1c 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -741,7 +741,7 @@  virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev,
 	return 0;
 }
 
-static void
+static inline void
 virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
 {
 	int error;
@@ -757,7 +757,7 @@  virtio_discard_rxbuf(struct virtqueue *vq, struct rte_mbuf *m)
 	}
 }
 
-static void
+static inline void
 virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
 {
 	int error;
@@ -769,7 +769,7 @@  virtio_discard_rxbuf_inorder(struct virtqueue *vq, struct rte_mbuf *m)
 	}
 }
 
-static void
+static inline void
 virtio_update_packet_stats(struct virtnet_stats *stats, struct rte_mbuf *mbuf)
 {
 	uint32_t s = mbuf->pkt_len;
@@ -811,7 +811,7 @@  virtio_rx_stats_updated(struct virtnet_rx *rxvq, struct rte_mbuf *m)
 }
 
 /* Optionally fill offload information in structure */
-static int
+static inline int
 virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
 {
 	struct rte_net_hdr_lens hdr_lens;