diff mbox series

[RFC,2/7] net: openvswitch: Reduce execute_push_nsh stack overhead

Message ID 20230927001308.749910-3-npiggin@gmail.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: openvswitch: Reduce stack usage | expand

Checks

Context Check Description
netdev/tree_selection success Guessing tree name failed - patch did not apply

Commit Message

Nicholas Piggin Sept. 27, 2023, 12:13 a.m. UTC
Use dynamic allocation to reduce execute_push_nsh stack consumption
from 336 bytes to 64 bytes, at the cost of introducing a GFP_ATOMIC
allocation.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
 net/openvswitch/actions.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index 8933caa92794..af177701a606 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -1290,13 +1290,17 @@  static noinline_for_stack int execute_push_nsh(struct sk_buff *skb,
 					       struct sw_flow_key *key,
 					       const struct nlattr *attr)
 {
-	u8 buffer[NSH_HDR_MAX_LEN];
-	struct nshhdr *nh = (struct nshhdr *)buffer;
+	struct nshhdr *nh;
 	int err;
 
+	nh = kmalloc(NSH_HDR_MAX_LEN, GFP_ATOMIC);
+	if (unlikely(!nh))
+		return -ENOMEM; /* XXX: should this skip action like clone? */
+
 	err = nsh_hdr_from_nlattr(attr, nh, NSH_HDR_MAX_LEN);
 	if (likely(!err))
 		err = push_nsh(skb, key, nh);
+	kfree(nh);
 
 	return err;
 }