Merge branch 'net-sched-conditional-notification-of-events-for-cls-and-act'
authorJakub Kicinski <kuba@kernel.org>
Tue, 12 Dec 2023 02:53:00 +0000 (18:53 -0800)
committerJakub Kicinski <kuba@kernel.org>
Tue, 12 Dec 2023 02:53:01 +0000 (18:53 -0800)
commitb72137ecd5e6f445ecbe8e5ebd867dd25125bc66
treeb09cc8e5beb83e881ed077fe2ae68f505c0653eb
parent70028b2e51c61d8dda0a31985978f4745da6a11b
parent93775590b1ee98bf2976b1f4a1ed24e9ff76170f
Merge branch 'net-sched-conditional-notification-of-events-for-cls-and-act'

Pedro Tammela says:

====================
net/sched: conditional notification of events for cls and act

This is an optimization we have been leveraging on P4TC but we believe
it will benefit rtnl users in general.

It's common to allocate an skb, build a notification message and then
broadcast an event. In the absence of any user space listeners, these
resources (cpu and memory operations) are wasted. In cases where the subsystem
is lockless (such as in tc-flower) this waste is more prominent. For the
scenarios where the rtnl_lock is held it is not as prominent.

The idea is simple. Build and send the notification iif:
   - The user requests via NLM_F_ECHO or
   - Someone is listening to the rtnl group (tc mon)

On a simple test with tc-flower adding 1M entries, using just a single core,
there's already a noticeable difference in the cycles spent in tc_new_tfilter
with this patchset.

before:
   - 43.68% tc_new_tfilter
      + 31.73% fl_change
      + 6.35% tfilter_notify
      + 1.62% nlmsg_notify
        0.66% __tcf_qdisc_find.part.0
        0.64% __tcf_chain_get
        0.54% fl_get
      + 0.53% tcf_proto_lookup_ops

after:
   - 39.20% tc_new_tfilter
      + 34.58% fl_change
        0.69% __tcf_qdisc_find.part.0
        0.67% __tcf_chain_get
      + 0.61% tcf_proto_lookup_ops

Note, the above test is using iproute2:tc which execs a shell.
We expect people using netlink directly to observe even greater
reductions.

The qdisc side needs some refactoring of the notification routines to fit in
this new model, so they will be sent in a later patchset.
====================

Link: https://lore.kernel.org/r/20231208192847.714940-1-pctammela@mojatatu.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>