From mboxrd@z Thu Jan 1 00:00:00 1970 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 15004C05027 for ; Tue, 14 Feb 2023 19:40:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8694A6B0074; Tue, 14 Feb 2023 14:40:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8192E6B0075; Tue, 14 Feb 2023 14:40:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 707B46B0078; Tue, 14 Feb 2023 14:40:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 5F6086B0074 for ; Tue, 14 Feb 2023 14:40:21 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 22230A0E44 for ; Tue, 14 Feb 2023 19:40:21 +0000 (UTC) X-FDA: 80466913842.05.A7993D5 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf18.hostedemail.com (Postfix) with ESMTP id 33D7F1C0009 for ; Tue, 14 Feb 2023 19:40:18 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=cp605a2O; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1676403619; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Op13fe7cM0WW9AFf3mRMjOqBT3cIvQfmgUIRH6wk7tQ=; b=jN9GGJM/MTqjEkwR9WinTV+QJYQ30KFvdgyUP72Zb4igk53bQhcjugINXhaI3EYzvSNGH9 A5Dl2q6/3EEx5NmpvMBdiztAnMmeXMR7r72v2jQSxWRkNR4sy8g1gjt787babfkfJaXZOQ DVh5EGh4Q6Zx3JPVhmlWMwd8+cQLEKE= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=cp605a2O; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1676403619; a=rsa-sha256; cv=none; b=aGm/Gi3SuhUMSpT9zborNdlyUr+VgS8qCp+K2hQbcZ0bXluhorirF9t+cbkNSlZHUliM3i 1w6bEXpIU9FgyYfgZCAcZ0mlb0oq9amt4qyJYedoWHX4IuE6KIiWpGa/CkOU7ukhPP4frY BFuMS/+Xgp95Q46sMuwL2b5surLCAN4= 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 ams.source.kernel.org (Postfix) with ESMTPS id 5736CB81ED4; Tue, 14 Feb 2023 19:40:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A6F9C433D2; Tue, 14 Feb 2023 19:40:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1676403616; bh=0LXw8JRUDtoPyyAboFWv208CWuieeyd4q3a7teZHquw=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=cp605a2Oj3lti83QtBZeb2dXcHH2XVW++5WVUtUa45Lzwbyb/rWLlgGh8WduACpdW leqoMvaYTETfFlU4dqEijCxp4unnzzOuq1p3+o4wnKsU4j/LTisjIamTNiJ5Cz+HS6 bRyZdlWe3iVr8gzFzrSdZUs09rV8hv0OTnSHpVEo= Date: Tue, 14 Feb 2023 11:40:14 -0800 From: Andrew Morton To: Arnd Bergmann Cc: "Liam R. Howlett" , Arnd Bergmann , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Vincenzo Frascino , kasan-dev@googlegroups.com, Vernon Yang , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [RFC] maple_tree: reduce stack usage with gcc-9 and earlier Message-Id: <20230214114014.4ce0afb658fae97d81f32925@linux-foundation.org> In-Reply-To: <20230214103030.1051950-1-arnd@kernel.org> References: <20230214103030.1051950-1-arnd@kernel.org> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: msexc7em98cw85xzb8xnuc8jkstjudzr X-Rspamd-Queue-Id: 33D7F1C0009 X-HE-Tag: 1676403618-371631 X-HE-Meta: U2FsdGVkX1+bVMFI1uOA1vhHC2EFyQajIfpSfT16v5fUUsU4GyY5CQoeI+0id8CIKWenA3i7rO9wlRwt0s6adsqMtAI77dFRwIH/1eGR0OiGMov8ytyVkUj4p9U+ILib33xTx9r38Rwc4qcBFrR2bhYptlJQIOmVd+m/YmOYtxm4rOcT5cCVh9PSF7NidsznxGVv2ktoMYcdY4V3ZDmd5ZRP7/cbM/oYKIX33YdwNVyZhUnKikYgm8/CD+vjftRfHouwQjtCeMfdl8jnGjBtc8SfIp4Z0Rzk/5oSHo6eR3LYbm4pkVNAmMrLuxgcxIKk+9wet8eGyb5A4SpMTIs/Uyewl+M4r87gS1aORTp5D7QGbU3aW+pFmtklMIVwY13nDOn/ezligs+wYPFG15xu7wNp8mSNFl7whMqMAtO2I3bBKpk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ofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, 14 Feb 2023 11:30:24 +0100 Arnd Bergmann wrote: > 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. > > ... > > --- 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 Should noinline_for_kasan be defined in kasan.h? maple_tree.c is unlikely to be the only place in the kernel which could use this treatment? I suppose we can do that when the need arises.