]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
rtnl: add helper to check if rtnl group has listeners
authorJamal Hadi Salim <jhs@mojatatu.com>
Fri, 8 Dec 2023 19:28:41 +0000 (16:28 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 25 Apr 2025 08:45:06 +0000 (10:45 +0200)
commitabd07987f7fee97da3593558d29a4de989b27246
treea5cf17d125c6de0a1fb1e7d86fe0bf3ac46c6e7f
parentaf4e364fb1c3b592d015e7a7c034540570ca831c
rtnl: add helper to check if rtnl group has listeners

[ Upstream commit c5e2a973448d958feb7881e4d875eac59fdeff3d ]

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.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Simon Horman <horms@kernel.org>
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>
Link: https://lore.kernel.org/r/20231208192847.714940-2-pctammela@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Stable-dep-of: 369609fc6272 ("tc: Ensure we have enough buffer space when sending filter netlink notifications")
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/rtnetlink.h