Message ID | 20231204203907.413435-2-pctammela@mojatatu.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net/sched: conditional notification of events for cls and act | expand |
Mon, Dec 04, 2023 at 09:39:03PM CET, pctammela@mojatatu.com wrote: >From: Jamal Hadi Salim <jhs@mojatatu.com> > >As of today, rtnl code creates a new skb and unconditionally fills and >broadcasts it to the relevant group. For most operations this is okay >and doesn't waste resources in general. > >When operations are done without the rtnl_lock, as in tc-flower, such >skb allocation, message fill and no-op broadcasting can happen in all >cores of the system, which contributes to system pressure and wastes >precious cpu cycles when no one will receive the built message. > >Introduce this helper so rtnetlink operations can simply check if someone >is listening and then proceed if necessary. > >Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com> >Signed-off-by: Victor Nogueira <victor@mojatatu.com> >Signed-off-by: Pedro Tammela <pctammela@mojatatu.com> Reviewed-by: Jiri Pirko <jiri@nvidia.com>
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 3d6cf306cd55..a7d757e96c55 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -130,4 +130,11 @@ extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, extern void rtnl_offload_xstats_notify(struct net_device *dev); +static inline int rtnl_has_listeners(const struct net *net, u32 group) +{ + struct sock *rtnl = net->rtnl; + + return netlink_has_listeners(rtnl, group); +} + #endif /* __LINUX_RTNETLINK_H */