Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case •...
Transcript of Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case •...
![Page 1: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/1.jpg)
x
Dynamic mbuf
THOMAS MONJALON – MELLANOX
OLIVIER MATZ – 6WIND
![Page 2: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/2.jpg)
2
Features require metadata
• offloads in NIC
• load balancing (flow steering)
• segmentation (LRO, TSO)
• checksums
• classification
• tunneling, inline protocol processing (IPsec, NVMe)
• lookaside or inline processing
• crypto symmetric/asymmetric
• lossless compression/decompression (stateless or stateful)
• pattern matching
• Note: software emulation can fill some gaps
![Page 3: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/3.jpg)
3
struct rte_mbuf
• Metadata for a network packet segment
• Data size, pointer (virtual and IOVA), private data size, external buffer metadata pointer
• Segment size, total count and pointer to next
• Protocol data (packet type, layer sizes, tunnels, checksums, VLAN, LRO, TSO, IPsec...)
• Flow classification (port id, queue id, hash, traffic class...)
• Timestamp, PTP
• User metadata
• Offload flags
![Page 4: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/4.jpg)
4
Private Data for Applications
• Space can be reserved on mempool allocation
• Application configures mempool
• Transparent for DPDK
![Page 5: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/5.jpg)
Current mbuf
Limitations
![Page 6: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/6.jpg)
6
Limited Space
• Small mbuf == Less cache misses
• Only 2 cache lines
• 2 x 64 = 128 Bytes
• depends on architecture
• Last free space
• pahole finds 16 Bytes at the end
![Page 7: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/7.jpg)
7
Wasted Space
For one application,
For one use case,
Some mbuf fields are not used.
Some features are rarely used.
![Page 8: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/8.jpg)
8
Mutually Exclusive Features
• Long term, features using the same bytes will clash
• Placeholders with vague description are bad
seqn, tx_metadata, userdata, usr
• Unions of separate features are bad
32-bit RSS FDIR low sched queueuser tag
(distributor)Tx metadata
32-bit FDIR highsched
class + color
eventdev
Tx queue
![Page 9: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/9.jpg)
9
Stability
• Removal or move in mbuf is a strong ABI break
• Vector implementations are tied to mbuf layout
• Slow evolution
• Target: no layout change at all in future
![Page 10: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/10.jpg)
10
Elsewhere
• Same issue in Linux XDP
• http://vger.kernel.org/netconf2019_files/xdp-metadata-discussion.pdf
• FreeBSD m_tag
• https://www.freebsd.org/cgi/man.cgi?query=mbuf_tags
![Page 11: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/11.jpg)
Extend with
Dynamic Fields
![Page 12: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/12.jpg)
12
Why not Allocating External Structure?
• Flexible
• any length
• chained
• Performance impact
• allocate / free
• cache miss
• Needs specific pools
![Page 13: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/13.jpg)
13
Why not Increasing Size?
• Simple
• Performance impact
• Does not avoid ABI breakage each time layout is changed
• Space is still wasted (many unused fields)
![Page 14: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/14.jpg)
14
Why not Selective Layout?
Application would choose
between different mbuf layouts
depending on its needs
• Requires as many structures as use cases
• Difficult to adapt and optimize drivers for all possible layouts
![Page 15: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/15.jpg)
15
Design of Dynamic Fields
• Register
• on demand, depending on use case
• unused fields don’t use space in mbuf
• Drivers and applications access to a dynamic offset in the mbuf
• small performance impact
• System-wide
• impacts all mbufs in all pools
• Same logic for dynamic bits in offload flags
name
size
alignment
flags
offset
name
countbit number
![Page 16: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/16.jpg)
16
API
Register the field
Read/Write the field
const struct rte_mbuf_dynfield rte_mbuf_dynfield_my_feature = {
.name = "rte_mbuf_dynfield_my_feature",
.size = sizeof(uint64_t),
.align = __alignof__(uint64_t),
.flags = 0,
};
offset = rte_mbuf_dynfield_register(&dynfield);
if (offset < 0)
/* error */
*RTE_MBUF_DYNFIELD(mbuf, offset, uint64_t *) = 0x1337beef;
![Page 17: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/17.jpg)
17
Example of Field
• Helper to register flag and field together
• rte_mbuf_dyn_timestamp_register()
• Feature-specific accessors
• rte_mbuf_dyn_timestamp_get(mbuf)
• rte_mbuf_dyn_timestamp_set(mbuf, value)
• rte_mbuf_dyn_timestamp_avail(mbuf)
![Page 18: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/18.jpg)
18
Drawbacks / Limitations
• Lower performance than accessing a static field
• Early benchmark:
+2 cycles for write access
+3 cycles for read access
• Cannot unregister dynamic fields
• No magic: space is still limited (but more flexible)
![Page 19: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/19.jpg)
Get even
More Space
![Page 20: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/20.jpg)
20
Plan for Future
• Sustainable if enough space to combine a lot of features
• Convert some fields from static to dynamic
• Would add room in Rx (first) cache line
• performance gain for fields moved in Rx part
• registration flags to choose the cache line
![Page 21: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/21.jpg)
21
Criteria for Dynamic Field
• Uncommon use
• Vendor-specific
• Performance degradation by a couple of cycles not critical
• Union'ed (exclusive) feature
![Page 22: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/22.jpg)
22
Remove User Data
• mbuf field (in second half)
• void *userdata
• uint64_t udata64
• Application can register its own well-defined field
![Page 23: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/23.jpg)
23
Remove User Tag
• mbuf field (union'ed in first half)
• uint32_t usr
• Cannot be used together with RSS hash
• Used only by distributor library
• could use a well-defined dynamic field
![Page 24: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/24.jpg)
24
Convert External Buffer Data Pointer
• mbuf field (in second half)
• struct rte_mbuf_ext_shared_info *shinfo
• Accessed only on external buffer attach
• Part of mbuf API
• Difficult to convert
![Page 25: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/25.jpg)
25
Convert PTP
• Offload flags• PKT_RX_IEEE1588_PTP
• PKT_RX_IEEE1588_TMST
• PKT_TX_IEEE1588_TMST
• mbuf field (in second half)• uint16_t timesync
• IEEE1588 PTP is a payload on top of UDP
• Why is it part of mbuf API?
![Page 26: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/26.jpg)
26
Convert Timestamp
• mbuf field (in first half)
• uint64_t timestamp
• Not performance critical?
• Not widely used
• In first half (Rx part)
![Page 27: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/27.jpg)
27
Convert Sequence Number
• mbuf field (in second half)
• uint32_t seqn
• Not enough defined
• Not widely used
![Page 28: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/28.jpg)
28
Convert Hierarchical Scheduler
• mbuf sub-struct (union'ed in first half)
• uint32_t queue_id
• uint8_t traffic_class
• uint8_t color
• Feature union'ed with RSS
• QoS not always done
![Page 29: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/29.jpg)
29
Convert eventdev Tx Adapter
• mbuf field (union'ed in first half)
• uint16_t txq
• Feature union'ed with RSS
• eventdev not always in use
![Page 30: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/30.jpg)
30
Convert Tx Metadata
• mbuf field (union'ed in first half)
• uint32_t tx_metadata
• Feature union'ed with RSS
• Application-specific usage
![Page 31: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/31.jpg)
31
More?
Other fields could be discussed.
The conversion may be a long way
happening as jumps when ABI breakage window is open.
![Page 32: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/32.jpg)
Conclusion
TO REVIEW (for 19.11)
Add dynamic mbuf API.
TODO (for 20.11)
Migrate some static fields to dynamic.
![Page 33: Dynamic mbuf - DPDKDesign of Dynamic Fields • Register • on demand, depending on use case • unused fields don’t use space in mbuf • Drivers and applications access to a dynamic](https://reader035.fdocuments.net/reader035/viewer/2022071420/6119ae4ab3d0a6523652763a/html5/thumbnails/33.jpg)
Questions?