Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp830563ybm; Fri, 29 May 2020 13:16:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx1/cu4Tp0Y1CjWNwmblprEXi81oT0bSnXGfJiqePtIhk0ZPWHIzHc9RTnZn8tFuYocv6D X-Received: by 2002:a17:906:7f84:: with SMTP id f4mr8972529ejr.482.1590783404898; Fri, 29 May 2020 13:16:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590783404; cv=none; d=google.com; s=arc-20160816; b=qSouEXPwmReO3v1G7orZwf7A7He7tewbV9D19bdb4RMGgRYNqonwXOE4tCv618cveP 86DmyQFOeHCxvy7TNWCnaVfy8o03ZJgmY2W1zoWgNNd/Cqw1hYBFaiD27nyiHBdkh8sO 9alsubZgNd5Gx8P4W2W1XpvPc2lHDk5YgLa+tfuIb9K87x75yqfwxgjL7WnEMnyTPYNx /FL7nOeI+b+ozNAOp7gYjXzHYcPBLQCVFUoBcNs5dzDtDInSOADU1HKlR0/2ebeTgkZz iZOlMG1UCfRc7nrOjHHlS7ROIbz7f9tQ5oUQhqMNrkCxXFdF0YjSv/GdrO8uEhjHZYsN 6kPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=lKMjiAkyBRELY5MJOa4iNzst+P3tmhE7y0zlIzz5RG0=; b=yeuiQsB6vEiIU05RksGyu/HV2dO1xpS/zQ4sowrdEjz63MCIvRXMVsuj8aoLYz8cto qUFMsG41mM74eqwG7ZO0KJbfoneKjcRvoLPoFYT7ta76cdVDJQvhW1M/lQ+uoYcL4GTU AzdhoxUo/C/5bYYdEz89rvLvp7J0D+f1oYCBMGWACfKncOzzXCmjQLgBRz2uaDTKSCj0 i5u3xDQfrYJl3zCQs9++umlfI1OWm66UCuKnTLNuWiXHWZSZr/OjrS47iXEPYFSuJR0L RPZqDh08QHBSli/g9XyD3e7qCgVn81VqtnSXBw3M7AV/by5KyX9NR5bylz3Nm/Cr0vpg e+Kw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di12si3198196edb.27.2020.05.29.13.16.21; Fri, 29 May 2020 13:16:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728134AbgE2UOg (ORCPT + 99 others); Fri, 29 May 2020 16:14:36 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:54705 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726866AbgE2UOf (ORCPT ); Fri, 29 May 2020 16:14:35 -0400 Received: from threadripper.lan ([149.172.98.151]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1MfpjF-1j3Ei81kC1-00gKp9; Fri, 29 May 2020 22:14:17 +0200 From: Arnd Bergmann To: Jamal Hadi Salim , Cong Wang , Jiri Pirko , "David S. Miller" , Jakub Kicinski , Guillaume Nault Cc: Arnd Bergmann , Vlad Buslov , Xin Long , Pablo Neira Ayuso , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] flow_dissector: work around stack frame size warning Date: Fri, 29 May 2020 22:13:58 +0200 Message-Id: <20200529201413.397679-1-arnd@arndb.de> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:fGBRSFc62pb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JuQfebA2yAI2a AVJ4CFK9DRPt91NdKmOjhFc26pvVnki1y9W19wWGM4SQJweZ8Y= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The fl_flow_key structure is around 500 bytes, so having two of them on the stack in one function now exceeds the warning limit after an otherwise correct change: net/sched/cls_flower.c:298:12: error: stack frame size of 1056 bytes in function 'fl_classify' [-Werror,-Wframe-larger-than=] I suspect the fl_classify function could be reworked to only have one of them on the stack and modify it in place, but I could not work out how to do that. As a somewhat hacky workaround, move one of them into an out-of-line function to reduce its scope. This does not necessarily reduce the stack usage of the outer function, but at least the second copy is removed from the stack during most of it and does not add up to whatever is called from there. I now see 552 bytes of stack usage for fl_classify(), plus 528 bytes for fl_mask_lookup(). Fixes: 58cff782cc55 ("flow_dissector: Parse multiple MPLS Label Stack Entries") Signed-off-by: Arnd Bergmann --- net/sched/cls_flower.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c index 96f5999281e0..030896eadd11 100644 --- a/net/sched/cls_flower.c +++ b/net/sched/cls_flower.c @@ -272,14 +272,16 @@ static struct cls_fl_filter *fl_lookup_range(struct fl_flow_mask *mask, return NULL; } -static struct cls_fl_filter *fl_lookup(struct fl_flow_mask *mask, - struct fl_flow_key *mkey, - struct fl_flow_key *key) +static noinline_for_stack +struct cls_fl_filter *fl_mask_lookup(struct fl_flow_mask *mask, struct fl_flow_key *key) { + struct fl_flow_key mkey; + + fl_set_masked_key(&mkey, key, mask); if ((mask->flags & TCA_FLOWER_MASK_FLAGS_RANGE)) - return fl_lookup_range(mask, mkey, key); + return fl_lookup_range(mask, &mkey, key); - return __fl_lookup(mask, mkey); + return __fl_lookup(mask, &mkey); } static u16 fl_ct_info_to_flower_map[] = { @@ -299,7 +301,6 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, struct tcf_result *res) { struct cls_fl_head *head = rcu_dereference_bh(tp->root); - struct fl_flow_key skb_mkey; struct fl_flow_key skb_key; struct fl_flow_mask *mask; struct cls_fl_filter *f; @@ -319,9 +320,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp, ARRAY_SIZE(fl_ct_info_to_flower_map)); skb_flow_dissect(skb, &mask->dissector, &skb_key, 0); - fl_set_masked_key(&skb_mkey, &skb_key, mask); - - f = fl_lookup(mask, &skb_mkey, &skb_key); + f = fl_mask_lookup(mask, &skb_key); if (f && !tc_skip_sw(f->flags)) { *res = f->res; return tcf_exts_exec(skb, &f->exts, res); -- 2.26.2