BPF List
 help / color / mirror / Atom feed
From: Jamal Hadi Salim <jhs@mojatatu.com>
To: netdev@vger.kernel.org
Cc: deb.chatterjee@intel.com, anjali.singhai@intel.com,
	namrata.limaye@intel.com, mleitner@redhat.com,
	Mahesh.Shirshyad@amd.com, tomasz.osinski@intel.com,
	jiri@resnulli.us, xiyou.wangcong@gmail.com, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, pabeni@redhat.com,
	vladbu@nvidia.com, horms@kernel.org, khalidm@nvidia.com,
	toke@redhat.com, daniel@iogearbox.net, bpf@vger.kernel.org
Subject: [PATCH net-next v9 07/15] rtnl: add helper to check if group has listeners
Date: Fri,  1 Dec 2023 13:28:56 -0500	[thread overview]
Message-ID: <20231201182904.532825-8-jhs@mojatatu.com> (raw)
In-Reply-To: <20231201182904.532825-1-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.

For P4TC, it's interesting to know if the TC group has any listeners
when adding/updating/deleting table entries as we can optimize for the
most likely case it contains none. This not only improves our processing
speed, it also reduces pressure on the system memory as we completely
avoid the broadcast skb allocation.

Co-developed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: Victor Nogueira <victor@mojatatu.com>
Co-developed-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Signed-off-by: Jamal Hadi Salim <jhs@mojatatu.com>
---
 include/linux/rtnetlink.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 971055e66..487e45f8a 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -142,4 +142,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 */
-- 
2.34.1


  parent reply	other threads:[~2023-12-01 18:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-01 18:28 [PATCH net-next v9 00/15] Introducing P4TC Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 01/15] net: sched: act_api: Introduce P4 actions list Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 02/15] net/sched: act_api: increase action kind string length Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 03/15] net/sched: act_api: Update tc_action_ops to account for P4 actions Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 04/15] net/sched: act_api: add struct p4tc_action_ops as a parameter to lookup callback Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 05/15] net: sched: act_api: Add support for preallocated P4 action instances Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 06/15] net: introduce rcu_replace_pointer_rtnl Jamal Hadi Salim
2023-12-01 18:28 ` Jamal Hadi Salim [this message]
2023-12-01 18:28 ` [PATCH net-next v9 08/15] p4tc: add P4 data types Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 09/15] p4tc: add template pipeline create, get, update, delete Jamal Hadi Salim
2023-12-01 18:28 ` [PATCH net-next v9 10/15] p4tc: add action template create, update, delete, get, flush and dump Jamal Hadi Salim
2023-12-01 18:29 ` [PATCH net-next v9 11/15] p4tc: add P4 action runtime support Jamal Hadi Salim
2023-12-01 18:29 ` [PATCH net-next v9 12/15] p4tc: add template table create, update, delete, get, flush and dump Jamal Hadi Salim
2023-12-01 18:29 ` [PATCH net-next v9 13/15] p4tc: add runtime table entry create, update, get, delete, " Jamal Hadi Salim
2023-12-06  5:34   ` Dan Carpenter
2023-12-06 15:08     ` Jamal Hadi Salim
2023-12-01 18:29 ` [PATCH net-next v9 14/15] p4tc: add set of P4TC table kfuncs Jamal Hadi Salim
2023-12-08  7:33   ` Martin KaFai Lau
2023-12-08 10:15     ` Toke Høiland-Jørgensen
2023-12-08 20:07       ` Martin KaFai Lau
2023-12-11 15:00         ` Toke Høiland-Jørgensen
2023-12-11 15:18           ` Jamal Hadi Salim
2023-12-01 18:29 ` [PATCH net-next v9 15/15] p4tc: add P4 classifier Jamal Hadi Salim
2023-12-05  0:32   ` John Fastabend
2023-12-05 13:43     ` Daniel Borkmann
2023-12-05 16:23       ` Jamal Hadi Salim
2023-12-05 22:32         ` Daniel Borkmann
2023-12-06 14:59           ` Jamal Hadi Salim
2023-12-08 10:06             ` Daniel Borkmann
2023-12-11 15:43               ` Jamal Hadi Salim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231201182904.532825-8-jhs@mojatatu.com \
    --to=jhs@mojatatu.com \
    --cc=Mahesh.Shirshyad@amd.com \
    --cc=anjali.singhai@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=deb.chatterjee@intel.com \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=khalidm@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mleitner@redhat.com \
    --cc=namrata.limaye@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=toke@redhat.com \
    --cc=tomasz.osinski@intel.com \
    --cc=vladbu@nvidia.com \
    --cc=xiyou.wangcong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox