All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: John Fastabend <john.fastabend@gmail.com>,
	Jason Wang <jasowang@redhat.com>,
	virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org
Subject: [PATCH 6/6] virtio_net: reduce alignment for buffers
Date: Wed, 29 Mar 2017 23:48:56 +0300	[thread overview]
Message-ID: <1490820507-8005-7-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1490820507-8005-1-git-send-email-mst@redhat.com>

We don't need to align length to any particular
value anymore. Aligning to L1 cache size probably
sill makes sense to reduce false sharing.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/net/virtio_net.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 94f94f3..824dd95 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -53,17 +53,6 @@ module_param(gso, bool, 0444);
  */
 DECLARE_EWMA(pkt_len, 0, 64)
 
-/* With mergeable buffers we align buffer address and use the low bits to
- * encode its true size. Buffer size is up to 1 page so we need to align to
- * square root of page size to ensure we reserve enough bits to encode the true
- * size.
- */
-#define MERGEABLE_BUFFER_MIN_ALIGN_SHIFT ((PAGE_SHIFT + 1) / 2)
-
-/* Minimum alignment for mergeable packet buffers. */
-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, \
-				   1 << MERGEABLE_BUFFER_MIN_ALIGN_SHIFT)
-
 #define VIRTNET_DRIVER_VERSION "1.0.0"
 
 struct virtnet_stats {
@@ -849,7 +838,7 @@ static unsigned int get_mergeable_buf_len(struct ewma_pkt_len *avg_pkt_len)
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
 			GOOD_PACKET_LEN, PAGE_SIZE - hdr_len);
-	return ALIGN(len, MERGEABLE_BUFFER_ALIGN);
+	return ALIGN(len, L1_CACHE_BYTES);
 }
 
 static int add_recvbuf_mergeable(struct virtnet_info *vi,
-- 
MST

WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, John Fastabend <john.fastabend@gmail.com>,
	virtualization@lists.linux-foundation.org
Subject: [PATCH 6/6] virtio_net: reduce alignment for buffers
Date: Wed, 29 Mar 2017 23:48:56 +0300	[thread overview]
Message-ID: <1490820507-8005-7-git-send-email-mst@redhat.com> (raw)
In-Reply-To: <1490820507-8005-1-git-send-email-mst@redhat.com>

We don't need to align length to any particular
value anymore. Aligning to L1 cache size probably
sill makes sense to reduce false sharing.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 drivers/net/virtio_net.c | 13 +------------
 1 file changed, 1 insertion(+), 12 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 94f94f3..824dd95 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -53,17 +53,6 @@ module_param(gso, bool, 0444);
  */
 DECLARE_EWMA(pkt_len, 0, 64)
 
-/* With mergeable buffers we align buffer address and use the low bits to
- * encode its true size. Buffer size is up to 1 page so we need to align to
- * square root of page size to ensure we reserve enough bits to encode the true
- * size.
- */
-#define MERGEABLE_BUFFER_MIN_ALIGN_SHIFT ((PAGE_SHIFT + 1) / 2)
-
-/* Minimum alignment for mergeable packet buffers. */
-#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, \
-				   1 << MERGEABLE_BUFFER_MIN_ALIGN_SHIFT)
-
 #define VIRTNET_DRIVER_VERSION "1.0.0"
 
 struct virtnet_stats {
@@ -849,7 +838,7 @@ static unsigned int get_mergeable_buf_len(struct ewma_pkt_len *avg_pkt_len)
 
 	len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
 			GOOD_PACKET_LEN, PAGE_SIZE - hdr_len);
-	return ALIGN(len, MERGEABLE_BUFFER_ALIGN);
+	return ALIGN(len, L1_CACHE_BYTES);
 }
 
 static int add_recvbuf_mergeable(struct virtnet_info *vi,
-- 
MST

  parent reply	other threads:[~2017-03-29 20:50 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-29 20:48 [PATCH 0/6] virtio: support extra per-buffer context Michael S. Tsirkin
2017-03-29 20:48 ` [PATCH 1/6] virtio: wrap find_vqs Michael S. Tsirkin
2017-03-29 20:48   ` Michael S. Tsirkin
2017-03-30  0:50   ` Gonglei (Arei)
2017-03-30  0:50   ` Gonglei (Arei)
2017-03-30  0:50     ` Gonglei (Arei)
2017-03-30  0:50     ` Gonglei (Arei)
2017-03-30  0:50     ` Gonglei (Arei)
2017-03-30  6:00   ` Jason Wang
2017-03-30  6:00   ` Jason Wang
2017-03-30  6:00     ` Jason Wang
2017-03-30 14:32     ` Michael S. Tsirkin
2017-03-30 14:32       ` Michael S. Tsirkin
2017-03-31  4:04       ` Jason Wang
2017-03-31  4:04       ` Jason Wang
2017-03-31  4:04         ` Jason Wang
2017-03-31 16:21         ` Michael S. Tsirkin
2017-03-31 16:21           ` Michael S. Tsirkin
2017-03-31 16:21         ` Michael S. Tsirkin
2017-03-30 14:32     ` Michael S. Tsirkin
2017-03-30  7:18   ` Cornelia Huck
2017-03-30  7:18     ` Cornelia Huck
2017-03-30  7:18   ` Cornelia Huck
2017-04-01 16:13   ` Bjorn Andersson
2017-04-01 16:13     ` Bjorn Andersson
2017-03-29 20:48 ` [PATCH 2/6] virtio: add context flag to find vqs Michael S. Tsirkin
2017-03-29 20:48   ` Michael S. Tsirkin
2017-03-30  7:17   ` Cornelia Huck
2017-03-30  7:17     ` Cornelia Huck
2017-03-30 14:57     ` Michael S. Tsirkin
2017-03-30 14:57       ` Michael S. Tsirkin
2017-03-30  7:17   ` Cornelia Huck
2017-03-29 20:48 ` [PATCH 3/6] virtio: allow extra context per descriptor Michael S. Tsirkin
2017-03-29 20:48   ` Michael S. Tsirkin
2017-03-30  7:23   ` Cornelia Huck
2017-03-30  7:23     ` Cornelia Huck
2017-03-30 14:34     ` Michael S. Tsirkin
2017-03-30 14:34       ` Michael S. Tsirkin
2017-03-29 20:48 ` [PATCH 4/6] virtio_net: allow specifying context for rx Michael S. Tsirkin
2017-03-29 20:48   ` Michael S. Tsirkin
2017-03-30  7:26   ` Cornelia Huck
2017-03-30 14:31     ` Michael S. Tsirkin
2017-03-30 14:46       ` Cornelia Huck
2017-03-30 14:46         ` Cornelia Huck
2017-03-30 14:31     ` Michael S. Tsirkin
2017-03-30  7:26   ` Cornelia Huck
2017-03-29 20:48 ` [PATCH 5/6] virtio_net: rework mergeable buffer handling Michael S. Tsirkin
2017-03-29 20:48   ` Michael S. Tsirkin
2017-03-29 20:48 ` Michael S. Tsirkin [this message]
2017-03-29 20:48   ` [PATCH 6/6] virtio_net: reduce alignment for buffers Michael S. Tsirkin

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=1490820507-8005-7-git-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=john.fastabend@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --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.