* [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb()
@ 2016-03-18 15:42 Paolo Abeni
0 siblings, 0 replies; 6+ messages in thread
From: Paolo Abeni @ 2016-03-18 15:42 UTC (permalink / raw)
To: netdev; +Cc: virtualization, Hannes Frederic Sowa, Michael S. Tsirkin
This gives small but noticeable rx performance improvement (2-3%)
and will allow exploiting future napi improvement.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
--
v2: replace also netdev_alloc_skb_ip_align() invocation in
add_recvbuf_small(), suggested by Venkatesh Srinivas
---
drivers/net/virtio_net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fb0eae4..100e039 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -260,7 +260,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
p = page_address(page) + offset;
/* copy small packet so we can reuse these pages for small data */
- skb = netdev_alloc_skb_ip_align(vi->dev, GOOD_COPY_LEN);
+ skb = napi_alloc_skb(&rq->napi, GOOD_COPY_LEN);
if (unlikely(!skb))
return NULL;
@@ -541,7 +541,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
struct virtio_net_hdr_mrg_rxbuf *hdr;
int err;
- skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
+ skb = __napi_alloc_skb(&rq->napi, GOOD_PACKET_LEN, gfp);
if (unlikely(!skb))
return -ENOMEM;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb()
2016-03-18 15:42 Paolo Abeni
` (2 preceding siblings ...)
2016-03-20 12:28 ` Michael S. Tsirkin
@ 2016-03-20 12:28 ` Michael S. Tsirkin
3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2016-03-20 12:28 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, virtualization, Hannes Frederic Sowa, Venkatesh Srinivas
On Fri, Mar 18, 2016 at 04:42:48PM +0100, Paolo Abeni wrote:
> This gives small but noticeable rx performance improvement (2-3%)
> and will allow exploiting future napi improvement.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
I am not sure this is necessarily worth doing for this dumb hardware.
I queued v1 in vhost tree for now, let's see some performance
numbers before we start changing about other paths.
> --
> v2: replace also netdev_alloc_skb_ip_align() invocation in
> add_recvbuf_small(), suggested by Venkatesh Srinivas
> ---
> drivers/net/virtio_net.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fb0eae4..100e039 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -260,7 +260,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> p = page_address(page) + offset;
>
> /* copy small packet so we can reuse these pages for small data */
> - skb = netdev_alloc_skb_ip_align(vi->dev, GOOD_COPY_LEN);
> + skb = napi_alloc_skb(&rq->napi, GOOD_COPY_LEN);
> if (unlikely(!skb))
> return NULL;
>
> @@ -541,7 +541,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
> struct virtio_net_hdr_mrg_rxbuf *hdr;
> int err;
>
> - skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
> + skb = __napi_alloc_skb(&rq->napi, GOOD_PACKET_LEN, gfp);
> if (unlikely(!skb))
> return -ENOMEM;
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb()
2016-03-18 15:42 Paolo Abeni
2016-03-18 15:58 ` Venkatesh Srinivas via Virtualization
2016-03-18 15:58 ` Venkatesh Srinivas
@ 2016-03-20 12:28 ` Michael S. Tsirkin
2016-03-20 12:28 ` Michael S. Tsirkin
3 siblings, 0 replies; 6+ messages in thread
From: Michael S. Tsirkin @ 2016-03-20 12:28 UTC (permalink / raw)
To: Paolo Abeni; +Cc: netdev, Hannes Frederic Sowa, virtualization
On Fri, Mar 18, 2016 at 04:42:48PM +0100, Paolo Abeni wrote:
> This gives small but noticeable rx performance improvement (2-3%)
> and will allow exploiting future napi improvement.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
I am not sure this is necessarily worth doing for this dumb hardware.
I queued v1 in vhost tree for now, let's see some performance
numbers before we start changing about other paths.
> --
> v2: replace also netdev_alloc_skb_ip_align() invocation in
> add_recvbuf_small(), suggested by Venkatesh Srinivas
> ---
> drivers/net/virtio_net.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fb0eae4..100e039 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -260,7 +260,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> p = page_address(page) + offset;
>
> /* copy small packet so we can reuse these pages for small data */
> - skb = netdev_alloc_skb_ip_align(vi->dev, GOOD_COPY_LEN);
> + skb = napi_alloc_skb(&rq->napi, GOOD_COPY_LEN);
> if (unlikely(!skb))
> return NULL;
>
> @@ -541,7 +541,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
> struct virtio_net_hdr_mrg_rxbuf *hdr;
> int err;
>
> - skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
> + skb = __napi_alloc_skb(&rq->napi, GOOD_PACKET_LEN, gfp);
> if (unlikely(!skb))
> return -ENOMEM;
>
> --
> 1.8.3.1
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb()
2016-03-18 15:42 Paolo Abeni
2016-03-18 15:58 ` Venkatesh Srinivas via Virtualization
@ 2016-03-18 15:58 ` Venkatesh Srinivas
2016-03-20 12:28 ` Michael S. Tsirkin
2016-03-20 12:28 ` Michael S. Tsirkin
3 siblings, 0 replies; 6+ messages in thread
From: Venkatesh Srinivas @ 2016-03-18 15:58 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, Michael S. Tsirkin, virtualization, Hannes Frederic Sowa
On Fri, Mar 18, 2016 at 8:42 AM, Paolo Abeni <pabeni@redhat.com> wrote:
> This gives small but noticeable rx performance improvement (2-3%)
> and will allow exploiting future napi improvement.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> --
> v2: replace also netdev_alloc_skb_ip_align() invocation in
> add_recvbuf_small(), suggested by Venkatesh Srinivas
> ---
> drivers/net/virtio_net.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fb0eae4..100e039 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -260,7 +260,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> p = page_address(page) + offset;
>
> /* copy small packet so we can reuse these pages for small data */
> - skb = netdev_alloc_skb_ip_align(vi->dev, GOOD_COPY_LEN);
> + skb = napi_alloc_skb(&rq->napi, GOOD_COPY_LEN);
> if (unlikely(!skb))
> return NULL;
>
> @@ -541,7 +541,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
> struct virtio_net_hdr_mrg_rxbuf *hdr;
> int err;
>
> - skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
> + skb = __napi_alloc_skb(&rq->napi, GOOD_PACKET_LEN, gfp);
> if (unlikely(!skb))
> return -ENOMEM;
Sorry, I should've mentioned more in my first reply --
add_recvbuf_small is called from try_fill_recv in both
NAPI and non-NAPI context (NAPI: via virtnet_receive from
virtnet_poll; non-NAPI: via scheduled work,
via virtnet_probe, and via virtnet_restore).
I don't believe you can use __napi_alloc_skb() for the non-NAPI paths,
it'd be a bit more work to plumb
the context as an argument if you think its worth doing here.
Looking forward to bulk skb allocation either way.
HTH,
-- vs;
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb()
2016-03-18 15:42 Paolo Abeni
@ 2016-03-18 15:58 ` Venkatesh Srinivas via Virtualization
2016-03-18 15:58 ` Venkatesh Srinivas
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Venkatesh Srinivas via Virtualization @ 2016-03-18 15:58 UTC (permalink / raw)
To: Paolo Abeni
Cc: netdev, virtualization, Hannes Frederic Sowa, Michael S. Tsirkin
On Fri, Mar 18, 2016 at 8:42 AM, Paolo Abeni <pabeni@redhat.com> wrote:
> This gives small but noticeable rx performance improvement (2-3%)
> and will allow exploiting future napi improvement.
>
> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
>
> --
> v2: replace also netdev_alloc_skb_ip_align() invocation in
> add_recvbuf_small(), suggested by Venkatesh Srinivas
> ---
> drivers/net/virtio_net.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index fb0eae4..100e039 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -260,7 +260,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
> p = page_address(page) + offset;
>
> /* copy small packet so we can reuse these pages for small data */
> - skb = netdev_alloc_skb_ip_align(vi->dev, GOOD_COPY_LEN);
> + skb = napi_alloc_skb(&rq->napi, GOOD_COPY_LEN);
> if (unlikely(!skb))
> return NULL;
>
> @@ -541,7 +541,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
> struct virtio_net_hdr_mrg_rxbuf *hdr;
> int err;
>
> - skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
> + skb = __napi_alloc_skb(&rq->napi, GOOD_PACKET_LEN, gfp);
> if (unlikely(!skb))
> return -ENOMEM;
Sorry, I should've mentioned more in my first reply --
add_recvbuf_small is called from try_fill_recv in both
NAPI and non-NAPI context (NAPI: via virtnet_receive from
virtnet_poll; non-NAPI: via scheduled work,
via virtnet_probe, and via virtnet_restore).
I don't believe you can use __napi_alloc_skb() for the non-NAPI paths,
it'd be a bit more work to plumb
the context as an argument if you think its worth doing here.
Looking forward to bulk skb allocation either way.
HTH,
-- vs;
^ permalink raw reply [flat|nested] 6+ messages in thread
* [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb()
@ 2016-03-18 15:42 Paolo Abeni
2016-03-18 15:58 ` Venkatesh Srinivas via Virtualization
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Paolo Abeni @ 2016-03-18 15:42 UTC (permalink / raw)
To: netdev
Cc: Michael S. Tsirkin, virtualization, Hannes Frederic Sowa,
Venkatesh Srinivas
This gives small but noticeable rx performance improvement (2-3%)
and will allow exploiting future napi improvement.
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
--
v2: replace also netdev_alloc_skb_ip_align() invocation in
add_recvbuf_small(), suggested by Venkatesh Srinivas
---
drivers/net/virtio_net.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index fb0eae4..100e039 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -260,7 +260,7 @@ static struct sk_buff *page_to_skb(struct virtnet_info *vi,
p = page_address(page) + offset;
/* copy small packet so we can reuse these pages for small data */
- skb = netdev_alloc_skb_ip_align(vi->dev, GOOD_COPY_LEN);
+ skb = napi_alloc_skb(&rq->napi, GOOD_COPY_LEN);
if (unlikely(!skb))
return NULL;
@@ -541,7 +541,7 @@ static int add_recvbuf_small(struct virtnet_info *vi, struct receive_queue *rq,
struct virtio_net_hdr_mrg_rxbuf *hdr;
int err;
- skb = __netdev_alloc_skb_ip_align(vi->dev, GOOD_PACKET_LEN, gfp);
+ skb = __napi_alloc_skb(&rq->napi, GOOD_PACKET_LEN, gfp);
if (unlikely(!skb))
return -ENOMEM;
--
1.8.3.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-03-20 12:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-18 15:42 [net-next v2] virtio_net: replace netdev_alloc_skb_ip_align() with napi_alloc_skb() Paolo Abeni
2016-03-18 15:42 Paolo Abeni
2016-03-18 15:58 ` Venkatesh Srinivas via Virtualization
2016-03-18 15:58 ` Venkatesh Srinivas
2016-03-20 12:28 ` Michael S. Tsirkin
2016-03-20 12:28 ` Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.