Use percpu data to move the large temporary buffer off the push_nsh
stack. This reduces stack consumption from 336 bytes to 64 bytes.

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

diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
index be15ef693284..fa53e22f3ebe 100644
--- a/net/openvswitch/actions.c
+++ b/net/openvswitch/actions.c
@@ -349,12 +349,18 @@ static int push_eth(struct sk_buff *skb, struct 
sw_flow_key *key,
        return 0;
 }
 
+struct tmp_nsh_hdr {
+       u8 data[NSH_HDR_MAX_LEN];
+};
+
+static DEFINE_PER_CPU(struct tmp_nsh_hdr, tmp_nsh_hdr);
+
 static noinline_for_stack int push_nsh(struct sk_buff *skb,
                                       struct sw_flow_key *key,
                                       const struct nlattr *a)
 {
-       u8 buffer[NSH_HDR_MAX_LEN];
-       struct nshhdr *nh = (struct nshhdr *)buffer;
+       struct tmp_nsh_hdr *hdr = this_cpu_ptr(&tmp_nsh_hdr);
+       struct nshhdr *nh = (struct nshhdr *)&hdr->data[0];
        int err;
 
        err = nsh_hdr_from_nlattr(a, nh, NSH_HDR_MAX_LEN);
-- 
2.42.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to