Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

6 messages, 4 authors, 2016-01-08 · open the first message on its own page

Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

From: Vitaly Kuznetsov <vkuznets@redhat.com>
Date: 2016-01-07 13:28:32

Eric Dumazet [off-list ref] writes:
On Thu, 2016-01-07 at 10:33 +0100, Vitaly Kuznetsov wrote:
quoted
Recent changes to 'struct flow_keys' (e.g commit d34af823ff40 ("net: Add
 VLAN ID to flow_keys")) introduced a performance regression in netvsc
driver. Is problem is, however, not the above mentioned commit but the
fact that netvsc_set_hash() function did some assumptions on the struct
flow_keys data layout and this is wrong. We need to extract the data we
need (src/dst addresses and ports) after the dissect.

The issue could also be solved in a completely different way: as suggested
by Eric instead of our own homegrown netvsc_set_hash() we could use
skb_get_hash() which does more or less the same. Unfortunately, the
testing done by Simon showed that Hyper-V hosts are not happy with our
Jenkins hash, selecting the output queue with the current algorithm based
on Toeplitz hash works significantly better.
Were tests done on IPv6 traffic ?
Simon, could you please test this patch for IPv6 and show us the numbers?
Toeplitz hash takes at least 100 ns to hash 12 bytes (one iteration per
bit : 96 iterations)

For IPv6 it is 3 times this, since we have to hash 36 bytes.

I do not see how it can compete with skb_get_hash() that directly gives
skb->hash for local TCP flows.
My guess is that this is not the bottleneck, something is happening
behind the scene with out packets in Hyper-V host (e.g. re-distributing
them to hardware queues?) but I don't know the internals, Microsoft
folks could probably comment.

See commits b73c3d0e4f0e1961e15bec18720e48aabebe2109
("net: Save TX flow hash in sock and set in skbuf on xmit")
and 877d1f6291f8e391237e324be58479a3e3a7407c
("net: Set sk_txhash from a random number")

I understand Microsoft loves Toeplitz, but this looks not well placed
here.

I suspect there is another problem.

Please share your numbers and test methodology, and the alternative
patch Simon tested so that we can double check it.
Alternative patch which uses skb_get_hash() attached. Simon, could you
please share the rest (environment, metodology, numbers) with us here?
Thanks!
Thanks.

PS: For the time being this patch can probably be applied on -net tree,
as it fixes a real bug.
-- 
  Vitaly

Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

From: John Fastabend <john.fastabend@gmail.com>
Date: 2016-01-08 01:02:32

On 16-01-07 05:28 AM, Vitaly Kuznetsov wrote:
Eric Dumazet [off-list ref] writes:
quoted
On Thu, 2016-01-07 at 10:33 +0100, Vitaly Kuznetsov wrote:
quoted
Recent changes to 'struct flow_keys' (e.g commit d34af823ff40 ("net: Add
 VLAN ID to flow_keys")) introduced a performance regression in netvsc
driver. Is problem is, however, not the above mentioned commit but the
fact that netvsc_set_hash() function did some assumptions on the struct
flow_keys data layout and this is wrong. We need to extract the data we
need (src/dst addresses and ports) after the dissect.

The issue could also be solved in a completely different way: as suggested
by Eric instead of our own homegrown netvsc_set_hash() we could use
skb_get_hash() which does more or less the same. Unfortunately, the
testing done by Simon showed that Hyper-V hosts are not happy with our
Jenkins hash, selecting the output queue with the current algorithm based
on Toeplitz hash works significantly better.
Also can I ask the maybe naive question. It looks like the hypervisor
is populating some table via a mailbox msg and this is used to select
the queues I guess with some sort of weighting function?

What happens if you just remove select_queue altogether? Or maybe just
what is this 16 entry table doing? How does this work on my larger
systems with 64+ cores can I only use 16 cores? Sorry I really have
no experience with hyperV and this got me curious.

Thanks,
John
quoted
Were tests done on IPv6 traffic ?
Simon, could you please test this patch for IPv6 and show us the numbers?
quoted
Toeplitz hash takes at least 100 ns to hash 12 bytes (one iteration per
bit : 96 iterations)

For IPv6 it is 3 times this, since we have to hash 36 bytes.

I do not see how it can compete with skb_get_hash() that directly gives
skb->hash for local TCP flows.
My guess is that this is not the bottleneck, something is happening
behind the scene with out packets in Hyper-V host (e.g. re-distributing
them to hardware queues?) but I don't know the internals, Microsoft
folks could probably comment.

quoted
See commits b73c3d0e4f0e1961e15bec18720e48aabebe2109
("net: Save TX flow hash in sock and set in skbuf on xmit")
and 877d1f6291f8e391237e324be58479a3e3a7407c
("net: Set sk_txhash from a random number")

I understand Microsoft loves Toeplitz, but this looks not well placed
here.

I suspect there is another problem.

Please share your numbers and test methodology, and the alternative
patch Simon tested so that we can double check it.
Alternative patch which uses skb_get_hash() attached. Simon, could you
please share the rest (environment, metodology, numbers) with us here?
Thanks!
quoted
Thanks.

PS: For the time being this patch can probably be applied on -net tree,
as it fixes a real bug.

RE: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

From: KY Srinivasan <kys@microsoft.com>
Date: 2016-01-08 03:49:22

-----Original Message-----
From: John Fastabend [mailto:john.fastabend@gmail.com]
Sent: Thursday, January 7, 2016 5:02 PM
To: Vitaly Kuznetsov <vkuznets@redhat.com>; Simon Xiao
[off-list ref]; Eric Dumazet [off-list ref]
Cc: Tom Herbert <redacted>; netdev@vger.kernel.org; KY
Srinivasan [off-list ref]; Haiyang Zhang [off-list ref];
devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; David Miller
[off-list ref]
Subject: Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct
flow_keys layout

On 16-01-07 05:28 AM, Vitaly Kuznetsov wrote:
quoted
Eric Dumazet [off-list ref] writes:
quoted
On Thu, 2016-01-07 at 10:33 +0100, Vitaly Kuznetsov wrote:
quoted
Recent changes to 'struct flow_keys' (e.g commit d34af823ff40 ("net: Add
 VLAN ID to flow_keys")) introduced a performance regression in netvsc
driver. Is problem is, however, not the above mentioned commit but the
fact that netvsc_set_hash() function did some assumptions on the struct
flow_keys data layout and this is wrong. We need to extract the data we
need (src/dst addresses and ports) after the dissect.

The issue could also be solved in a completely different way: as suggested
by Eric instead of our own homegrown netvsc_set_hash() we could use
skb_get_hash() which does more or less the same. Unfortunately, the
testing done by Simon showed that Hyper-V hosts are not happy with our
Jenkins hash, selecting the output queue with the current algorithm based
on Toeplitz hash works significantly better.
Also can I ask the maybe naive question. It looks like the hypervisor
is populating some table via a mailbox msg and this is used to select
the queues I guess with some sort of weighting function?

What happens if you just remove select_queue altogether? Or maybe just
what is this 16 entry table doing? How does this work on my larger
systems with 64+ cores can I only use 16 cores? Sorry I really have
no experience with hyperV and this got me curious.
We will limit the number of VRSS channels to the number of CPUs in
a NUMA node. If the number of CPUs in a NUMA node exceeds 8, we
will only open up 8 VRSS channels. On the host side currently traffic
spreading is done in software and we have found that limiting to 8 CPUs
gives us the best throughput. In Windows Server 2016, we will be 
distributing traffic on the host in hardware; the heuristics in the guest
may change.

Regards,

K. Y
Thanks,
John
quoted
quoted
Were tests done on IPv6 traffic ?
Simon, could you please test this patch for IPv6 and show us the numbers?
quoted
Toeplitz hash takes at least 100 ns to hash 12 bytes (one iteration per
bit : 96 iterations)

For IPv6 it is 3 times this, since we have to hash 36 bytes.

I do not see how it can compete with skb_get_hash() that directly gives
skb->hash for local TCP flows.
My guess is that this is not the bottleneck, something is happening
behind the scene with out packets in Hyper-V host (e.g. re-distributing
them to hardware queues?) but I don't know the internals, Microsoft
folks could probably comment.

quoted
See commits b73c3d0e4f0e1961e15bec18720e48aabebe2109
("net: Save TX flow hash in sock and set in skbuf on xmit")
and 877d1f6291f8e391237e324be58479a3e3a7407c
("net: Set sk_txhash from a random number")

I understand Microsoft loves Toeplitz, but this looks not well placed
here.

I suspect there is another problem.

Please share your numbers and test methodology, and the alternative
patch Simon tested so that we can double check it.
Alternative patch which uses skb_get_hash() attached. Simon, could you
please share the rest (environment, metodology, numbers) with us here?
Thanks!
quoted
Thanks.

PS: For the time being this patch can probably be applied on -net tree,
as it fixes a real bug.

Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

From: John Fastabend <john.fastabend@gmail.com>
Date: 2016-01-08 06:17:09

On 16-01-07 07:49 PM, KY Srinivasan wrote:
quoted
-----Original Message-----
From: John Fastabend [mailto:john.fastabend@gmail.com]
Sent: Thursday, January 7, 2016 5:02 PM
To: Vitaly Kuznetsov <vkuznets@redhat.com>; Simon Xiao
[off-list ref]; Eric Dumazet [off-list ref]
Cc: Tom Herbert <redacted>; netdev@vger.kernel.org; KY
Srinivasan [off-list ref]; Haiyang Zhang [off-list ref];
devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; David Miller
[off-list ref]
Subject: Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct
flow_keys layout

On 16-01-07 05:28 AM, Vitaly Kuznetsov wrote:
quoted
Eric Dumazet [off-list ref] writes:
quoted
On Thu, 2016-01-07 at 10:33 +0100, Vitaly Kuznetsov wrote:
quoted
Recent changes to 'struct flow_keys' (e.g commit d34af823ff40 ("net: Add
 VLAN ID to flow_keys")) introduced a performance regression in netvsc
driver. Is problem is, however, not the above mentioned commit but the
fact that netvsc_set_hash() function did some assumptions on the struct
flow_keys data layout and this is wrong. We need to extract the data we
need (src/dst addresses and ports) after the dissect.

The issue could also be solved in a completely different way: as suggested
by Eric instead of our own homegrown netvsc_set_hash() we could use
skb_get_hash() which does more or less the same. Unfortunately, the
testing done by Simon showed that Hyper-V hosts are not happy with our
Jenkins hash, selecting the output queue with the current algorithm based
on Toeplitz hash works significantly better.
Also can I ask the maybe naive question. It looks like the hypervisor
is populating some table via a mailbox msg and this is used to select
the queues I guess with some sort of weighting function?

What happens if you just remove select_queue altogether? Or maybe just
what is this 16 entry table doing? How does this work on my larger
systems with 64+ cores can I only use 16 cores? Sorry I really have
no experience with hyperV and this got me curious.
We will limit the number of VRSS channels to the number of CPUs in
a NUMA node. If the number of CPUs in a NUMA node exceeds 8, we
will only open up 8 VRSS channels. On the host side currently traffic
spreading is done in software and we have found that limiting to 8 CPUs
gives us the best throughput. In Windows Server 2016, we will be 
distributing traffic on the host in hardware; the heuristics in the guest
may change.

Regards,

K. Y
I think a better way to do this would be to query the numa node when
the interface comes online via dev_to_node() and then use cpu_to_node()
or create/find some better variant to get a list of cpus on the numa
node.

At this point you can use the xps mapping interface
netif_set_xps_queue() to get the right queue to cpu binding. If you want
to cap it to max 8 queues that works as well. I don't think there is
any value to have more tx queues than number of cpus in use.

If you do it this way all the normal mechanisms to setup queue mappings
will work for users who are doing some special configuration and the
default will still be what you want.

I guess I should go do this numa mapping for ixgbe and friends now that
I mention it. Last perf numbers I had showed cross numa affinitizing
was pretty bad.

Thanks,
John

RE: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

From: KY Srinivasan <kys@microsoft.com>
Date: 2016-01-08 18:01:40

-----Original Message-----
From: John Fastabend [mailto:john.fastabend@gmail.com]
Sent: Thursday, January 7, 2016 10:17 PM
To: KY Srinivasan <kys@microsoft.com>; Vitaly Kuznetsov
[off-list ref]; Simon Xiao [off-list ref]; Eric Dumazet
[off-list ref]
Cc: Tom Herbert <redacted>; netdev@vger.kernel.org;
Haiyang Zhang [off-list ref]; devel@linuxdriverproject.org;
linux-kernel@vger.kernel.org; David Miller [off-list ref]
Subject: Re: [PATCH net-next] hv_netvsc: don't make assumptions on struct
flow_keys layout

On 16-01-07 07:49 PM, KY Srinivasan wrote:
quoted
quoted
-----Original Message-----
From: John Fastabend [mailto:john.fastabend@gmail.com]
Sent: Thursday, January 7, 2016 5:02 PM
To: Vitaly Kuznetsov <vkuznets@redhat.com>; Simon Xiao
[off-list ref]; Eric Dumazet [off-list ref]
Cc: Tom Herbert <redacted>; netdev@vger.kernel.org; KY
Srinivasan [off-list ref]; Haiyang Zhang
[off-list ref];
quoted
quoted
devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; David Miller
[off-list ref]
Subject: Re: [PATCH net-next] hv_netvsc: don't make assumptions on
struct
quoted
quoted
flow_keys layout

On 16-01-07 05:28 AM, Vitaly Kuznetsov wrote:
quoted
Eric Dumazet [off-list ref] writes:
quoted
On Thu, 2016-01-07 at 10:33 +0100, Vitaly Kuznetsov wrote:
quoted
Recent changes to 'struct flow_keys' (e.g commit d34af823ff40 ("net:
Add
quoted
quoted
quoted
quoted
quoted
 VLAN ID to flow_keys")) introduced a performance regression in
netvsc
quoted
quoted
quoted
quoted
quoted
driver. Is problem is, however, not the above mentioned commit but
the
quoted
quoted
quoted
quoted
quoted
fact that netvsc_set_hash() function did some assumptions on the
struct
quoted
quoted
quoted
quoted
quoted
flow_keys data layout and this is wrong. We need to extract the data
we
quoted
quoted
quoted
quoted
quoted
need (src/dst addresses and ports) after the dissect.

The issue could also be solved in a completely different way: as
suggested
quoted
quoted
quoted
quoted
quoted
by Eric instead of our own homegrown netvsc_set_hash() we could
use
quoted
quoted
quoted
quoted
quoted
skb_get_hash() which does more or less the same. Unfortunately,
the
quoted
quoted
quoted
quoted
quoted
testing done by Simon showed that Hyper-V hosts are not happy with
our
quoted
quoted
quoted
quoted
quoted
Jenkins hash, selecting the output queue with the current algorithm
based
quoted
quoted
quoted
quoted
quoted
on Toeplitz hash works significantly better.
Also can I ask the maybe naive question. It looks like the hypervisor
is populating some table via a mailbox msg and this is used to select
the queues I guess with some sort of weighting function?

What happens if you just remove select_queue altogether? Or maybe
just
quoted
quoted
what is this 16 entry table doing? How does this work on my larger
systems with 64+ cores can I only use 16 cores? Sorry I really have
no experience with hyperV and this got me curious.
We will limit the number of VRSS channels to the number of CPUs in
a NUMA node. If the number of CPUs in a NUMA node exceeds 8, we
will only open up 8 VRSS channels. On the host side currently traffic
spreading is done in software and we have found that limiting to 8 CPUs
gives us the best throughput. In Windows Server 2016, we will be
distributing traffic on the host in hardware; the heuristics in the guest
may change.

Regards,

K. Y
I think a better way to do this would be to query the numa node when
the interface comes online via dev_to_node() and then use cpu_to_node()
or create/find some better variant to get a list of cpus on the numa
node.

At this point you can use the xps mapping interface
netif_set_xps_queue() to get the right queue to cpu binding. If you want
to cap it to max 8 queues that works as well. I don't think there is
any value to have more tx queues than number of cpus in use.

If you do it this way all the normal mechanisms to setup queue mappings
will work for users who are doing some special configuration and the
default will still be what you want.

I guess I should go do this numa mapping for ixgbe and friends now that
I mention it. Last perf numbers I had showed cross numa affinitizing
was pretty bad.

Thanks,
John
John,

I am little confused. In the guest, we need to first open the sub-channels (VRSS queues) based on what the host is offering. While we cannot open more sub-channels than what the host is offering, the guest can certainly open fewer sub-channels. I was describing the heuristics for how many sub-channels the guest currently opens. This is based on the NUMA topology presented to the guest and the number of VCPUs provisioned for the guest. The binding of VCPUs to the channels occur at the point of opening these channels.

Regards,

K. Y 

RE: [PATCH net-next] hv_netvsc: don't make assumptions on struct flow_keys layout

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: 2016-01-08 21:08:04

-----Original Message-----
From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com]
Sent: Thursday, January 7, 2016 8:28 AM
To: Simon Xiao <redacted>; Eric Dumazet
[off-list ref]
Cc: Tom Herbert <redacted>; netdev@vger.kernel.org; KY
Srinivasan [off-list ref]; Haiyang Zhang [off-list ref];
devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; David Miller
[off-list ref]
Subject: Re: [PATCH net-next] hv_netvsc: don't make assumptions on
struct flow_keys layout

Eric Dumazet [off-list ref] writes:
quoted
On Thu, 2016-01-07 at 10:33 +0100, Vitaly Kuznetsov wrote:
quoted
Recent changes to 'struct flow_keys' (e.g commit d34af823ff40 ("net:
Add
quoted
quoted
 VLAN ID to flow_keys")) introduced a performance regression in
netvsc
quoted
quoted
driver. Is problem is, however, not the above mentioned commit but
the
quoted
quoted
fact that netvsc_set_hash() function did some assumptions on the
struct
quoted
quoted
flow_keys data layout and this is wrong. We need to extract the data
we
quoted
quoted
need (src/dst addresses and ports) after the dissect.

The issue could also be solved in a completely different way: as
suggested
quoted
quoted
by Eric instead of our own homegrown netvsc_set_hash() we could use
skb_get_hash() which does more or less the same. Unfortunately, the
testing done by Simon showed that Hyper-V hosts are not happy with
our
quoted
quoted
Jenkins hash, selecting the output queue with the current algorithm
based
quoted
quoted
on Toeplitz hash works significantly better.
Were tests done on IPv6 traffic ?
Simon, could you please test this patch for IPv6 and show us the numbers?
quoted
Toeplitz hash takes at least 100 ns to hash 12 bytes (one iteration
per
quoted
bit : 96 iterations)

For IPv6 it is 3 times this, since we have to hash 36 bytes.

I do not see how it can compete with skb_get_hash() that directly
gives
quoted
skb->hash for local TCP flows.
My guess is that this is not the bottleneck, something is happening
behind the scene with out packets in Hyper-V host (e.g. re-distributing
them to hardware queues?) but I don't know the internals, Microsoft
folks could probably comment.
The Hyper-V vRSS protocol lets us use the Toeplitz hash algorithm. We are
currently running further tests, including IPv6 too, and will share the 
results when available.

Thanks,
- Haiyang
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help