[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <67093b209de14_236a96294b2@willemb.c.googlers.com.notmuch>
Date: Fri, 11 Oct 2024 10:50:08 -0400
From: Willem de Bruijn <willemdebruijn.kernel@...il.com>
To: Philo Lu <lulie@...ux.alibaba.com>,
Willem de Bruijn <willemdebruijn.kernel@...il.com>,
netdev@...r.kernel.org
Cc: davem@...emloft.net,
edumazet@...gle.com,
kuba@...nel.org,
pabeni@...hat.com,
dsahern@...nel.org,
antony.antony@...unet.com,
steffen.klassert@...unet.com,
linux-kernel@...r.kernel.org,
dust.li@...ux.alibaba.com,
jakub@...udflare.com,
fred.cc@...baba-inc.com,
yubing.qiuyubing@...baba-inc.com
Subject: Re: [PATCH v3 net-next 3/3] ipv4/udp: Add 4-tuple hash for connected
socket
Philo Lu wrote:
>
>
> On 2024/10/10 21:49, Willem de Bruijn wrote:
> > Philo Lu wrote:
> >> Currently, the udp_table has two hash table, the port hash and portaddr
> >> hash. Usually for UDP servers, all sockets have the same local port and
> >> addr, so they are all on the same hash slot within a reuseport group.
> >>
> >> In some applications, UDP servers use connect() to manage clients. In
> >> particular, when firstly receiving from an unseen 4 tuple, a new socket
> >> is created and connect()ed to the remote addr:port, and then the fd is
> >> used exclusively by the client.
> >>
> >> Once there are connected sks in a reuseport group, udp has to score all
> >> sks in the same hash2 slot to find the best match. This could be
> >> inefficient with a large number of connections, resulting in high
> >> softirq overhead.
> >>
> >> To solve the problem, this patch implement 4-tuple hash for connected
> >> udp sockets. During connect(), hash4 slot is updated, as well as a
> >> corresponding counter, hash4_cnt, in hslot2. In __udp4_lib_lookup(),
> >> hslot4 will be searched firstly if the counter is non-zero. Otherwise,
> >> hslot2 is used like before. Note that only connected sockets enter this
> >> hash4 path, while un-connected ones are not affected.
> >>
> >> Signed-off-by: Philo Lu <lulie@...ux.alibaba.com>
> >> Signed-off-by: Cambda Zhu <cambda@...ux.alibaba.com>
> >> Signed-off-by: Fred Chen <fred.cc@...baba-inc.com>
> >> Signed-off-by: Yubing Qiu <yubing.qiuyubing@...baba-inc.com>
> >
> >> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> >> index bbf3352213c4..4d3dfcb48a39 100644
> >> --- a/net/ipv6/udp.c
> >> +++ b/net/ipv6/udp.c
> >> @@ -111,7 +111,7 @@ void udp_v6_rehash(struct sock *sk)
> >> &sk->sk_v6_rcv_saddr,
> >> inet_sk(sk)->inet_num);
> >>
> >> - udp_lib_rehash(sk, new_hash);
> >> + udp_lib_rehash(sk, new_hash, 0); /* 4-tuple hash not implemented */
> >
> > What is the plan for IPv6?
> >
>
> iiuc, udp6 shares the same udptable with udp4, and the hash-related
> implementations are almost the same, so there is no obvious obstacle for
> udp6 hash4 as long as udp4 hash4 is ready. And I'll do it right after
> udp4 hash4.
Okay great.
Powered by blists - more mailing lists