Skip to content

Commit e377fcc

Browse files
committed
virtio_net: reduce alignment for buffers
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 <[email protected]>
1 parent 680557c commit e377fcc

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

drivers/net/virtio_net.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,6 @@ module_param(gso, bool, 0444);
5353
*/
5454
DECLARE_EWMA(pkt_len, 0, 64)
5555

56-
/* With mergeable buffers we align buffer address and use the low bits to
57-
* encode its true size. Buffer size is up to 1 page so we need to align to
58-
* square root of page size to ensure we reserve enough bits to encode the true
59-
* size.
60-
*/
61-
#define MERGEABLE_BUFFER_MIN_ALIGN_SHIFT ((PAGE_SHIFT + 1) / 2)
62-
63-
/* Minimum alignment for mergeable packet buffers. */
64-
#define MERGEABLE_BUFFER_ALIGN max(L1_CACHE_BYTES, \
65-
1 << MERGEABLE_BUFFER_MIN_ALIGN_SHIFT)
66-
6756
#define VIRTNET_DRIVER_VERSION "1.0.0"
6857

6958
struct virtnet_stats {
@@ -849,7 +838,7 @@ static unsigned int get_mergeable_buf_len(struct ewma_pkt_len *avg_pkt_len)
849838

850839
len = hdr_len + clamp_t(unsigned int, ewma_pkt_len_read(avg_pkt_len),
851840
GOOD_PACKET_LEN, PAGE_SIZE - hdr_len);
852-
return ALIGN(len, MERGEABLE_BUFFER_ALIGN);
841+
return ALIGN(len, L1_CACHE_BYTES);
853842
}
854843

855844
static int add_recvbuf_mergeable(struct virtnet_info *vi,

0 commit comments

Comments
 (0)