Skip to content

Commit 5d718d4

Browse files
committed
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. Signed-off-by: Babis Chalios <[email protected]>
1 parent 14e6e33 commit 5d718d4

File tree

6 files changed

+557
-297
lines changed

6 files changed

+557
-297
lines changed

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

+102
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,108 @@
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+
},
39+
{
40+
"syscall": "memfd_create",
41+
"comment": "Used by the IovDeque implementation"
42+
},
43+
{
44+
"syscall": "fcntl",
45+
"comment": "Used by the IovDeque implementation",
46+
"args": [
47+
{
48+
"index": 1,
49+
"type": "dword",
50+
"op": "eq",
51+
"val": 1033,
52+
"comment": "FCNTL_F_SETFD"
53+
},
54+
{
55+
"index": 2,
56+
"type": "dword",
57+
"op": "eq",
58+
"val": 6,
59+
"comment": "F_SEAL_SHRINK|F_SEAL_GROW"
60+
}
61+
]
62+
},
63+
{
64+
"syscall": "fcntl",
65+
"comment": "Used by the IovDeque implementation",
66+
"args": [
67+
{
68+
"index": 1,
69+
"type": "dword",
70+
"op": "eq",
71+
"val": 1033,
72+
"comment": "FCNTL_F_SETFD"
73+
},
74+
{
75+
"index": 2,
76+
"type": "dword",
77+
"op": "eq",
78+
"val": 1,
79+
"comment": "F_SEAL_SEAL"
80+
}
81+
]
82+
},
83+
{
84+
"syscall": "mmap",
85+
"comment": "Used by the IovDeque implementation",
86+
"args": [
87+
{
88+
"index": 1,
89+
"type": "dword",
90+
"op": "eq",
91+
"val": 4096,
92+
"comment": "Page size allocation"
93+
},
94+
{
95+
"index": 2,
96+
"type": "dword",
97+
"op": "eq",
98+
"val": 3,
99+
"comment": "PROT_READ|PROT_WRITE"
100+
},
101+
{
102+
"index": 3,
103+
"type": "dword",
104+
"op": "eq",
105+
"val": 17,
106+
"comment": "MAP_SHARED|MAP_FIXED"
107+
}
108+
]
109+
},
110+
{
111+
"syscall": "mmap",
112+
"comment": "Used by the IovDeque implementation",
113+
"args": [
114+
{
115+
"index": 1,
116+
"type": "dword",
117+
"op": "eq",
118+
"val": 8192,
119+
"comment": "2 pages allocation"
120+
},
121+
{
122+
"index": 2,
123+
"type": "dword",
124+
"op": "eq",
125+
"val": 0,
126+
"comment": "PROT_NONE"
127+
},
128+
{
129+
"index": 3,
130+
"type": "dword",
131+
"op": "eq",
132+
"val": 34,
133+
"comment": "MAP_PRIVATE|MAP_ANONYMOUS"
134+
}
135+
]
136+
},
35137
{
36138
"syscall": "fsync"
37139
},

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

+102
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,108 @@
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+
},
39+
{
40+
"syscall": "memfd_create",
41+
"comment": "Used by the IovDeque implementation"
42+
},
43+
{
44+
"syscall": "fcntl",
45+
"comment": "Used by the IovDeque implementation",
46+
"args": [
47+
{
48+
"index": 1,
49+
"type": "dword",
50+
"op": "eq",
51+
"val": 1033,
52+
"comment": "FCNTL_F_SETFD"
53+
},
54+
{
55+
"index": 2,
56+
"type": "dword",
57+
"op": "eq",
58+
"val": 6,
59+
"comment": "F_SEAL_SHRINK|F_SEAL_GROW"
60+
}
61+
]
62+
},
63+
{
64+
"syscall": "fcntl",
65+
"comment": "Used by the IovDeque implementation",
66+
"args": [
67+
{
68+
"index": 1,
69+
"type": "dword",
70+
"op": "eq",
71+
"val": 1033,
72+
"comment": "FCNTL_F_SETFD"
73+
},
74+
{
75+
"index": 2,
76+
"type": "dword",
77+
"op": "eq",
78+
"val": 1,
79+
"comment": "F_SEAL_SEAL"
80+
}
81+
]
82+
},
83+
{
84+
"syscall": "mmap",
85+
"comment": "Used by the IovDeque implementation",
86+
"args": [
87+
{
88+
"index": 1,
89+
"type": "dword",
90+
"op": "eq",
91+
"val": 4096,
92+
"comment": "Page size allocation"
93+
},
94+
{
95+
"index": 2,
96+
"type": "dword",
97+
"op": "eq",
98+
"val": 3,
99+
"comment": "PROT_READ|PROT_WRITE"
100+
},
101+
{
102+
"index": 3,
103+
"type": "dword",
104+
"op": "eq",
105+
"val": 17,
106+
"comment": "MAP_SHARED|MAP_FIXED"
107+
}
108+
]
109+
},
110+
{
111+
"syscall": "mmap",
112+
"comment": "Used by the IovDeque implementation",
113+
"args": [
114+
{
115+
"index": 1,
116+
"type": "dword",
117+
"op": "eq",
118+
"val": 8192,
119+
"comment": "2 pages allocation"
120+
},
121+
{
122+
"index": 2,
123+
"type": "dword",
124+
"op": "eq",
125+
"val": 0,
126+
"comment": "PROT_NONE"
127+
},
128+
{
129+
"index": 3,
130+
"type": "dword",
131+
"op": "eq",
132+
"val": 34,
133+
"comment": "MAP_PRIVATE|MAP_ANONYMOUS"
134+
}
135+
]
136+
},
35137
{
36138
"syscall": "fsync"
37139
},

0 commit comments

Comments
 (0)