Repository navigation
xen/netfront: netfront persistent grants - #119
Merged
Merged
Conversation
bleggett
requested review from
antoineco,
azenla,
kaniini,
sveith and
tycho
as code owners
November 19, 2026 02:25
azenla
approved these changes
Nov 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a new grant mechanism to the
xen-netfrontdriver which reduces CPU usage and improves throughput by a measurable amount (see below)This is logically similar to the persistent grant mechanism
xen-blkfrontalready uses, just applied toxen-netfront.Existing method used in
netfront: grant copy for each requestFor every packet buffer, the zone's netfront granted the backend access to that one page, then put the grant reference in a ring request.
Then the backend asks Xen to copy the data (
GNTTABOP_copy). Xen checks the grant, takes locks and page references, maps the page, copies, and releases it. When the response comes back, netfront revokes the grant.So each page costs 1 grant, 1 hypercall with fixed work of about 400 to 600 ns, and a revoke. The backend never has the zone's memory mapped. It reaches each page only through Xen, one request at a time.
New method for
netfront: static/persistent grantAt connect, netfront allocates a fixed pool of pages for each TX/RX queue(s), grants them once up front, and registers them with the backend over the netif control ring (
ADD_GREF_MAPPING). The backend maps those pages once and keeps them mapped.For each packet, netfront puts a pool page's reference in the request. The backend copies to/from via a regular memory copy with no hypercall. On receive netfront copies the data out of the pool page into its own buffer, and on transmit it copies the data in first.
Requests that do not use a pool page (pool empty, an old kernel, or the flag off) still use grant copy as before.
Measurements
PV dom0, before and after static grants, 4-vCPU zones, median of 3
CPU cost is dom0 cores plus zone cores, divided by Gbit/s. The dom0 cores include the runc iperf3 endpoint, and
the zone cores include the zone's endpoint.
Note that the 4-stream throughput ranges are wide, because they depend on how the flows hash to queues, which is currently randomized in Xen, but this might not be hard to fix.