Skip to contentSkip to conversation

flow director and packet ordering

DISCUSSION David Miller 3 participants 8 messages Jun 15, 2009 – Jul 6, 2009

Subsystems (2)
lore
Share & tools
lore

David Miller

author maintainer
#0 lore raw

Does the flow director implementation in IXGBE make sure to preserve packet ordering in some way?

You can't just change the RX flow destination queue whenever you like.

For example, if a transmit happens on cpu 1, then we start to receive some packets for that flow on that cpu, will a sudden set of transmits on another cpu make the flow director quickly switch the RX destination?

That would be very bad.

Without some extreme care that will result in potential packet reordering.

There needs to be some safey net in place in your silicon to wait for a significant "quiet time" in the RX stream before you can revector the RX flow destination setting. Enough time to let the stack process all that packets for that flow received on the currently bound flow CPU.

To be honest, I'm not optimistic about this situation :-/

#1 lore raw
Quoted 10 lines · David Miller

Does the flow director implementation in IXGBE make sure to preserve packet ordering in some way?

You can't just change the RX flow destination queue whenever you like.

For example, if a transmit happens on cpu 1, then we start to receive some packets for that flow on that cpu, will a sudden set of transmits on another cpu make the flow director quickly switch the RX destination?

Not by design, no. The mode of Flow Director that is currently in the driver is the hashing mode. 82599 also supports a perfect match mode, which isn't supported yet, since there's no good interface to program the 5-tuple filters (I've been watching the ethtool work from the Sun guys for niu, but haven't had time to help).

Back to the hashing mode. The idea is that a particular flow, say on CPU 1, will be hashed. There are two layers of hashing; the first will land the flow into a bucket, the second will land it into the filter lists. The two hash values for the Tx packet are then written to the filter table along with the Rx queue. There are two ways that the Rx queue for that flow could be moved: 1) The flow itself moves from CPU 1 to a different CPU. This is the most likely case that will move the Rx flow. 2) We have a double collision on the hashes. This really isn't very likely that a different flow will collide on both hashed values.

The reason we have two levels of hashing is to try and avoid this possible situation of a collision accidentally moving a different flow.

Quoted 2 lines

That would be very bad.

Agreed.

Quoted 9 lines

Without some extreme care that will result in potential packet reordering.

There needs to be some safey net in place in your silicon to wait for a significant "quiet time" in the RX stream before you can revector the RX flow destination setting. Enough time to let the stack process all that packets for that flow received on the currently bound flow CPU.

The current Rx DMA's that have been posted must be completed before our hardware will apply the changes to the Rx filters.

Quoted 2 lines

To be honest, I'm not optimistic about this situation :-/

The way the internal hashing works in the software and hardware, I think we're pretty safe with getting moved unexpectedely.

Cheers,
-PJ Waskiewicz

author maintainer
#2 lore raw

From: "Waskiewicz Jr, Peter P" <[email protected]>
Date: Mon, 15 Jun 2009 23:42:16 -0700 (Pacific Daylight Time)

Quoted 2 lines

The way the internal hashing works in the software and hardware, I think we're pretty safe with getting moved unexpectedely.

The device RX being empty doesn't mean anything.

Those packets, even after you give them all to netif_receive_skb(), can be held up in all number of queues, or even scheduled off to be processed by ksoftirqd after a full context switch.

In the meantime you cannot switch the RX queue mapping without introducing reordering.

So my original fears and doubts still stand :-)

#3 lore raw
Quoted 5 lines · David Miller

In the meantime you cannot switch the RX queue mapping without introducing reordering.

So my original fears and doubts still stand :-)

Methinks this whole idea is doomed. The fact is as long as there are more sockets than queues, then you can have two sockets pull the same queue in different directions and there's nothing you can do about that.

That's my bit of uncertainty for you :)

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#4 lore raw

From: Herbert Xu <[email protected]>
Date: Sun, 5 Jul 2009 12:19:55 +0800

Quoted 5 lines
Quoted 4 lines · David Miller

In the meantime you cannot switch the RX queue mapping without introducing reordering.

Quoted 8 lines
Quoted 1 line

So my original fears and doubts still stand :-)

Methinks this whole idea is doomed. The fact is as long as there are more sockets than queues, then you can have two sockets pull the same queue in different directions and there's nothing you can do about that.

That's my bit of uncertainty for you :)

Flows map to queues, queues don't move. Rather the mapping between flows and queues changes dynamically.

#5 lore raw
Quoted 3 lines · David Miller

Flows map to queues, queues don't move. Rather the mapping between flows and queues changes dynamically.

Oh that makes more sense.

In that case I don't see the big need in moving the flows/sockets after establishment. After all process migration should be rare, so if it does occur then it's OK for the existing sockets to stay on their original queue.

I'm curious about what the limit on the number of flows is though. Because when you go above that limit performance will magically suck :)

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
author maintainer
#6 lore raw

From: Herbert Xu <[email protected]>
Date: Mon, 6 Jul 2009 09:10:51 +0800

Quoted 4 lines

In that case I don't see the big need in moving the flows/sockets after establishment. After all process migration should be rare, so if it does occur then it's OK for the existing sockets to stay on their original queue.

I personally assume that a master process that accepts connections and then hands them off down to worker threads is quite common.

Quoted 3 lines

I'm curious about what the limit on the number of flows is though. Because when you go above that limit performance will magically suck :)

Yes, of course that's an important aspect of the implementation.

#7 lore raw
Quoted 3 lines · David Miller

I personally assume that a master process that accepts connections and then hands them off down to worker threads is quite common.

In this scenario I think it might be better to determine which worker thread to hand the socket to based on the current RX queue assignment. This way you won't have to worry about what limit the hardware has in terms of how many flows it can assign.

Of course if you can't modify the app then you'd have to rely on hardware assignment.

Cheers,

Signature · 4 lines
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt