diff mbox series

[ovs-dev,1/5] datapath: hide clang frame-overflow warnings

Message ID 1570656134-11957-2-git-send-email-gvrose8192@gmail.com
State Accepted
Commit 19b6110dd9e2b0026c57d7e7235383edcbdc38b7
Headers show
Series Backport upstream Linux kernel patches | expand

Commit Message

Gregory Rose Oct. 9, 2019, 9:22 p.m. UTC
From: Arnd Bergmann <arnd@arndb.de>

Upstream commit:
    commit 260637903f47f20c5918bb5c1eea52b2a28ea863
    Author: Arnd Bergmann <arnd@arndb.de>
    Date:   Mon Jul 22 17:00:01 2019 +0200

    ovs: datapath: hide clang frame-overflow warnings

    Some functions in the datapath code are factored out so that each
    one has a stack frame smaller than 1024 bytes with gcc. However,
    when compiling with clang, the functions are inlined more aggressively
    and combined again so we get

    net/openvswitch/datapath.c:1124:12: error: stack frame size of 1528 bytes in function 'ovs_flow_cmd_set' [-Werror,-Wframe-larger-than=]

    Marking both get_flow_actions() and ovs_nla_init_match_and_action()
    as 'noinline_for_stack' gives us the same behavior that we see with
    gcc, and no warning. Note that this does not mean we actually use
    less stack, as the functions call each other, and we still get
    three copies of the large 'struct sw_flow_key' type on the stack.

    The comment tells us that this was previously considered safe,
    presumably since the netlink parsing functions are called with
    a known backchain that does not also use a lot of stack space.

    Fixes: 9cc9a5cb176c ("datapath: Avoid using stack larger than 1024.")
    Signed-off-by: Arnd Bergmann <arnd@arndb.de>
    Signed-off-by: David S. Miller <davem@davemloft.net>

Cc: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Greg Rose <gvrose8192@gmail.com>
---
 datapath/datapath.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

Comments

0-day Robot Oct. 9, 2019, 9:59 p.m. UTC | #1
Bleep bloop.  Greetings Greg Rose, I am a robot and I have tried out your patch.
Thanks for your contribution.

I encountered some error that I wasn't expecting.  See the details below.


checkpatch:
ERROR: Author Arnd Bergmann <arnd@arndb.de> needs to sign off.
WARNING: Unexpected sign-offs from developers who are not authors or co-authors or committers: Greg Rose <gvrose8192@gmail.com>
Lines checked: 75, Warnings: 1, Errors: 1


Please check this out.  If you feel there has been an error, please email aconole@redhat.com

Thanks,
0-day Robot
Yi-Hung Wei Oct. 15, 2019, 6:05 p.m. UTC | #2
On Wed, Oct 9, 2019 at 2:23 PM Greg Rose <gvrose8192@gmail.com> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Upstream commit:
>     commit 260637903f47f20c5918bb5c1eea52b2a28ea863
>     Author: Arnd Bergmann <arnd@arndb.de>
>     Date:   Mon Jul 22 17:00:01 2019 +0200
>
>     ovs: datapath: hide clang frame-overflow warnings
>
>     Some functions in the datapath code are factored out so that each
>     one has a stack frame smaller than 1024 bytes with gcc. However,
>     when compiling with clang, the functions are inlined more aggressively
>     and combined again so we get
>
>     net/openvswitch/datapath.c:1124:12: error: stack frame size of 1528 bytes in function 'ovs_flow_cmd_set' [-Werror,-Wframe-larger-than=]
>
>     Marking both get_flow_actions() and ovs_nla_init_match_and_action()
>     as 'noinline_for_stack' gives us the same behavior that we see with
>     gcc, and no warning. Note that this does not mean we actually use
>     less stack, as the functions call each other, and we still get
>     three copies of the large 'struct sw_flow_key' type on the stack.
>
>     The comment tells us that this was previously considered safe,
>     presumably since the netlink parsing functions are called with
>     a known backchain that does not also use a lot of stack space.
>
>     Fixes: 9cc9a5cb176c ("datapath: Avoid using stack larger than 1024.")
>     Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>     Signed-off-by: David S. Miller <davem@davemloft.net>
>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Greg Rose <gvrose8192@gmail.com>
> ---
Looks good to me.

Acked-by: Yi-Hung Wei <yihung.wei@gmail.com>
diff mbox series

Patch

diff --git a/datapath/datapath.c b/datapath/datapath.c
index 94e4f6f..15af156 100644
--- a/datapath/datapath.c
+++ b/datapath/datapath.c
@@ -1069,7 +1069,7 @@  error:
 }
 
 /* Factor out action copy to avoid "Wframe-larger-than=1024" warning. */
-static struct sw_flow_actions *get_flow_actions(struct net *net,
+static noinline_for_stack struct sw_flow_actions *get_flow_actions(struct net *net,
 						const struct nlattr *a,
 						const struct sw_flow_key *key,
 						const struct sw_flow_mask *mask,
@@ -1103,12 +1103,13 @@  static struct sw_flow_actions *get_flow_actions(struct net *net,
  * we should not to return match object with dangling reference
  * to mask.
  * */
-static int ovs_nla_init_match_and_action(struct net *net,
-					 struct sw_flow_match *match,
-					 struct sw_flow_key *key,
-					 struct nlattr **a,
-					 struct sw_flow_actions **acts,
-					 bool log)
+static noinline_for_stack int
+ovs_nla_init_match_and_action(struct net *net,
+			      struct sw_flow_match *match,
+			      struct sw_flow_key *key,
+			      struct nlattr **a,
+			      struct sw_flow_actions **acts,
+			      bool log)
 {
 	struct sw_flow_mask mask;
 	int error = 0;