All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Michael Dalton <mwdalton@google.com>
Cc: netdev@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	Eric Dumazet <edumazet@google.com>,
	Ben Hutchings <bhutchings@solarflare.com>,
	"David S. Miller" <davem@davemloft.net>
Subject: Re: [PATCH net-next v4 6/6] virtio-net: initial rx sysfs support, export mergeable rx buffer size
Date: Thu, 16 Jan 2014 22:25:38 +0200	[thread overview]
Message-ID: <20140116202538.GK29522@redhat.com> (raw)
In-Reply-To: <1389901950-3854-6-git-send-email-mwdalton@google.com>

On Thu, Jan 16, 2014 at 11:52:30AM -0800, Michael Dalton wrote:
> Add initial support for per-rx queue sysfs attributes to virtio-net. If
> mergeable packet buffers are enabled, adds a read-only mergeable packet
> buffer size sysfs attribute for each RX queue.
> 
> Suggested-by: Michael S. Tsirkin <mst@redhat.com>
> Signed-off-by: Michael Dalton <mwdalton@google.com>

Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
> v3->v4: Remove seqcount due to EWMA changes in patch 5.
>         Add missing Suggested-By.
> 
>  drivers/net/virtio_net.c | 46 ++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 42 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 3e82311..968eacd 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -604,18 +604,25 @@ static int add_recvbuf_big(struct receive_queue *rq, gfp_t gfp)
>  	return err;
>  }
>  
> -static int add_recvbuf_mergeable(struct receive_queue *rq, gfp_t gfp)
> +static unsigned int get_mergeable_buf_len(struct ewma *avg_pkt_len)
>  {
>  	const size_t hdr_len = sizeof(struct virtio_net_hdr_mrg_rxbuf);
> +	unsigned int len;
> +
> +	len = hdr_len + clamp_t(unsigned int, ewma_read(avg_pkt_len),
> +			GOOD_PACKET_LEN, PAGE_SIZE - hdr_len);
> +	return ALIGN(len, MERGEABLE_BUFFER_ALIGN);
> +}
> +
> +static int add_recvbuf_mergeable(struct receive_queue *rq, gfp_t gfp)
> +{
>  	struct page_frag *alloc_frag = &rq->alloc_frag;
>  	char *buf;
>  	unsigned long ctx;
>  	int err;
>  	unsigned int len, hole;
>  
> -	len = hdr_len + clamp_t(unsigned int, ewma_read(&rq->mrg_avg_pkt_len),
> -				GOOD_PACKET_LEN, PAGE_SIZE - hdr_len);
> -	len = ALIGN(len, MERGEABLE_BUFFER_ALIGN);
> +	len = get_mergeable_buf_len(&rq->mrg_avg_pkt_len);
>  	if (unlikely(!skb_page_frag_refill(len, alloc_frag, gfp)))
>  		return -ENOMEM;
>  
> @@ -1594,6 +1601,33 @@ err:
>  	return ret;
>  }
>  
> +#ifdef CONFIG_SYSFS
> +static ssize_t mergeable_rx_buffer_size_show(struct netdev_rx_queue *queue,
> +		struct rx_queue_attribute *attribute, char *buf)
> +{
> +	struct virtnet_info *vi = netdev_priv(queue->dev);
> +	unsigned int queue_index = get_netdev_rx_queue_index(queue);
> +	struct ewma *avg;
> +
> +	BUG_ON(queue_index >= vi->max_queue_pairs);
> +	avg = &vi->rq[queue_index].mrg_avg_pkt_len;
> +	return sprintf(buf, "%u\n", get_mergeable_buf_len(avg));
> +}
> +
> +static struct rx_queue_attribute mergeable_rx_buffer_size_attribute =
> +	__ATTR_RO(mergeable_rx_buffer_size);
> +
> +static struct attribute *virtio_net_mrg_rx_attrs[] = {
> +	&mergeable_rx_buffer_size_attribute.attr,
> +	NULL
> +};
> +
> +static const struct attribute_group virtio_net_mrg_rx_group = {
> +	.name = "virtio_net",
> +	.attrs = virtio_net_mrg_rx_attrs
> +};
> +#endif
> +
>  static int virtnet_probe(struct virtio_device *vdev)
>  {
>  	int i, err;
> @@ -1708,6 +1742,10 @@ static int virtnet_probe(struct virtio_device *vdev)
>  	if (err)
>  		goto free_stats;
>  
> +#ifdef CONFIG_SYSFS
> +	if (vi->mergeable_rx_bufs)
> +		dev->sysfs_rx_queue_group = &virtio_net_mrg_rx_group;
> +#endif
>  	netif_set_real_num_tx_queues(dev, vi->curr_queue_pairs);
>  	netif_set_real_num_rx_queues(dev, vi->curr_queue_pairs);
>  
> -- 
> 1.8.5.2

  reply	other threads:[~2014-01-16 20:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-16 19:52 [PATCH net-next v4 1/6] net: allow > 0 order atomic page alloc in skb_page_frag_refill Michael Dalton
2014-01-16 19:52 ` [PATCH net-next v4 2/6] virtio-net: use per-receive queue page frag alloc for mergeable bufs Michael Dalton
2014-01-16 20:24   ` Michael S. Tsirkin
2014-01-16 19:52 ` [PATCH net-next v4 3/6] virtio-net: auto-tune mergeable rx buffer size for improved performance Michael Dalton
2014-01-16 20:24   ` Michael S. Tsirkin
2014-01-16 19:52 ` Michael Dalton
2014-01-16 19:52 ` [PATCH net-next v4 4/6] net-sysfs: add support for device-specific rx queue sysfs attributes Michael Dalton
2014-01-16 20:25   ` Michael S. Tsirkin
2014-01-16 19:52 ` [PATCH net-next v4 5/6] lib: Ensure EWMA does not store wrong intermediate values Michael Dalton
2014-01-16 20:08   ` Eric Dumazet
2014-01-16 20:25   ` Michael S. Tsirkin
2014-01-16 19:52 ` [PATCH net-next v4 6/6] virtio-net: initial rx sysfs support, export mergeable rx buffer size Michael Dalton
2014-01-16 19:52 ` Michael Dalton
2014-01-16 20:25   ` Michael S. Tsirkin [this message]
2014-01-16 23:28 ` [PATCH net-next v4 1/6] net: allow > 0 order atomic page alloc in skb_page_frag_refill David Miller
2014-01-16 23:30   ` David Miller
2014-01-16 23:30   ` David Miller
2014-01-17  0:30     ` Michael Dalton
2014-01-17  0:30     ` Michael Dalton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140116202538.GK29522@redhat.com \
    --to=mst@redhat.com \
    --cc=bhutchings@solarflare.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=mwdalton@google.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.