Skip to content

Commit e03d4bc

Browse files
ShadowCursebchalios
authored andcommitted
net: use readv for reading frames from TAP device
Right now, we are performing two copies for writing a frame from the TAP device into guest memory. We first read the frame in an array held by the Net device and then copy that array in a DescriptorChain. In order to avoid the double copy use the readv system call to read directly from the TAP device into the buffers described by DescriptorChain. The main challenge with this is that DescriptorChain objects describe memory that is at least 65562 bytes long when guest TSO4, TSO6 or UFO are enabled or 1526 otherwise and parsing the chain includes overhead which we pay even if the frame we are receiving is much smaller than these sizes. PR #4748 reduced the overheads involved with parsing DescriptorChain objects. To further avoid this overhead, move the parsing of DescriptorChain objects out of the hot path of process_rx() where we are actually receiving a frame into process_rx_queue_event() where we get the notification that the guest added new buffers for network RX. Co-authored-by: Babis Chalios <[email protected]> Signed-off-by: Egor Lazarchuk <[email protected]>
1 parent dfe87db commit e03d4bc

File tree

6 files changed

+363
-296
lines changed

6 files changed

+363
-296
lines changed

resources/seccomp/aarch64-unknown-linux-musl.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
"syscall": "writev",
3333
"comment": "Used by the VirtIO net device to write to tap"
3434
},
35+
{
36+
"syscall": "readv",
37+
"comment": "Used by the VirtIO net device to read from tap"
38+
},
3539
{
3640
"syscall": "fsync"
3741
},

resources/seccomp/x86_64-unknown-linux-musl.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
"syscall": "writev",
3333
"comment": "Used by the VirtIO net device to write to tap"
3434
},
35+
{
36+
"syscall": "readv",
37+
"comment": "Used by the VirtIO net device to read from tap"
38+
},
3539
{
3640
"syscall": "fsync"
3741
},

0 commit comments

Comments
 (0)