From patchwork Tue Feb 14 10:30:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13139811 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97F2FC61DA4 for ; Tue, 14 Feb 2023 10:30:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 142536B0073; Tue, 14 Feb 2023 05:30:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F31C6B0074; Tue, 14 Feb 2023 05:30:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F230A6B0075; Tue, 14 Feb 2023 05:30:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E3F1C6B0073 for ; Tue, 14 Feb 2023 05:30:38 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A28191602A2 for ; Tue, 14 Feb 2023 10:30:38 +0000 (UTC) X-FDA: 80465528556.10.9F35BF3 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 1E93740002 for ; Tue, 14 Feb 2023 10:30:35 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FRujVgQd; spf=pass (imf17.hostedemail.com: domain of arnd@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676370636; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=iO2oNcvyj+5oQXBNXKeF8zvrEC8UyLgmscT1pfcl3Oc=; b=6ANV1xR/CXOGbPYfM70P/80XfQatgoNQ0ea1GlIDG/Rzqa8jpVD2NH8xOM7PSZoDsPg9vy bHX9DPAMX7TMVUuBtYHuNKUCrhXQ3f1GhSPZSqjseSq6uu+UIQsZlPQiW7AS1xAVeqkZ/y PTvmqnC7Q4BjAsyAnJvAI3EF3eHxjr8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=FRujVgQd; spf=pass (imf17.hostedemail.com: domain of arnd@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676370636; a=rsa-sha256; cv=none; b=XQDuzDkF2mJZG1fQVdA/RbttgBq4E5iDWGt81RYoaito5KtpACFyu9wl9RQ6N89VwPa/Fv qtNFVk53vZTLBv5qQb6pUtA/vxasK0itvO3CKYWkKkfJynd3SW2+PUzZBAB1ILCpjLEgcd 3tcoUA6ZKtKDiuQsSRlhFyP4u7MFOCE= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E65C761509; Tue, 14 Feb 2023 10:30:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7E7BC433EF; Tue, 14 Feb 2023 10:30:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676370634; bh=9T6pAt8RK/wq+3Lfrzi3xrLApHJkjngyCRo3iZZ8lcM=; h=From:To:Cc:Subject:Date:From; b=FRujVgQdhII1Y1kLFdI49NShstvdPkwW9DJTqMSApgiaz2cPn7FjCjQsVcxy4228C Y2iGvCNYWUAVz2GoYmvgW2/ja59ZwxyVnyZ/BZ5onLQ07n19oJvl9EMTfpbNRn2xgq QEkw6+6Tsoyx5p198fWDYBUoQNdDInMJM93CtK3a8RafJ9ykweJIG58qK5MtdG6Xwh U9+1ikY/FV6uI+wm1uM8FqSnEwksPW9wwkTs3CdLV2cNxbQXAybJXpU5dvxK+b++fE KjkKPqFqmv32h6dHpqvqQmgppq5BrWQQ5lZ0JudInrsf0adg25t3Pl1T7cCZATr4/h jIv3FSv/RYIZQ== From: Arnd Bergmann To: "Liam R. Howlett" Cc: Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , kasan-dev@googlegroups.com, Andrew Morton , Vernon Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] [RFC] maple_tree: reduce stack usage with gcc-9 and earlier Date: Tue, 14 Feb 2023 11:30:24 +0100 Message-Id: <20230214103030.1051950-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 1E93740002 X-Rspam-User: X-Stat-Signature: j4b3dgiczdpycnkd6uj73jtyx484boz3 X-HE-Tag: 1676370635-787847 X-HE-Meta: U2FsdGVkX1/P0bRy0cB4OEG8MSzq/Lz1pvfEwbQgXEGDKmbpW6EN8trgvqdqLqqQ7mpTRq7nTS6g0lMJrqCJPRN1PHwo7lw/2P6aC2EKDkqKic/gxnqJfDQMjlgPbCY0HKXkDif5F6Aoe2MRbmLCwmcJCwmW/ZlbRs6SMCvB/AtBR3jc4sAXijUJ/u3MA4JLKcOduEfm7ANMDqPkLLOQY2EUD2JulmpIikw1l9RXew91F1rgGRyWnFEocfcjUoifV86/5YBOONxaWlV57nFH6rwzzlV8lwIdp5fmQoq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Moqm1G/x5vuInokHW939vlfG3Ntm8Q49k19lANOXZrUtNK+9fydnnbtzVtyEHU/i4wuTBVhvGLZiyiXBSHBda3H0d8alLmwthW6Trn+pu3WdHe3OBZDThqp1gacGK/3JZxngAsGpNmfks+ALa2MxJ1N6XkB7vpdqkI0ynZ9v3ffZ3SIXKdP3w9dsKH4q78/3NyuVBJ0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Arnd Bergmann gcc-10 changed the way inlining works to be less aggressive, but older versions run into an oversized stack frame warning whenever CONFIG_KASAN_STACK is enabled, as that forces variables from inlined callees to be non-overlapping: lib/maple_tree.c: In function 'mas_wr_bnode': lib/maple_tree.c:4320:1: error: the frame size of 1424 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Change the annotations on mas_store_b_node() and mas_commit_b_node() to explicitly forbid inlining in this configuration, which is the same behavior that newer versions already have. Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Vincenzo Frascino Cc: kasan-dev@googlegroups.com Signed-off-by: Arnd Bergmann Reviewed-by: David Hildenbrand Reviewed-by: Liam R. Howlett --- lib/maple_tree.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 5e9703189259..646297cae5d1 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -146,6 +146,13 @@ struct maple_subtree_state { struct maple_big_node *bn; }; +#ifdef CONFIG_KASAN_STACK +/* Prevent mas_wr_bnode() from exceeding the stack frame limit */ +#define noinline_for_kasan noinline_for_stack +#else +#define noinline_for_kasan inline +#endif + /* Functions */ static inline struct maple_node *mt_alloc_one(gfp_t gfp) { @@ -2107,7 +2114,7 @@ static inline void mas_bulk_rebalance(struct ma_state *mas, unsigned char end, * * Return: The actual end of the data stored in @b_node */ -static inline void mas_store_b_node(struct ma_wr_state *wr_mas, +static noinline_for_kasan void mas_store_b_node(struct ma_wr_state *wr_mas, struct maple_big_node *b_node, unsigned char offset_end) { unsigned char slot; @@ -3579,7 +3586,7 @@ static inline bool mas_reuse_node(struct ma_wr_state *wr_mas, * @b_node: The maple big node * @end: The end of the data. */ -static inline int mas_commit_b_node(struct ma_wr_state *wr_mas, +static noinline_for_kasan int mas_commit_b_node(struct ma_wr_state *wr_mas, struct maple_big_node *b_node, unsigned char end) { struct maple_node *node;