Re: [PATCH net-next v10 08/15] quic: add path management
Xin Long <[email protected]> Wed, 4 Mar 2026 16:25:50 -0500
| Newsgroups | dev.linux.lists.quic,dev.linux.lists.kernel-tls-handshake,org.kernel.vger.linux-cifs,org.kernel.vger.netdev |
|---|---|
| Message-ID | <CADvbK_f84jwQPRq-xztO9mN+m_NWXaf6Q+9Ao-YtDiGQfmudLw@mail.gmail.com> |
On Tue, Mar 3, 2026 at 3:23=E2=80=AFAM Paolo Abeni <[email protected]> wrot= e: > > On 2/25/26 3:34 AM, Xin Long wrote: > > +/* Binds a QUIC path to a local port and sets up a UDP socket. */ > > +int quic_path_bind(struct sock *sk, struct quic_path_group *paths, u8 = path) > > +{ > > + union quic_addr *a =3D quic_path_saddr(paths, path); > > + int rover, low, high, remaining; > > + struct net *net =3D sock_net(sk); > > + struct quic_uhash_head *head; > > + struct quic_udp_sock *us; > > + u16 port; > > + > > + port =3D ntohs(a->v4.sin_port); > > + if (port) { > > + head =3D quic_udp_sock_head(net, port); > > + mutex_lock(&head->lock); > > + us =3D quic_udp_sock_lookup(sk, a, port); > > + if (us) { > > When the quick socket is already bound to a local port, reusing an > existing udp tunnel sock is allowed, but when the quick socket is not > bound, UDP tunnel sock reused is prevented. This looks confusing and not > documented, please clarify the behavior and/or make it consistent. > Yes, /* Reuse of an existing UDP tunnel socket is allowed, * but if it is currently being freed asynchronously by the workqueue, * it cannot be used now =E2=80=94 retry later. */ Let me know if it's still not clear. > > > + if (!quic_udp_sock_get(us)) { /* Releasing in wor= kqueue; retry later. */ > > + mutex_unlock(&head->lock); > > + return -EAGAIN; > > Why not -EADDRINUSE here? Because in this case, the us is being released in workqueue, a retry will likely succeed. > > > + } > > + } else { > > + us =3D quic_udp_sock_create(sk, a); > > + if (!us) { > > + mutex_unlock(&head->lock); > > + return -EINVAL; > > It's probably better to propagate an error code (PTR_ERR) from > quic_udp_sock_create(), or use -ENOMEM > Changing to PTR_ERR looks better. > [...] > > @@ -332,6 +333,12 @@ static __init int quic_init(void) > > if (err) > > goto err_hash; > > > > + quic_wq =3D create_workqueue("quic_workqueue"); > > + if (!quic_wq) { > > + err =3D -ENOMEM; > > + goto err_wq; > > + } > > AI review noted that: > > This isn't a bug, but create_workqueue() is a legacy API marked with > __WQ_LEGACY in include/linux/workqueue.h. Should new subsystem code use > alloc_workqueue() with explicit flags instead? > > Looking at include/linux/workqueue.h, create_workqueue() implicitly sets > WQ_PERCPU, creating per-CPU worker threads. Since quic_wq only handles > infrequent UDP socket cleanup via quic_udp_sock_put_work() in path.c, is > per-CPU allocation necessary here? Would alloc_workqueue("quic_workqueue"= , > WQ_MEM_RECLAIM, 0) be more appropriate, or could this simply use system_w= q > if memory reclaim safety is not required? > This workqueue is also used for processing some backlog packets, which requ= ires process context. I will move the infrequent UDP socket cleanup to system_wq as the AI sugges= ts, and leave this workqueue for the backlog packets processing only. Then the allocation becomes: quic_wq =3D alloc_workqueue("quic_workqueue", WQ_PERCPU, 0); Thanks.