New netchannels implementation. Userspace network stack.
Subsystems (3)
Netchannel [1] is pure bridge between low-level hardware and user, without any special protocol processing involved between them.
Users are not limited to userspace only - I will use this netchannel infrastructure for fast NAT implementation, which is purely kernelspace user (although it is possible to create NAT in userspace, but price of the kernelspace board crossing is too high, which only needs to change some fields in the header and recalculate checksum).
Userspace network stack [2] is another user of the new netchannel subsystem.
Current netchannel version supports data transfer using copy*user().
One could ask how does it differ from netfilter's queue target? There are three differencies (read advantages):
* it does not depend on netfilter (and thus does not introduce it's slow path)
* it is very scalable, since it does not use neither hash tables, nor lists
* it does not depend on netfilter (and thus does not introduce it's slow path). Yes, again, since if we get into account NAT implementation, then we need to add dependency on connection tracking, which is not needed for existing netchannels implementation.
It is also much smaller and scalable compared to tun/tap devices.
And some other small advantages: possibility to perform zero-copy sending and receiving using network allocator's [3] facilities (not implemented in the current version of netchannels), it is very small, there are no locks in the very short fast path (except RCU and skb queue linking lock, which is held for 5 operations) and so on...
There are also some limitations: it is only possible to get one packet per read from netchannel's file descriptor (it is possible to extend it to read several packets, but right now I leave it as is), it is ipv4 only (I'm lazy and only implemented tree comparison functions for IPv4 addresses).
First user of the netchannel subsystem is userspace network stack [2], which supports:
* TCP/UDP sending and receiving.
* Timestamp, window scaling, MSS TCP options.
* PAWS.
* Slow start and congestion control.
* Route table (including startic ARP cache).
* Socket-like interface.
* IP and ethernet processing code.
* complete retransmit algorithm.
* fast retransmit support.
* support for TCP listen state (only point-to-point mode, i.e. no new data channels are created, when new client is connected, instead state is changed according to protocol (TCP state is changed to ESTABLISHED).
* support for the new netchannels interface.
Speed/CPU usage graph for the socket code (which uses epoll and send/recv) is attached. With the same 100 Mbit speed, CPU usage for netchanenls and userspace network stack is about 2-3 times smaller than socket one with small packet (128 bytes) sending/receiving.
There is very strange behaviour of userspace time() function, which if being used actively results in extremely high kernel load and following functions start to appear on the top of profiles:
* get_offset_pmtmr() - 25%, second position, even higher than sysenter_past_esp().
* do_gettimeofday() - 0.6%, 4'th place.
* delay_pmtmr() - 0.29%, 11'th place.
First place is poll_idle().
Testing system, which runs either netchannel or socket tests runs HT-enabled Xeon:
processor : 0vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Xeon(TM) CPU 2.40GHz
stepping : 7
with 1GB of RAM and e100 network adapter on Linux 2.6.17-rc3.
Main (vanilla) system is amd64 with 1GB of RAM and 8169 gigabit adapter on Linux 2.6.18-1.2200.fc5, software is either netcat dumping data into /dev/null or sendfile based server.
All sources are available on project's homepages.
Thank you.
1. Netchannels subsystem.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=netchannel
2. Userspace network stack.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=unetstack
3. Network allocator.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=nta
If you have read upto here, then I want you to know that adverticement is over. Thanks again.
Signature · 1 line
Evgeniy Polyakov
Netchannels implementation.
Patch is against 2.6.17-rc3 tree. If there will be any interest to have such subsystem in vanila tree I will regenerate patch against appropriate git tree.
arch/i386/kernel/syscall_table.S +2 -0
@@ -315,3 +315,5 @@ ENTRY(sys_call_table) .long sys_splice .long sys_sync_file_range .long sys_tee /* 315 */ + .long sys_vmsplice + .long sys_netchannel_control
arch/x86_64/ia32/ia32entry.S +1 -0
@@ -696,4 +696,5 @@ #endif .quad sys_sync_file_range .quad sys_tee .quad compat_sys_vmsplice + .quad sys_netchannel_control ia32_syscall_end:
include/asm-i386/unistd.h +2 -1
@@ -322,8 +322,9 @@ #define __NR_splice 313#define __NR_sync_file_range 314#define __NR_tee 315#define __NR_vmsplice 316 +#define __NR_netchannel_control 317 -#define NR_syscalls 317 +#define NR_syscalls 318/* * user-visible error numbers are in the range -1 - -128: see
include/asm-x86_64/unistd.h +3 -1
@@ -617,8 +617,10 @@ #define __NR_sync_file_range 277 __SYSCALL(__NR_sync_file_range, sys_sync_file_range)#define __NR_vmsplice 278 __SYSCALL(__NR_vmsplice, sys_vmsplice) +#define __NR_netchannel_control 279 +__SYSCALL(__NR_netchannel_control, sys_netchannel_control) -#define __NR_syscall_max __NR_vmsplice +#define __NR_syscall_max __NR_netchannel_control#ifndef __NO_STUBS
include/linux/netchannel.h new file +88 -0
88 lines not on this page · raw message
include/linux/netdevice.h +9 -0
@@ -684,6 +684,15 @@ extern void dev_queue_xmit_nit(struct sextern void dev_init (void ); +#ifdef CONFIG_NETCHANNEL +extern int netchannel_recv (struct sk_buff *skb); +#else +static int netchannel_recv (struct sk_buff *skb) +{ +return -1 ; +} +#endif +extern int netdev_nit;extern int netdev_budget;
include/linux/skbuff.h +12 -0
@@ -314,6 +314,18 @@ static inline struct sk_buff *alloc_skb(return __alloc_skb (size, priority,0 ); } +#ifdef CONFIG_NETCHANNEL +struct unetchannel ; +extern struct sk_buff *netchannel_alloc (struct unetchannel *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask); +#else +static struct sk_buff *netchannel_alloc (void *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask) +{ +return NULL ; +} +#endif +static inline struct sk_buff *alloc_skb_fclone (unsigned int size,gfp_t priority) {
include/linux/syscalls.h +2 -0
@@ -582,4 +582,6 @@ asmlinkage long sys_tee(int fdin, int fdasmlinkage long sys_sync_file_range (int fd,loff_t offset,loff_t nbytes,unsigned int flags); +asmlinkage long sys_netchannel_control (void __user *arg); +#endif
kernel/sys_ni.c +2 -0
@@ -132,3 +132,5 @@ cond_syscall(sys_mincore);cond_syscall (sys_madvise);cond_syscall (sys_mremap);cond_syscall (sys_remap_file_pages); + +cond_syscall (sys_netchannel_control);
net/Kconfig +8 -0
@@ -66,6 +66,14 @@ source "net/ipv6/Kconfig" endif # if INET +config NETCHANNEL + bool "Network channels" + ---help--- + Network channels are peer-to-peer abstraction, which allows to create + high performance communications. + Main advantages are unified address cache, protocol processing moved + to userspace, receiving zero-copy support and other interesting features. + menuconfig NETFILTER bool "Network packet filtering (replaces ipchains)" ---help---
net/core/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o obj-$(CONFIG_WIRELESS_EXT) += wireless.o obj-$(CONFIG_NETPOLL) += netpoll.o +obj-$(CONFIG_NETCHANNEL) += netchannel.o
net/core/dev.c +4 -0
@@ -1712,6 +1712,10 @@ #endif } } + ret =netchannel_recv (skb); +if (!ret) + goto out; +#ifdef CONFIG_NET_CLS_ACT if (pt_prev) { ret =deliver_skb (skb, pt_prev, orig_dev);
net/core/netchannel.c new file +897 -0
897 lines not on this page · raw message
Signature · 1 line
Evgeniy Polyakov
[Announce] Netchannels ported to the latest git tree. Gigabit benchmark. Complete rout.
In reply to Evgeniy PolyakovQuoted 10 lines · Evgeniy Polyakov
Netchannel [1] is pure bridge between low-level hardware and user, without any special protocol processing involved between them.
Users are not limited to userspace only - I will use this netchannel infrastructure for fast NAT implementation, which is purely kernelspace user (although it is possible to create NAT in userspace, but price of the kernelspace board crossing is too high, which only needs to change some fields in the header and recalculate checksum).
Userspace network stack [2] is another user of the new netchannel subsystem.Current netchannel version supports data transfer using copy*user().
Performance graph (speed and CPU usage) attached. Benchmark uses 128 bytes sending/receiving per syscall (no latency checks, only throughput.
MB and KB mean not 1000, but 1024.
Receiving is about 8 MB/sec faster.
Receiving CPU usage is 3 times less (90% socket code vs. 30% netchannels+unetstack).
Sending is 10 MB/sec faster.
Sending CPU usage is 5 times less (upto 50% vs. upto 10%).
Number of syscalls is about 10 times less for netchannels.
Hardware.
System 1.
Netchannel kernel (2.6.19-rc3-git) or
vanilla 2.6.19-rc3/2.6.18-1.2200.fc5.
amd64 athlon 3500+ cpu
1gb ram
r8169 nic
System 2.
2.6.17-2-686 debian etch
intel core duo 3.40GHz
2 gb ram
Marvell Technology Group Ltd. 88E8053 PCI-E Gigabit Ethernet Controller
(sky2 driven)
All software used in tests (tcp_client.c/tcp_test.c and userspace network stack) can be found on project's hompages (userspace network stack requires increased window scaling factor than default).
Consider for inclusion netchannel subsystem.
1. Netchannels homepage.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=netchannel
2. Userspace network stack homapage.
http://tservice.net.ru/~s0mbre/old/?section=projects&item=unetstack
arch/i386/kernel/syscall_table.S +1 -0
@@ -319,3 +319,4 @@ ENTRY(sys_call_table) .long sys_move_pages .long sys_getcpu .long sys_epoll_pwait + .long sys_netchannel_control
arch/x86_64/ia32/ia32entry.S +1 -0
@@ -718,4 +718,5 @@ #endif .quad compat_sys_vmsplice .quad compat_sys_move_pages .quad sys_getcpu + .quad sys_netchannel_control ia32_syscall_end:
include/asm-i386/unistd.h +2 -1
@@ -325,10 +325,11 @@ #define __NR_vmsplice 316#define __NR_move_pages 317#define __NR_getcpu 318#define __NR_epoll_pwait 319 +#define __NR_netchannel_control 320#ifdef __KERNEL__ -#define NR_syscalls 320 +#define NR_syscalls 321#include <linux/err.h> /*
include/asm-x86_64/unistd.h +3 -1
@@ -619,8 +619,10 @@ #define __NR_vmsplice 278 __SYSCALL(__NR_vmsplice, sys_vmsplice)#define __NR_move_pages 279 __SYSCALL(__NR_move_pages, sys_move_pages) +#define __NR_netchannel_control 280 +__SYSCALL(__NR_netchannel_control, sys_netchannel_control) -#define __NR_syscall_max __NR_move_pages +#define __NR_syscall_max __NR_netchannel_control#ifdef __KERNEL__#include <linux/err.h>
include/linux/netchannel.h new file +88 -0
88 lines not on this page · raw message
include/linux/netdevice.h +9 -0
@@ -707,6 +707,15 @@ extern int dev_hard_start_xmit(struct sextern void dev_init (void ); +#ifdef CONFIG_NETCHANNEL +extern int netchannel_recv (struct sk_buff *skb); +#else +static int netchannel_recv (struct sk_buff *skb) +{ +return -1 ; +} +#endif +extern int netdev_budget;/* Called by rtnetlink.c:rtnl_unlock() */
include/linux/skbuff.h +12 -0
@@ -338,6 +338,18 @@ static inline struct sk_buff *alloc_skb(return __alloc_skb (size, priority,0 ); } +#ifdef CONFIG_NETCHANNEL +struct unetchannel ; +extern struct sk_buff *netchannel_alloc (struct unetchannel *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask); +#else +static struct sk_buff *netchannel_alloc (void *unc,unsigned int header_size, +unsigned int total_size,gfp_t gfp_mask) +{ +return NULL ; +} +#endif +static inline struct sk_buff *alloc_skb_fclone (unsigned int size,gfp_t priority) {
include/linux/syscalls.h +2 -0
@@ -605,4 +605,6 @@ asmlinkage long sys_getcpu(unsigned __usint kernel_execve (const char *filename,char *const argv[],char *const envp[]); +asmlinkage long sys_netchannel_control (void __user *arg); +#endif
kernel/sys_ni.c +3 -0
@@ -134,9 +134,12 @@ cond_syscall(sys_mincore);cond_syscall (sys_madvise);cond_syscall (sys_mremap);cond_syscall (sys_remap_file_pages); +cond_syscall (compat_sys_move_pages);/* block-layer dependent */ cond_syscall (sys_bdflush);cond_syscall (sys_ioprio_set);cond_syscall (sys_ioprio_get); + +cond_syscall (sys_netchannel_control);
net/Kconfig +8 -0
@@ -66,6 +66,14 @@ source "net/ipv6/Kconfig" endif # if INET +config NETCHANNEL + bool "Network channels" + ---help--- + Network channels are peer-to-peer abstraction, which allows to create + high performance communications. + Main advantages are unified address cache, protocol processing moved + to userspace, receiving zero-copy support and other interesting features. + config NETWORK_SECMARK bool "Security Marking" help
net/core/Makefile +1 -0
@@ -16,5 +16,6 @@ obj-$(CONFIG_NET_DIVERT) += dv.o obj-$(CONFIG_NET_PKTGEN) += pktgen.o obj-$(CONFIG_WIRELESS_EXT) += wireless.o obj-$(CONFIG_NETPOLL) += netpoll.o +obj-$(CONFIG_NETCHANNEL) += netchannel.o obj-$(CONFIG_NET_DMA) += user_dma.o obj-$(CONFIG_FIB_RULES) += fib_rules.o
net/core/dev.c +4 -0
@@ -1808,6 +1808,10 @@ #endif } } + ret =netchannel_recv (skb); +if (!ret) + goto out; +#ifdef CONFIG_NET_CLS_ACT if (pt_prev) { ret =deliver_skb (skb, pt_prev, orig_dev);
net/core/netchannel.c new file +897 -0
897 lines not on this page · raw message
Signature · 1 line
Evgeniy Polyakov
Re: [Announce] Netchannels ported to the latest git tree. Gigabit benchmark. Complete rout.
Quoted 4 lines · Evgeniy Polyakov
Benchmark uses 128 bytes sending/receiving per syscall (no latency checks, only throughput.
Receiving CPU usage is 3 times less (90% socket code vs. 30% Sending CPU usage is 5 times less (upto 50% vs. upto 10%).
Wow. I currently lack the hardware to reproduce your measurements, do you have any idea of how these numbers would be with 1024 byte "system calls"?
Thanks.
Signature · 2 lines
http://www.PowerDNS.com Open source, database driven DNS Software http://netherlabs.nl Open and Closed source services
Re: [Announce] Netchannels ported to the latest git tree. Gigabit benchmark. Complete rout.
Quoted 9 lines · bert hubert
Quoted 4 lines · Evgeniy Polyakov
Benchmark uses 128 bytes sending/receiving per syscall (no latency checks, only throughput.
Receiving CPU usage is 3 times less (90% socket code vs. 30% Sending CPU usage is 5 times less (upto 50% vs. upto 10%).Wow. I currently lack the hardware to reproduce your measurements, do you have any idea of how these numbers would be with 1024 byte "system calls"?
Results are not that exciting in this case.
Receiving CPU usage is about the same: it steady grows upto about 30-35% (netchannel stops growing after some time with about 28%, socket slowly continues), but netchannel's speed is smaller.
It can be described by that fact, that unetstack uses C-coded checksumming (the dumbies algo I think) and additional memory copy, which becomes visible in case of big buffers (it can be eliminated though, I will think about better interface).
The same applies to sending - CPU usage is smaller, but speed is smaller too. (10% vs. 8% compared to 30 MB/sec vs. 24 MB/sec).
So netchannels with userspace stack behave exactly the same in both 128 and 1024 byte write/read cases.
But all it is just a drawnbacks of userspace stack, not netchannels, which do not have any protocol processing at all - it is just a queue between low-level driver and users - some kind of high performance scalable packet socket with only selected addresses or tun/tap device.
Quoted 5 lines
Thanks.
Signature · 2 lines
http://www.PowerDNS.com Open source, database driven DNS Software http://netherlabs.nl Open and Closed source services
Signature · 1 line
Evgeniy Polyakov