* [PATCH] net-udp: deprioritize cpu match for udp socket lookup
@ 2018-12-05 20:59 Maciej Żenczykowski
2018-12-08 0:16 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Maciej Żenczykowski @ 2018-12-05 20:59 UTC (permalink / raw)
To: Maciej Żenczykowski, David S . Miller, Eric Dumazet; +Cc: netdev
From: Maciej Żenczykowski <maze@google.com>
During udp socket lookup cpu match should be lowest priority,
hence it should increase score by only 1.
The next priority is delivering v4 to v4 sockets, and v6 to v6 sockets.
The v6 code path doesn't have to deal with this so it always gets
a score of '4'. The v4 code path uses '4' or '2' depending on
whether we're delivering to a v4 socket or a dualstack v6 socket.
This is more important than cpu match, so has to be greater than
the '1' bump in score from cpu match.
All other matches (src/dst ip, src port) are even *more* important,
so need to bump score by 4 for ipv4.
For ipv6 we could simply bump by 2, but let's keep the two code
paths as similar as possible.
(also, while at it, remove two unnecessary unconditional score bumps)
Signed-off-by: Maciej Żenczykowski <maze@google.com>
---
net/ipv4/udp.c | 3 +--
net/ipv6/udp.c | 9 ++++-----
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index aff2a8e99e01..0c0ab0383cec 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -380,7 +380,7 @@ static int compute_score(struct sock *sk, struct net *net,
ipv6_only_sock(sk))
return -1;
- score = (sk->sk_family == PF_INET) ? 2 : 1;
+ score = (sk->sk_family == PF_INET) ? 4 : 2;
inet = inet_sk(sk);
if (inet->inet_rcv_saddr) {
@@ -405,7 +405,6 @@ static int compute_score(struct sock *sk, struct net *net,
dif, sdif);
if (!dev_match)
return -1;
- score += 4;
if (sk->sk_incoming_cpu == raw_smp_processor_id())
score++;
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 09cba4cfe31f..5441062d7d5e 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -125,31 +125,30 @@ static int compute_score(struct sock *sk, struct net *net,
sk->sk_family != PF_INET6)
return -1;
- score = 0;
+ score = 4;
inet = inet_sk(sk);
if (inet->inet_dport) {
if (inet->inet_dport != sport)
return -1;
- score++;
+ score += 4;
}
if (!ipv6_addr_any(&sk->sk_v6_rcv_saddr)) {
if (!ipv6_addr_equal(&sk->sk_v6_rcv_saddr, daddr))
return -1;
- score++;
+ score += 4;
}
if (!ipv6_addr_any(&sk->sk_v6_daddr)) {
if (!ipv6_addr_equal(&sk->sk_v6_daddr, saddr))
return -1;
- score++;
+ score += 4;
}
dev_match = udp_sk_bound_dev_eq(net, sk->sk_bound_dev_if, dif, sdif);
if (!dev_match)
return -1;
- score++;
if (sk->sk_incoming_cpu == raw_smp_processor_id())
score++;
--
2.20.0.rc1.387.gf8505762e3-goog
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] net-udp: deprioritize cpu match for udp socket lookup
2018-12-05 20:59 [PATCH] net-udp: deprioritize cpu match for udp socket lookup Maciej Żenczykowski
@ 2018-12-08 0:16 ` David Miller
2018-12-08 0:46 ` Maciej Żenczykowski
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2018-12-08 0:16 UTC (permalink / raw)
To: zenczykowski; +Cc: maze, edumazet, netdev
From: Maciej Żenczykowski <zenczykowski@gmail.com>
Date: Wed, 5 Dec 2018 12:59:17 -0800
> From: Maciej Żenczykowski <maze@google.com>
>
> During udp socket lookup cpu match should be lowest priority,
> hence it should increase score by only 1.
>
> The next priority is delivering v4 to v4 sockets, and v6 to v6 sockets.
> The v6 code path doesn't have to deal with this so it always gets
> a score of '4'. The v4 code path uses '4' or '2' depending on
> whether we're delivering to a v4 socket or a dualstack v6 socket.
>
> This is more important than cpu match, so has to be greater than
> the '1' bump in score from cpu match.
>
> All other matches (src/dst ip, src port) are even *more* important,
> so need to bump score by 4 for ipv4.
>
> For ipv6 we could simply bump by 2, but let's keep the two code
> paths as similar as possible.
>
> (also, while at it, remove two unnecessary unconditional score bumps)
>
> Signed-off-by: Maciej Żenczykowski <maze@google.com>
This doesn't apply to the current net tree.
Also "net-udp: " is a weird subsystem prefix, just use "udp: ".
Thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-udp: deprioritize cpu match for udp socket lookup
2018-12-08 0:16 ` David Miller
@ 2018-12-08 0:46 ` Maciej Żenczykowski
2018-12-08 6:24 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Maciej Żenczykowski @ 2018-12-08 0:46 UTC (permalink / raw)
To: David S. Miller; +Cc: Eric Dumazet, Linux NetDev
> This doesn't apply to the current net tree.
>
> Also "net-udp: " is a weird subsystem prefix, just use "udp: ".
>
> Thank you.
Interesting... this patch was on top of net-next/master, and it still
rebases cleanly on current net-next/master.
Would you like it on net/master instead? It indeed doesn't apply
cleanly there...
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-udp: deprioritize cpu match for udp socket lookup
2018-12-08 0:46 ` Maciej Żenczykowski
@ 2018-12-08 6:24 ` David Miller
2018-12-10 3:29 ` David Ahern
0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2018-12-08 6:24 UTC (permalink / raw)
To: zenczykowski; +Cc: edumazet, netdev
From: Maciej Żenczykowski <zenczykowski@gmail.com>
Date: Fri, 7 Dec 2018 16:46:36 -0800
>> This doesn't apply to the current net tree.
>>
>> Also "net-udp: " is a weird subsystem prefix, just use "udp: ".
>>
>> Thank you.
>
> Interesting... this patch was on top of net-next/master, and it still
> rebases cleanly on current net-next/master.
>
> Would you like it on net/master instead? It indeed doesn't apply
> cleanly there...
Well, it is a bug fix isn't it? Or is this more like a behavioral feature?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-udp: deprioritize cpu match for udp socket lookup
2018-12-08 6:24 ` David Miller
@ 2018-12-10 3:29 ` David Ahern
2018-12-10 4:18 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: David Ahern @ 2018-12-10 3:29 UTC (permalink / raw)
To: David Miller, zenczykowski; +Cc: edumazet, netdev
On 12/7/18 11:24 PM, David Miller wrote:
> From: Maciej Żenczykowski <zenczykowski@gmail.com>
> Date: Fri, 7 Dec 2018 16:46:36 -0800
>
>>> This doesn't apply to the current net tree.
>>>
>>> Also "net-udp: " is a weird subsystem prefix, just use "udp: ".
>>>
>>> Thank you.
>>
>> Interesting... this patch was on top of net-next/master, and it still
>> rebases cleanly on current net-next/master.
>>
>> Would you like it on net/master instead? It indeed doesn't apply
>> cleanly there...
>
> Well, it is a bug fix isn't it? Or is this more like a behavioral feature?
>
If this goes in can it target net-next first? Some soak time there will
help show if there are any side effects before propagating to stable
releases.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net-udp: deprioritize cpu match for udp socket lookup
2018-12-10 3:29 ` David Ahern
@ 2018-12-10 4:18 ` David Miller
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2018-12-10 4:18 UTC (permalink / raw)
To: dsahern; +Cc: zenczykowski, edumazet, netdev
From: David Ahern <dsahern@gmail.com>
Date: Sun, 9 Dec 2018 20:29:04 -0700
> If this goes in can it target net-next first? Some soak time there
> will help show if there are any side effects before propagating to
> stable releases.
Ok.
Maciej please resubmit this specifically targetting net-next.
Thank you.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-12-10 4:19 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-05 20:59 [PATCH] net-udp: deprioritize cpu match for udp socket lookup Maciej Żenczykowski
2018-12-08 0:16 ` David Miller
2018-12-08 0:46 ` Maciej Żenczykowski
2018-12-08 6:24 ` David Miller
2018-12-10 3:29 ` David Ahern
2018-12-10 4:18 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).