Re: [PATCH net-next] rtnetlink: comment the RCU and SRCU waits in unregister paths
From: Andrea Parri
Date: Tue Oct 13 2026 - 06:59:28 EST
On Mon, Oct 12, 2026 at 06:48:22PM -0700, Kuniyuki Iwashima wrote:
> > + /* Wait for rtnl_get_link() callers under RCU that may still
> > + * dereference tab.
> > + */
> > synchronize_net();
>
> More specifically, this only applies to callers before try_module_get().
Right, the later lookup in rtnetlink_rcv_msg() runs under RTNL. I'll
name rtnetlink_rcv_msg() and try_module_get() in v2.
> > + /* Wait for rtnl_link_ops_get() callers to call rtnl_link_ops_put(). */
> > synchronize_srcu(&ops->srcu);
>
> I think we don't need comment for srcu as the relation is
> clear via the argument.
Agreed, I'll drop both srcu comments.
> > + /* Wait for RCU walkers of rtnl_af_ops, including rtnl_af_lookup()
> > + * readers that found ops but have not yet taken ops->srcu.
> > + */
>
> this can be simply /* see rtnl_link_unregister() */ instead of duplicating
> comments.
The two waits cover different readers, though. Besides
rtnl_af_lookup(), the synchronize_rcu() in rtnl_af_unregister() also
waits for the RCU walkers of rtnl_af_ops that invoke callbacks without
ops->srcu: rtnl_link_get_af_size(), rtnl_fill_link_af() and the
IFLA_STATS_AF_SPEC paths. link_ops has no analogous RCU-only list
walkers, so a pointer there would miss them. I'd prefer to keep a
local comment, reworded in v2 to mention those walkers.
Thanks,
Andrea