Skip to content

Add support for very fast packet I/O using netmap(4) on FreeBSD#787

Merged
phillip-stephens merged 7 commits intozmap:mainfrom
droe:droe/netmap-10gbe
Feb 22, 2024
Merged

Add support for very fast packet I/O using netmap(4) on FreeBSD#787
phillip-stephens merged 7 commits intozmap:mainfrom
droe:droe/netmap-10gbe

Conversation

@droe
Copy link
Contributor

@droe droe commented Feb 16, 2024

Initial support for sending and receiving packets using netmap(4) on FreeBSD. Netmap is a framework for very fast packet I/O from userspace that uses pre-allocated ring buffers mapped into ZMap's virtual address space. I have mainly tested on 1 GigE and 10 GigE links, both on netmap-aware and non-aware NICs, but perf advantage compared to the default BPF send code on even faster links than 10 GigE should be even more substantial.

Netmap has also been ported to Linux, support in ZMap is for FreeBSD only at this point. I am not sure how interesting netmap is on Linux with the requirement to patch kernel sources, and how it compares in terms of performance to liburing etc. Making the netmap send/recv code work on Linux too would mainly involve porting the link status and interface stats bits to Linux, so should not be a big deal in case there is interest.

There will be merge conflicts with #767. In case you'll accept (a revised version of) this PR, you may want to wait with merging until after that has landed and I had a chance to rebase on top.

droe added 5 commits February 17, 2024 00:05
Support for sending and receiving packets using netmap(4) on FreeBSD.
Netmap is a framework for very fast packet I/O from userspace that uses
pre-allocated ring buffers mapped into ZMap's virtual address space.
@zakird
Copy link
Member

zakird commented Feb 17, 2024

Thanks @droe, this looks awesome! Thank you as well for all of the other improvements over the past few weeks — I sincerely appreciate all the work you've put into ZMap recently.

@phillip-stephens I think that we should look at what it would take to get this to work on Linux too, particularly given that we haven't yet seen superb performance from io_uring.

@phillip-stephens
Copy link
Contributor

Yeah, thank you so much @droe for this and your other contributions! I'll give it a proper look over on Tuesday.

@zakird Yep sounds good, once we have that bare metal server with a 10 Gbit uplink, I can look into what performance io_uring is really giving and look into this if io_uring leaves anything to be desired.

@droe
Copy link
Contributor Author

droe commented Feb 18, 2024

In case you want to test this on Linux: I keep an untested branch with Linux support at droe/zmap:droe/netmap-linux. Compiles on Ubuntu. Have not run it on a netmap-enabled Linux kernel, so no idea how badly it is broken. Keeping Linux support separate from this PR.

Edit: Linux branch seems to work, results seem to vary greatly depending on the NIC driver, not well tested.

Copy link
Contributor

@phillip-stephens phillip-stephens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really great overall, really appreciate the very digestible README.
Just a few very minor nits on formatting, I didn't see anything stand out in the core logic.

My FreeBSD VM doesn't have the /dev/netmap device by default, and based on this, it looks like adding it would require compiling the kernel from source. IMO, if it's working on your BSD box, I'm good to merge if you are @zakird.

Copy link
Member

@zakird zakird left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. I know that you had some nits about the code. Please merge when your'e good with state of thinsg @phillip-stephens !

@droe
Copy link
Contributor Author

droe commented Feb 20, 2024

Re: netmap default availability, in case you're testing on an arm64 VM, netmap has only recently been added to the default config in D43702, and that change has not made it into a release yet; 14.0 still requires rebuilding the kernel (tl;dr: git clone -b releng/14.0 --depth 1 https://git.freebsd.org/src.git /usr/src, apply the diff in D43702, make buildkernel && make installkernel, reboot). amd64 otoh had it in the default config for ten years now (11.0).

Will take care of the PR feedback later this week, thanks for reviewing.

@droe droe removed their assignment Feb 22, 2024
@phillip-stephens phillip-stephens merged commit 5fd653d into zmap:main Feb 22, 2024
@phillip-stephens
Copy link
Contributor

@droe Thank you for this great contribution!

@droe droe deleted the droe/netmap-10gbe branch March 11, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants