Skip to contentSkip to conversation

netif_rx: receive path optimization

PATCH In review Stephen Hemminger 7 participants 24 messages Mar 30, 2005 – Apr 1, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netif_rx: receive path optimization

This patch cleans up the netif_rx and related code in the network receive core.

- Eliminate vestiges of fastroute.
The leftover statistics no longer needed.

- Get rid of high/med/low threshold return from netif_rx. Drivers rarely check return value of netif_rx, and those that do can handle the DROP vs SUCCESS return

- Remove dead code for RAND_LINE and OFFLINE_SAMPLE

- Get rid of weight_p since setting sysctl has no effect. Increase default weight of netif_rx path because it can receive packets from multiple devices and loopback.

- Separate out max packets per softirq vs. max queued packets. Today, netdev_max_burst is used for both. Add new parameter that is for the per-cpu max queued packets.

- Increase queue defaults to meet modern CPU speeds. Make max_backlog be about 1ms, and max_queue be about 10ms

- Switch to pure drop tail when queue fills. Better for TCP performance under load to drop a few packets then go into full discard mode.

This needs more testing on range of hardware before possible inclusion in 2.6.13. Will split out to finer grain patches then.

include/linux/netdevice.h +0 -6
diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
@@ -164,12 +164,6 @@
 	unsigned total;
 	unsigned dropped;
 	unsigned time_squeeze;
-	unsigned throttled;
-	unsigned fastroute_hit;
-	unsigned fastroute_success;
-	unsigned fastroute_defer;
-	unsigned fastroute_deferred_out;
-	unsigned fastroute_latency_reduction;
 	unsigned cpu_collision;
 };
 
include/linux/sysctl.h +1 -0
diff -Nru a/include/linux/sysctl.h b/include/linux/sysctl.h
@@ -242,6 +242,7 @@
 	NET_CORE_MOD_CONG=16,
 	NET_CORE_DEV_WEIGHT=17,
 	NET_CORE_SOMAXCONN=18,
+	NET_CORE_MAX_QUEUE=19,
 };
 
 /* /proc/sys/net/ethernet */
net/core/dev.c +26 -136

240 lines not on this page · raw message

net/core/sysctl_net_core.c +5 -42

71 lines not on this page · raw message

#1 lore raw
Quoted 10 lines · Stephen Hemminger

This patch cleans up the netif_rx and related code in the network receive core.

- Eliminate vestiges of fastroute.
The leftover statistics no longer needed.

- Get rid of high/med/low threshold return from netif_rx. Drivers rarely check return value of netif_rx, and those that do can handle the DROP vs SUCCESS return

Please leave this feature in. Drivers that used it have moved on to a better life under NAPI; however, it is still useful for anyone who wants to take heed of congestion. And infact it is highly advisable for anyone not using NAPI to using it.
In other words: the work should be to convert users of netif_rx and not to get rid of this feature.

Quoted 2 lines

- Remove dead code for RAND_LINE and OFFLINE_SAMPLE

OFLINE SAMPLE can go. The other refer to my comments above.

Quoted 4 lines

- Get rid of weight_p since setting sysctl has no effect. Increase default weight of netif_rx path because it can receive packets from multiple devices and loopback.

Same here.

Quoted 7 lines

- Separate out max packets per softirq vs. max queued packets. Today, netdev_max_burst is used for both. Add new parameter that is for the per-cpu max queued packets.

- Increase queue defaults to meet modern CPU speeds. Make max_backlog be about 1ms, and max_queue be about 10ms

kind of hard to compute what 1 or 10 ms in packet count. But probably justfied to make the default larger.

Quoted 4 lines

- Switch to pure drop tail when queue fills. Better for TCP performance under load to drop a few packets then go into full discard mode.

Like discussed in that thread with person who enhanced the SACK queue traversal that for a serious use a TCP user really oughta migrate to a NAPI driver.

cheers,
jamal

#2 lore raw
Quoted 4 lines · jamal

Like discussed in that thread with person who enhanced the SACK queue traversal that for a serious use a TCP user really oughta migrate to a NAPI driver.

I think i wasnt clear:
The change is fine - just saying that someone serious about benchmarky numbers should probably not use that interface.

cheers,
jamal

#3 lore raw
In reply to jamal
Quoted 12 lines · On 30 Mar 2005 16:57:29 -0500 jamal <[email protected]> wrote:
Quoted 10 lines · Stephen Hemminger

This patch cleans up the netif_rx and related code in the network receive core.

- Eliminate vestiges of fastroute.
The leftover statistics no longer needed.

- Get rid of high/med/low threshold return from netif_rx. Drivers rarely check return value of netif_rx, and those that do can handle the DROP vs SUCCESS return

Quoted 6 lines

Please leave this feature in. Drivers that used it have moved on to a better life under NAPI; however, it is still useful for anyone who wants to take heed of congestion. And infact it is highly advisable for anyone not using NAPI to using it.
In other words: the work should be to convert users of netif_rx and not to get rid of this feature.

How about percentages instead of multiple sysctl values? Or some relationship of max_queue and max_backlog.
success qlen < max_backlog
low qlen > max_backlog
medium qlen > max_queue/2
high qlen > max_queue - max_backlog
drop qlen > max_queue

Also, RAND_LIE (dead code) is
kind of confusing because I expected it to be a receive version of Random Drop, but it really just lies back to the caller (and keeps the packet).

#4 lore raw
Quoted 8 lines · Stephen Hemminger

How about percentages instead of multiple sysctl values? Or some relationship of max_queue and max_backlog.
success qlen < max_backlog
low qlen > max_backlog
medium qlen > max_queue/2
high qlen > max_queue - max_backlog
drop qlen > max_queue

Well, you still need the moving window average computation to detect the second order effect (of an oncoming tsunami).
Unless i misunderstood - you are suggesting looking at instantenous values

Quoted 3 lines

Also, RAND_LIE (dead code) is
kind of confusing because I expected it to be a receive version of Random Drop, but it really just lies back to the caller (and keeps the packet).

If you have drivers which look at the feedback value - then they will back off. We dont drop but we do hope that by telling the driver to back off that it listens to us. Clearly if you have drivers that dont listen then its like running UDP on a wire with everyone trying to shove packets.
For some numbers and experiments on this stuff circa 1999/2000 look at:
http://robur.slu.se/Linux/net-development/jamal/FF-html/
You may find at least one entertaining:
http://robur.slu.se/Linux/net-development/jamal/FF-html/img20.htm

cheers,
jamal

#5 lore raw

RFC 1/1 netif_rx: receive path optimization

In reply to Stephen Hemminger

Here is another alternative that seems better than the earlier posting. It uses a per device receive queue for non-NAPI devices. The only issue is that then we lose the per-cpu queue's and that could impact the loopback device performance. If that is really an issue, then the per-cpu magic should be moved to the loopback device.

# This is a BitKeeper generated diff -Nru style patch. #
# ChangeSet
# 2005/03/31 11:51:14-08:00 [email protected]
# Use per-device rx_queue for non NAPI devices.
#

# net/core/dev.c
#   2005/03/31 11:51:00-08:00 [email protected] +28 -57
#   Use per-device rx_queue for non NAPI devices.
# 
# include/linux/netdevice.h
#   2005/03/31 11:51:00-08:00 [email protected] +2 -7
#   Use per-device rx_queue for non NAPI devices.
# 
# ChangeSet
#   2005/03/30 12:02:44-08:00 [email protected] 
#   netif_rx redux:
#     - eliminate vestiages of fastroute
#     - get rid of high/med/low return never used
#     - get rid of weight_p since setting sysctl has no effect
#     - separate out max packets per softirq vs. max queued packets
#     - increase queue defaults to meet modern CPU speeds
#     - switch to pure drop tail when queue fills
# 
# net/core/sysctl_net_core.c
#   2005/03/30 12:02:30-08:00 [email protected] +5 -42
#   update net_core_sysctl
# 
# net/core/dev.c
#   2005/03/30 12:02:30-08:00 [email protected] +26 -136
#   cleanup of netif_rx path.
# 
# include/linux/sysctl.h
#   2005/03/30 12:02:30-08:00 [email protected] +1 -0
#   add max queue sysctl
# 
# include/linux/netdevice.h
#   2005/03/30 12:02:30-08:00 [email protected] +0 -6
#   Get rid of unused statistics
# 
diff -Nru a/include/linux/netdevice.h b/include/linux/netdevice.h
--- a/include/linux/netdevice.h	2005-03-31 11:52:39 -08:00
+++ b/include/linux/netdevice.h	2005-03-31 11:52:39 -08:00
@@ -164,12 +164,6 @@
 	unsigned total;
 	unsigned dropped;
 	unsigned time_squeeze;
-	unsigned throttled;
-	unsigned fastroute_hit;
-	unsigned fastroute_success;
-	unsigned fastroute_defer;
-	unsigned fastroute_deferred_out;
-	unsigned fastroute_latency_reduction;
 	unsigned cpu_collision;
 };

@@ -362,6 +356,7 @@
void *ec_ptr; /* Econet specific data */
void *ax25_ptr; /* AX.25 specific data */

+ struct sk_buff_head rx_queue; /* Receive queue (non NAPI) */
struct list_head poll_list; /* Link to poll list */
int quota;
int weight;
@@ -562,15 +557,9 @@

struct softnet_data
{
- int throttle;
- int cng_level;
- int avg_blog;
- struct sk_buff_head input_pkt_queue;
- struct list_head poll_list;
struct net_device *output_queue;
+ struct list_head poll_list;
struct sk_buff *completion_queue;
-
- struct net_device backlog_dev; /* Sorry. 8) */
};

DECLARE_PER_CPU(struct softnet_data,softnet_data);

include/linux/sysctl.h +1 -0
diff -Nru a/include/linux/sysctl.h b/include/linux/sysctl.h
@@ -242,6 +242,7 @@
 	NET_CORE_MOD_CONG=16,
 	NET_CORE_DEV_WEIGHT=17,
 	NET_CORE_SOMAXCONN=18,
+	NET_CORE_MAX_QUEUE=19,
 };
 
 /* /proc/sys/net/ethernet */
net/core/dev.c +44 -183

324 lines not on this page · raw message

net/core/sysctl_net_core.c +5 -42

71 lines not on this page · raw message

#6 lore raw
Quoted 6 lines · Stephen Hemminger

Here is another alternative that seems better than the earlier posting. It uses a per device receive queue for non-NAPI devices. The only issue is that then we lose the per-cpu queue's and that could impact the loopback device performance. If that is really an issue, then the per-cpu magic should be moved to the loopback device.

The repurcassions of going from per-CPU-for-all-devices queue (introduced by softnet) to per-device-for-all-CPUs maybe huge in my opinion especially in SMP. A closer view of whats there now maybe per-device-per-CPU backlog queue.
I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

cheers,
jamal

#7 lore raw
Quoted 8 lines · On 31 Mar 2005 16:10:32 -0500 Jamal Hadi Salim <[email protected]> wrote:
Quoted 6 lines · Stephen Hemminger

Here is another alternative that seems better than the earlier posting. It uses a per device receive queue for non-NAPI devices. The only issue is that then we lose the per-cpu queue's and that could impact the loopback device performance. If that is really an issue, then the per-cpu magic should be moved to the loopback device.

Quoted 4 lines

The repurcassions of going from per-CPU-for-all-devices queue (introduced by softnet) to per-device-for-all-CPUs maybe huge in my opinion especially in SMP. A closer view of whats there now maybe per-device-per-CPU backlog queue.

Any real hardware only has a single receive packet source (the interrupt routine), and the only collision would be in the case of interrupt migration. So having per-device-per-CPU queue's would be overkill and more complex because the NAPI scheduling is per-netdevice rather than per-queue (though that could be fixed).

Quoted 2 lines

I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

Experiment with what? Proving an absolute negative is impossible. I will test loopback and non-NAPI version of a couple of gigabit drivers to see.

#8 lore raw
Quoted 5 lines · Stephen Hemminger

Any real hardware only has a single receive packet source (the interrupt routine), and the only collision would be in the case of interrupt migration. So having per-device-per-CPU queue's would be overkill and more complex because the NAPI scheduling is per-netdevice rather than per-queue (though that could be fixed).

The idea behind the current per-CPU queues is to avoid cache ping-ponging; same queue shared across multiple CPUs with roundrobin interupts will get expensive. In other words these non-NAPI devices will be migrating across CPUs based on interupts a lot more under heavy traffic.
In the case of NAPI, the issue doesnt exist: A device stays on the same queue until all packets are offloaded of it. Depending on CPU capacity it could stay forever on the same CPU.

So my suggestion to do per CPU queues for these devices is avoid that.

Quoted 6 lines
Quoted 2 lines

I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

Experiment with what? Proving an absolute negative is impossible. I will test loopback and non-NAPI version of a couple of gigabit drivers to see.

I think that will do. I dont know how heavy traffic you can pound. Collecting and comparing some profiles between the two schems will help.

cheers,
jamal

#9 lore raw
In reply to Stephen Hemminger
Quoted 18 lines
Quoted 11 lines
Quoted 6 lines

Here is another alternative that seems better than the earlier posting. It uses a per device receive queue for non-NAPI devices. The only issue is that then we lose the per-cpu queue's and that could impact the loopback device performance. If that is really an issue, then the per-cpu magic should be moved to the loopback device.

The repurcassions of going from per-CPU-for-all-devices queue (introduced by softnet) to per-device-for-all-CPUs maybe huge in my opinion especially in SMP. A closer view of whats there now maybe per-device-per-CPU backlog queue.

Any real hardware only has a single receive packet source (the interrupt routine), and the only collision would be in the case of interrupt migration. So having per-device-per-CPU queue's would be overkill and more complex because the NAPI scheduling is per-netdevice rather than per-queue (though that could be fixed).

Quoted 6 lines
Quoted 2 lines

I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

Experiment with what? Proving an absolute negative is impossible. I will test loopback and non-NAPI version of a couple of gigabit drivers to see.

Just a naive question : why at all trying to accelerate netif_rx? Isn't NAPI the best choice for high performance rx anyway?

Signature · 1 line
Eric
#10 lore raw
Quoted 21 lines · On Thu, 31 Mar 2005 23:43:27 +0200 Eric Lemoine <[email protected]> wrote:
Quoted 21 lines
Quoted 11 lines
Quoted 6 lines

Here is another alternative that seems better than the earlier posting. It uses a per device receive queue for non-NAPI devices. The only issue is that then we lose the per-cpu queue's and that could impact the loopback device performance. If that is really an issue, then the per-cpu magic should be moved to the loopback device.

The repurcassions of going from per-CPU-for-all-devices queue (introduced by softnet) to per-device-for-all-CPUs maybe huge in my opinion especially in SMP. A closer view of whats there now maybe per-device-per-CPU backlog queue.

Any real hardware only has a single receive packet source (the interrupt routine), and the only collision would be in the case of interrupt migration. So having per-device-per-CPU queue's would be overkill and more complex because the NAPI scheduling is per-netdevice rather than per-queue (though that could be fixed).

Quoted 2 lines

I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

Quoted 6 lines
Quoted 3 lines

Experiment with what? Proving an absolute negative is impossible. I will test loopback and non-NAPI version of a couple of gigabit drivers to see.

Just a naive question : why at all trying to accelerate netif_rx? Isn't NAPI the best choice for high performance rx anyway?

It was a side-effect of trying to clean out the dead code leftover from removal of fastroute and other old experiments. netif_rx still gets used for loopback and people do benchmarks on loopback. Also, NAPI doesn't work for all cases like layered devices and devices like wifi that need to receive packets when the network device is "not running".

#11 lore raw
In reply to Jamal Hadi Salim
Quoted 6 lines

The repurcassions of going from per-CPU-for-all-devices queue (introduced by softnet) to per-device-for-all-CPUs maybe huge in my opinion especially in SMP. A closer view of whats there now maybe per-device-per-CPU backlog queue.
I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

Indeed.

At the risk of again chewing on my toes (yum), if multiple CPUs are pulling packets from the per-device queue there will be packet reordering. HP-UX 10.0 did just that and it was quite nasty even at low CPU counts (<=4). It was changed by HP-UX 10.20 (ca 1995) to per-CPU queues with queue selection computed from packet headers (hash the IP and TCP/UDP header to pick a CPU) It was called IPS for Inbound Packet Scheduling. 11.0 (ca 1998) later changed that to "find where the connection last ran and queue to that CPU" That was called TOPS - Thread Optimized Packet Scheduling.

fwiw,

rick jones

#12 lore raw
Quoted 11 lines · Rick Jones
Quoted 6 lines

The repurcassions of going from per-CPU-for-all-devices queue (introduced by softnet) to per-device-for-all-CPUs maybe huge in my opinion especially in SMP. A closer view of whats there now maybe per-device-per-CPU backlog queue.
I think performance will be impacted in all devices. imo, whatever needs to go in needs to have some experimental data to back it

Indeed.

At the risk of again chewing on my toes (yum), if multiple CPUs are pulling packets from the per-device queue there will be packet reordering.

;-> This happens already _today_ on Linux on non-NAPI.

Take the following scenario in non-NAPI.
-packet 1 arrives
-interupt happens, NIC bound to CPU0
- in the meantime packets 2,3 arrive
- 3 packets put on queue for CPU0
- interupt processing done

- packet 4 arrives, interupt, CPU1 is bound to NIC
- in the meantime packets 5,6 arrive
- CPU1 backlog queue used.
- interupt processing done

Assume CPU0 is overloaded with other systenm work and CPU1 rx processing kicks in first ...
TCP sees packet 4, 5, 6 before 1, 2, 3 ..

Note Linux is quiet resilient to reordering compared to other OSes (as you may know) but avoiding this is a better approach - hence my suggestion to use NAPI when you want to do serious TCP.

Of course NAPI is not all that panacea under low traffic eating a little bit more CPU (but you have CPU issues under low load you are in some other deep shit)

Quoted 8 lines

HP-UX 10.0
did just that and it was quite nasty even at low CPU counts (<=4). It was changed by HP-UX 10.20 (ca 1995) to per-CPU queues with queue selection computed from packet headers (hash the IP and TCP/UDP header to pick a CPU) It was called IPS for Inbound Packet Scheduling. 11.0 (ca 1998) later changed that to "find where the connection last ran and queue to that CPU" That was called TOPS - Thread Optimized Packet Scheduling.

Dont think we can do that unfortunately: We are screwed by the APIC architecture on x86.

cheers,
jamal

#13 lore raw
Quoted 17 lines
Quoted 1 line

At the risk of again chewing on my toes (yum), if multiple CPUs are pulling packets from the per-device queue there will be packet reordering.

;-> This happens already _today_ on Linux on non-NAPI.

Take the following scenario in non-NAPI.

(quoted diff) +0 -9
-packet 1 arrives 
-interupt happens, NIC bound to CPU0
- in the meantime packets 2,3 arrive
- 3 packets put on queue for CPU0
- interupt processing done
 
- packet 4 arrives, interupt, CPU1 is bound to NIC
- in the meantime packets 5,6 arrive
- CPU1 backlog queue used.
- interupt processing done
Quoted 2 lines

Assume CPU0 is overloaded with other systenm work and CPU1 rx processing kicks in first ... TCP sees packet 4, 5, 6 before 1, 2, 3 ..

I "never" see that because I always bind a NIC to a specific CPU :) Just about every networking-intensive benchmark report I've seen has done the same.

Quoted 3 lines

Note Linux is quiet resilient to reordering compared to other OSes (as you may know) but avoiding this is a better approach - hence my suggestion to use NAPI when you want to do serious TCP.

Would the same apply to NIC->CPU interrupt assignments? That is, bind the NIC to a single CPU.

Quoted 6 lines
Quoted 2 lines

HP-UX 10.0 did just that and it was quite nasty even at low CPU counts (<=4). It was changed by HP-UX 10.20 (ca 1995) to per-CPU queues with queue selection computed from packet headers (hash the IP and TCP/UDP header to pick a CPU) It was called IPS for Inbound Packet Scheduling. 11.0 (ca 1998) later changed that to "find where the connection last ran and queue to that CPU" That was called TOPS - Thread Optimized Packet Scheduling.

Dont think we can do that unfortunately: We are screwed by the APIC architecture on x86.

The IPS and TOPS stuff was/is post-NIC-interrupt. Low-level driver processing still happened/s on a specific CPU, it is the higher-level processing which is done on another CPU. The idea - with TOPS at least, is to try to access the ULP (TCP, UDP etc) structures on the same CPU as last accessed by the app to minimize that cache to cache migration.

rick jones

#14 lore raw
Quoted 10 lines · Rick Jones
Quoted 10 lines

Take the following scenario in non-NAPI. -packet 1 arrives -interupt happens, NIC bound to CPU0
- in the meantime packets 2,3 arrive
- 3 packets put on queue for CPU0
- interupt processing done

- packet 4 arrives, interupt, CPU1 is bound to NIC
- in the meantime packets 5,6 arrive
- CPU1 backlog queue used.
- interupt processing done

Quoted 5 lines
Quoted 2 lines

Assume CPU0 is overloaded with other systenm work and CPU1 rx processing kicks in first ... TCP sees packet 4, 5, 6 before 1, 2, 3 ..

I "never" see that because I always bind a NIC to a specific CPU :) Just about every networking-intensive benchmark report I've seen has done the same.

Just a reminder that the networking-benchmark world and the real networking deployment world have a less than desirable intersection (which I know you know only too well, Rick ;)). How often do people use affinity? How often do they really tune the system for their workloads? How often do they turn off things like SACK etc? Not very often in the real world. Designing OSs to do better at benchmarks is a different proposition than designing OSs to do well in the real world.

Quoted 3 lines
Quoted 3 lines

Note Linux is quiet resilient to reordering compared to other OSes (as you may know) but avoiding this is a better approach - hence my suggestion to use NAPI when you want to do serious TCP.

The real killer for TCP is triggering fast retransmit unnecessarily - and while we have some reordering detection and safeguards for that - for other situations like apps running over UDP and being unable to cope with reordering (yes, there are dunderheads like that) there is not much you can do. It does help them to avoid the reordering to begin with.

thanks,
Nivedita

#15 lore raw
Quoted 6 lines
Quoted 1 line

I "never" see that because I always bind a NIC to a specific CPU :) Just about every networking-intensive benchmark report I've seen has done the same.

Just a reminder that the networking-benchmark world and the real networking deployment world have a less than desirable intersection (which I know you know only too well, Rick ;)).

Touche :)

Quoted 2 lines

How often do people use affinity? How often do they really tune the system for their workloads?

Not as often as they should.

Quoted 1 line

How often do they turn off things like SACK etc?

Well, I'm in an email discussion with someone who seems to bump their TCP windows quite large, and disable timestamps...

Quoted 3 lines

Not very often in the real world. Designing OSs to
do better at benchmarks is a different proposition than designing OSs to do well in the real world.

BTW what is the real world purpose of having the multiple CPU affinity of NIC interrupts? I have to admit it seems rather alien to me. (In the context of no onboard NIC smarts being involved that is)

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines

Note Linux is quiet resilient to reordering compared to other OSes (as you may know) but avoiding this is a better approach - hence my suggestion to use NAPI when you want to do serious TCP.

The real killer for TCP is triggering fast retransmit unnecessarily

Agreed. That is doubleplusungood.

rick

#16 lore raw
Quoted 14 lines · On Thu, 31 Mar 2005 15:28:16 -0800 Rick Jones <[email protected]> wrote:
Quoted 8 lines
Quoted 3 lines

I "never" see that because I always bind a NIC to a specific CPU :) Just about every networking-intensive benchmark report I've seen has done the same.

Just a reminder that the networking-benchmark world and the real networking deployment world have a less than desirable intersection (which I know you know only too well, Rick ;)).

Touche :)

Quoted 2 lines

How often do people use affinity? How often do they really tune the system for their workloads?

Quoted 6 lines

Not as often as they should.

Quoted 1 line

How often do they turn off things like SACK etc?

Well, I'm in an email discussion with someone who seems to bump their TCP windows quite large, and disable timestamps...

And do they like the resulting data corruption.

#17 lore raw
Quoted 4 lines
Quoted 1 line

Well, I'm in an email discussion with someone who seems to bump their TCP windows quite large, and disable timestamps...

And do they like the resulting data corruption.

Minor nit - potential data corruption, perhaps even probable, but I don't think they are all that concerned yet - feeling secure in their belief that 2*MSL on a LAN is rather short indeed, and perhaps even in WANs where using 1GB TCP windows (although I may have mixed too much together there).

Of course, if we believe that stacks should be smart enough to limit the initial receive windows (or does a setsockopt() actrually override that?), and grow them over time based on what the transfer rates might be and the like, perhaps the stack should have a hard interlock on TCP window >= 65535 and timestamp option on. No timestamps, no window > 65535 bytes. At present, it seems possible to have one without the other. Of course, if one is indeed on a "LAN" and _knows_ (somehow, given the existence of remote bridges) that it is a LAN.

rick jones

#18 lore raw
In reply to Rick Jones
Quoted 1 line · Rick Jones

Well, I'm in an email discussion with someone who seems to bump their TCP windows quite large, and disable timestamps...

Ah, an oldie but a goodie :), disabling route inheritance as a result, bumping up their default rto back to 300ms, just so many things that could go wrong there...

Quoted 1 line

BTW what is the real world purpose of having the multiple CPU affinity of NIC interrupts? I have to admit it seems rather alien to me. (In the context of no onboard NIC smarts being involved that is)

Featuritis Bloatis ;). It's a marketing requirement :).

thanks,
Nivedita

#19 lore raw
In reply to Rick Jones
Quoted 3 lines · Rick Jones

I "never" see that because I always bind a NIC to a specific CPU :) Just about every networking-intensive benchmark report I've seen has done the same.

Do you have to be so clever? ;->

Quoted 7 lines
Quoted 3 lines

Note Linux is quiet resilient to reordering compared to other OSes (as you may know) but avoiding this is a better approach - hence my suggestion to use NAPI when you want to do serious TCP.

Would the same apply to NIC->CPU interrupt assignments? That is, bind the NIC to a single CPU.

No reordering there.

Quoted 9 lines
Quoted 2 lines

Dont think we can do that unfortunately: We are screwed by the APIC architecture on x86.

The IPS and TOPS stuff was/is post-NIC-interrupt. Low-level driver processing still happened/s on a specific CPU, it is the higher-level processing which is done on another CPU. The idea - with TOPS at least, is to try to access the ULP (TCP, UDP etc) structures on the same CPU as last accessed by the app to minimize that cache to cache migration.

But if interupt happens on "wrong" cpu - and you decide higher level processing is to be done on the "right" cpu (i assume queueing on some per CPU queue); then isnt that expensive? Perhaps IPIs involved even?

cheers,
jamal

#20 lore raw
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

Note Linux is quiet resilient to reordering compared to other OSes (as you may know) but avoiding this is a better approach - hence my suggestion to use NAPI when you want to do serious TCP.

Would the same apply to NIC->CPU interrupt assignments? That is, bind the NIC to a single CPU.

No reordering there.

Ah, I wasn't clear - would someone doing serious TCP want to have the interrupts of a NIC go to a specific CPU.

Quoted 10 lines
Quoted 5 lines
Quoted 2 lines

Dont think we can do that unfortunately: We are screwed by the APIC architecture on x86.

The IPS and TOPS stuff was/is post-NIC-interrupt. Low-level driver processing still happened/s on a specific CPU, it is the higher-level processing which is done on another CPU. The idea - with TOPS at least, is to try to access the ULP (TCP, UDP etc) structures on the same CPU as last accessed by the app to minimize that cache to cache migration.

But if interupt happens on "wrong" cpu - and you decide higher level processing is to be done on the "right" cpu (i assume queueing on some per CPU queue); then isnt that expensive? Perhaps IPIs involved even?

More expensive than if one were lucky enough to have the interrupt on the "right" CPU in the first place, but as the CPU count goes-up, the chances of that go down. The main idea behind TOPS and prior to that IPS was to spread-out the processing of packets across as many CPUs as we could, as "correctly" as we could. Lots of small packets meant/means that a NIC could saturate its interrupt CPU before the NIC was saturated. You don't necessarily see that on say single-instance netperf TCP_STREAM (or basic FTP) testing, but certainly can on aggregate netperf TCP_RR testing.

IPS, being driven by the packet header info, was good enough for simple benchmarking, but once you had more than one connection per process/thread that wasn't going to cut it, and even with one connection per process telling the process where it should run wasn't terribly easy :) It wasn't _that_ much more expensive than the queueing already happening - IPS was when HP-UX networking was BSDish and it was done when things were being queued to the netisr queue(s).

TOPS lets the process (I suppose the scheduler really) decide where some of the processing for the packet will happen - the part after the handoff.

rick

#21 lore raw
Quoted 3 lines · Rick Jones

Ah, I wasn't clear - would someone doing serious TCP want to have the interrupts of a NIC go to a specific CPU.

Not sure i followed:
Your TCP app (server probably) is running on CPU X;
You therefore want to tie the NIC which it goes out on the same CPU X?

AFAIK, Linux scheduler will reschedule a process on the last CPU it was running on if possible - So if you bind a NIC to some CPU it is likely that the CPU will also run the process. Just handwaving - never tried to observe.
You could bind processes to CPUs (process affinity) from user space but then also make sure you bind CPU-NIC statically

Quoted 3 lines

More expensive than if one were lucky enough to have the interrupt on the "right" CPU in the first place, but as the CPU count goes-up, the chances of that go down.

Indeed.

Quoted 3 lines

The main idea behind TOPS and prior to that IPS was to spread-out the processing of packets across as many CPUs as we could, as "correctly" as we could.

Very very hard to do. Isnt MSI supposed to give you ability such that a NIC can pick a CPU to interupt? That would help in a small way

Quoted 12 lines

Lots of small packets meant/means that a NIC could saturate its
interrupt CPU before the NIC was saturated. You don't necessarily see that on say single-instance netperf TCP_STREAM (or basic FTP) testing, but certainly can on aggregate netperf TCP_RR testing.

IPS, being driven by the packet header info, was good enough for simple benchmarking, but once you had more than one connection per process/thread that wasn't going to cut it, and even with one connection per process telling the
process where it should run wasn't terribly easy :) It wasn't _that_ much more
expensive than the queueing already happening - IPS was when HP-UX networking was BSDish and it was done when things were being queued to the netisr queue(s).

Quoted 3 lines

TOPS lets the process (I suppose the scheduler really) decide where some of the processing for the packet will happen - the part after the handoff.

I think this last part should be easy to do - but perhaps the expense of landing on the wrong CPU may override any benefits perceived.

cheers,
jamal

#22 lore raw
Quoted 4 lines
Quoted 1 line

The main idea behind TOPS and prior to that IPS was to spread-out the processing of packets across as many CPUs as we could, as "correctly" as we could.

Very very hard to do.

Why do you say that? "Correct" can be defined as either the same CPU for each packet in a given flow (IPS) or the same CPU as last accessed the endpoint (TOPS).

Quoted 1 line

Isnt MSI supposed to give you ability such that a NIC can pick a CPU to interupt? That would help in a small way

That gives the NIC the knowledge of how to direct to a CPU, but as you know does not tell it how to decide where. Since I doubt that the NIC wants to reach-out and touch connection state in the host (nor I suppose do we want it to either) the best a NIC with MSI could do would be IPS

Quoted 5 lines
Quoted 2 lines

TOPS lets the process (I suppose the scheduler really) decide where some of the processing for the packet will happen - the part after the handoff.

I think this last part should be easy to do - but perhaps the expense of landing on the wrong CPU may override any benefits perceived.

Unless one has a scheduler that likes to migrate processes, the chances of landing on the wrong CPU are minimal and shortlived, and overall, the chances of being right are greater than if not doing anything and sticking with the interrupt CPU. (Handwaving based on experience-driven intuition and a bit of math as one increases the CPU count) This is all on the premis that one is running with numNIC << numCPU. With numNIC == numCPU one does things as seen in certain networking-intensive benchmarks :)

rick jones

#23 lore raw
In reply to Rick Jones
Quoted 9 lines · Rick Jones

At the risk of again chewing on my toes (yum), if multiple CPUs are pulling packets from the per-device queue there will be packet reordering. HP-UX 10.0 did just that and it was quite nasty even at low CPU counts (<=4). It was changed by HP-UX 10.20 (ca 1995) to per-CPU queues with queue selection computed from packet headers (hash the IP and TCP/UDP header to pick a CPU) It was called IPS for Inbound Packet Scheduling. 11.0 (ca 1998) later changed that to "find where the connection last ran and queue to that CPU" That was called TOPS - Thread Optimized Packet Scheduling.

We went over this a lot several years ago when Linux got multi threaded RX with softnet in 2.1. You might want to go over the archives.

Some things that came out of it was a sender side TCP optimization to tolerate reordering without slowing down (works great with other Linux peers) and NAPI style polling mode (which was mostly designed for routing and still seems to have regressions for the client/server case :/)

Something like TOPS was discussed, but afaik nobody ever implemented it. Of course benchmark guys do it manually by setting interrupt and scheduler affinity.

-Andi