From: Nicholas Piggin <npiggin@gmail.com>
To: netdev@vger.kernel.org
Cc: Nicholas Piggin <npiggin@gmail.com>,
dev@openvswitch.org, Pravin B Shelar <pshelar@ovn.org>
Subject: [RFC PATCH 7/7] net: openvswitch: Reduce stack usage in ovs_dp_process_packet
Date: Wed, 27 Sep 2023 10:13:08 +1000 [thread overview]
Message-ID: <20230927001308.749910-8-npiggin@gmail.com> (raw)
In-Reply-To: <20230927001308.749910-1-npiggin@gmail.com>
The upcall in ovs_dp_process_packet uses a lot of stack and is not
involved in the recursive call. Move it into an out of line function,
reducing stack overhead from 144 to 96 bytes.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
net/openvswitch/datapath.c | 55 +++++++++++++++++++++-----------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 11c69415c605..bdbbdd556c4a 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -242,6 +242,37 @@ void ovs_dp_detach_port(struct vport *p)
ovs_vport_del(p);
}
+static noinline_for_stack
+void do_packet_upcall(struct sk_buff *skb, struct sw_flow_key *key,
+ const struct vport *p, struct datapath *dp)
+{
+ struct dp_upcall_info upcall;
+ int error;
+
+ memset(&upcall, 0, sizeof(upcall));
+ upcall.cmd = OVS_PACKET_CMD_MISS;
+
+ if (dp->user_features & OVS_DP_F_DISPATCH_UPCALL_PER_CPU)
+ upcall.portid =
+ ovs_dp_get_upcall_portid(dp, smp_processor_id());
+ else
+ upcall.portid = ovs_vport_find_upcall_portid(p, skb);
+
+ upcall.mru = OVS_CB(skb)->mru;
+ error = ovs_dp_upcall(dp, skb, key, &upcall, 0);
+ switch (error) {
+ case 0:
+ case -EAGAIN:
+ case -ERESTARTSYS:
+ case -EINTR:
+ consume_skb(skb);
+ break;
+ default:
+ kfree_skb(skb);
+ break;
+ }
+}
+
/* Must be called with rcu_read_lock. */
void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
{
@@ -261,30 +292,6 @@ void ovs_dp_process_packet(struct sk_buff *skb, struct sw_flow_key *key)
flow = ovs_flow_tbl_lookup_stats(&dp->table, key, skb_get_hash(skb),
&n_mask_hit, &n_cache_hit);
if (unlikely(!flow)) {
- struct dp_upcall_info upcall;
-
- memset(&upcall, 0, sizeof(upcall));
- upcall.cmd = OVS_PACKET_CMD_MISS;
-
- if (dp->user_features & OVS_DP_F_DISPATCH_UPCALL_PER_CPU)
- upcall.portid =
- ovs_dp_get_upcall_portid(dp, smp_processor_id());
- else
- upcall.portid = ovs_vport_find_upcall_portid(p, skb);
-
- upcall.mru = OVS_CB(skb)->mru;
- error = ovs_dp_upcall(dp, skb, key, &upcall, 0);
- switch (error) {
- case 0:
- case -EAGAIN:
- case -ERESTARTSYS:
- case -EINTR:
- consume_skb(skb);
- break;
- default:
- kfree_skb(skb);
- break;
- }
stats_counter = &stats->n_missed;
goto out;
}
--
2.40.1
next prev parent reply other threads:[~2023-09-27 0:13 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 0:13 [RFC PATCH 0/7] net: openvswitch: Reduce stack usage Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 1/7] net: openvswitch: Move NSH buffer out of do_execute_actions Nicholas Piggin
2023-09-27 8:26 ` [ovs-dev] " Ilya Maximets
2023-09-27 10:03 ` Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 2/7] net: openvswitch: Reduce execute_push_nsh stack overhead Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 3/7] net: openvswitch: uninline action execution Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 4/7] net: openvswitch: ovs_vport_receive reduce stack usage Nicholas Piggin
2023-09-28 15:26 ` [ovs-dev] " Aaron Conole
2023-09-29 7:00 ` Nicholas Piggin
2023-09-29 8:38 ` Eelco Chaudron
2023-10-04 7:11 ` Nicholas Piggin
2023-10-04 15:15 ` Aaron Conole
2023-10-05 2:01 ` Nicholas Piggin
2023-10-11 13:34 ` Aaron Conole
2023-10-11 23:58 ` Nicholas Piggin
2023-10-04 7:29 ` Nicholas Piggin
2023-10-04 15:16 ` Aaron Conole
2023-09-27 0:13 ` [RFC PATCH 5/7] net: openvswitch: uninline ovs_fragment to control " Nicholas Piggin
2023-09-27 0:13 ` [RFC PATCH 6/7] net: openvswitch: Reduce ovs_fragment " Nicholas Piggin
2023-09-27 0:13 ` Nicholas Piggin [this message]
2023-09-27 15:22 ` [RFC PATCH 7/7] net: openvswitch: Reduce stack usage in ovs_dp_process_packet kernel test robot
2023-09-27 8:36 ` [ovs-dev] [RFC PATCH 0/7] net: openvswitch: Reduce stack usage Ilya Maximets
2023-09-28 1:52 ` Nicholas Piggin
2023-10-02 11:54 ` Ilya Maximets
2023-10-04 9:56 ` Nicholas Piggin
2023-09-29 7:06 ` Nicholas Piggin
2023-10-02 11:56 ` Ilya Maximets
2023-10-03 13:31 ` Aaron Conole
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=20230927001308.749910-8-npiggin@gmail.com \
--to=npiggin@gmail.com \
--cc=dev@openvswitch.org \
--cc=netdev@vger.kernel.org \
--cc=pshelar@ovn.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.