Re: [PATCH] connector/cn_proc: cn_netlink_has_listeners replaces proc_event_num_listeners

From: Paolo Abeni
Date: Thu Feb 08 2024 - 04:46:26 EST


On Sun, 2024-02-04 at 16:22 +0800, Keqi Wang wrote:
> It is not accurate to reset proc_event_num_listeners according to
> cn_netlink_send_mult() return value -ESRCH.
>
> In the case of stress-ng netlink-proc, -ESRCH will always be returned,
> because netlink_broadcast_filtered will return -ESRCH,
> which may cause stress-ng netlink-proc performance degradation.
>
> proc_event_num_listeners cannot accurately reflect whether
> the listener exists, so add cn_netlink_has_listeners() functon
> and use that instead of proc_event_num_listeners.

Adding Anjali for awareness, as the last active developer in this area.

This change looks really invasive for a net fix. It's not trivially
clear to me if the change of accounting schema will bring or not
unintended functional/behavioural changes.

What about a simple revert of the blamed commit, and target net-next
with this kind of change?

> @@ -396,10 +404,10 @@ static void cn_proc_ack(int err, int rcvd_seq, int rcvd_ack)
> static void cn_proc_mcast_ctl(struct cn_msg *msg,
> struct netlink_skb_parms *nsp)
> {
> - enum proc_cn_mcast_op mc_op = 0, prev_mc_op = 0;
> + enum proc_cn_mcast_op mc_op = 0;
> struct proc_input *pinput = NULL;
> enum proc_cn_event ev_type = 0;
> - int err = 0, initial = 0;
> + int err = 0;
> struct sock *sk = NULL;

Minor nit: the above breaks the reverse xmas tree order

Cheers,

Paolo