Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5023960rdb; Tue, 12 Dec 2023 17:13:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IGizz8z/OAlx6MUqIr0t55Excjyh+VcmLsgY1qSou5Ni3wCQdVRangMvwxtY0hFgKFNaIUm X-Received: by 2002:a62:e414:0:b0:6ce:2731:e873 with SMTP id r20-20020a62e414000000b006ce2731e873mr6594913pfh.58.1702430034279; Tue, 12 Dec 2023 17:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702430034; cv=none; d=google.com; s=arc-20160816; b=iXVsmnY1HFMxAJaHN9oJwh7UGEuloTh8g4YT0+oNlposfEyqTmHXWyhTeFY7l7I3d0 EoJZgo2FIybSKSTo8VhI4E8Cs/JX/3pZPp1EqBKw8DtIlaLIv/gFKEJqZGKxNa8XVcY2 LT4bp/SxpHjxOQVf9HAPBJcTQx4Mb9TEJxcum5CdPwr0m7iiB8aQUJvmTTKqtYgbtxb1 XRuGf5ecoA4WTF9ycV9PIeoL+5ra0W36C/CYL7teuIHEWtKcAoOSQ1mXDJQDMWhBrOPV KCRY0iaBVThCgTleMx2pAKlYsTDqEAALYwDdtXibr/gMAjqTm+r5+NtESscBMAs8WyS8 vZhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:content-language:references:cc:to:user-agent:mime-version:date :message-id:feedback-id:dkim-signature:dkim-signature; bh=q1SPQYQRBWl7bFrY5/lVAS8dc6PpLJdw7+EOXaZGVW4=; fh=8EoQs3IKtzrq8J3jIaI/LcYmlxqkFBB3eTaQqXZiDwk=; b=sKBVzfVImY7op6b1t1iwlste8ghZMfz7isEzJ3HSTU5qBlb9uqHzbDAbtWeZoF3VB6 yDNTnltoWezhKEyak+ZTsO82c0bOhoPjIFMgqS0DKuHrjevjzLqzQLsyvP6EjVOO0bml bxB3qBbJPBrPyCT3pystCqaM9VuO+aSEuNISBTf0S+RbPQMu4McNu2l3UQQGQhAz+5Vd TP0wc2W9GdHKRefEKS6FOv+QJfY5r2lN6QUplnHBWSaF7CCZDOg01+p5vrxVBrSHBjbL kUlSoS8e7OdRmro7xTaznx5jho4pZXq0iHeR5XEhyoMug8Q0SOJjjOEr1poAr9VJ8D18 HSCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b=Ze0PwEh2; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=2Pu5VDvJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=themaw.net Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id n10-20020a6563ca000000b005c66240925dsi8506561pgv.546.2023.12.12.17.13.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 17:13:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@themaw.net header.s=fm3 header.b=Ze0PwEh2; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=2Pu5VDvJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=themaw.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C0BEE80A9DC0; Tue, 12 Dec 2023 17:13:51 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378132AbjLMBNf (ORCPT + 99 others); Tue, 12 Dec 2023 20:13:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377653AbjLMBNe (ORCPT ); Tue, 12 Dec 2023 20:13:34 -0500 Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43ED391; Tue, 12 Dec 2023 17:13:39 -0800 (PST) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id CE0295C01D7; Tue, 12 Dec 2023 20:13:36 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Tue, 12 Dec 2023 20:13:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=themaw.net; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1702430016; x=1702516416; bh=q1SPQYQRBWl7bFrY5/lVAS8dc6PpLJdw7+EOXaZGVW4=; b= Ze0PwEh2S3szHV/ysnl1BX0zv1/CfSBmMStu4vXojWR8sKZ/+ev5W6PpgP4i1la5 INWsbQWMZOhPOPz0Ss3v6hx3aLl+r3+O7DNtSkjQ4k8b0BSpKudqERUpkdFcwWrC u5Hb9hQrPiUyBnGaK0Mx2qM5oHX/QOJyk1ltkecAlXM1w18/xSMNTkSNkMkIcha3 aBigpGgHNFrD9s/99NM2EPyaZSFJofrufVllgbTDQD3x8agFx+uWv937VPj4yQov LDZ61yro2+0ViZyt44dv6aTAIDLwVaw48rU/G/CIczeS5MKuaFTaaici99+Hb0r9 xLoEXdf5gQQQHJmIiOrHvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1702430016; x= 1702516416; bh=q1SPQYQRBWl7bFrY5/lVAS8dc6PpLJdw7+EOXaZGVW4=; b=2 Pu5VDvJxB+hNgOzbQS8onyFPjDTA5005w70yUaUEx6sY6LH9thUWrT74U/eM3n7i 8sPvzZT5BraMUnai4Oiurvmrz7CyvxK/uFWVESLJ0aNxBcLpSUF3XDmk7aP2wSFe LNZXNSS1TYD3y8iPrKxqQjisH5lHYJCXCy6x+x0N/zMRlDWw8x9C5TcFU4DM+/tH PndYo4EQezv+W1RekQUeHg0M/6/qxChKcZJEOev1fsqcH93x1yG6i8O6KdSKFZMA nLbYJEO7M/CxVv+30+imA2niTK7g/I3Aly/SsLJKWaZb/pE3rxn0XKizH3RhgSob DxC3cAqIgfb7dAt4xiphw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudelhedgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfvfevfhfhufgjtgfgsehtjeertddtfeejnecuhfhrohhmpefkrghn ucfmvghnthcuoehrrghvvghnsehthhgvmhgrfidrnhgvtheqnecuggftrfgrthhtvghrnh epjeegkedvhfekueejgeefieejtdevledvtdelieevveekffejfedtvdehkeefjeeknecu vehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprhgrvhgvnh esthhhvghmrgifrdhnvght X-ME-Proxy: Feedback-ID: i31e841b0:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 12 Dec 2023 20:13:32 -0500 (EST) Message-ID: Date: Wed, 13 Dec 2023 09:13:27 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 To: Arnd Bergmann , Alexander Viro , Christian Brauner Cc: Arnd Bergmann , Jan Kara , Miklos Szeredi , "Seth Forshee (DigitalOcean)" , Dave Chinner , Amir Goldstein , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20231212214819.247611-1-arnd@kernel.org> Content-Language: en-US From: Ian Kent Subject: Re: [PATCH] statmount: reduce runtime stack usage In-Reply-To: <20231212214819.247611-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 17:13:51 -0800 (PST) On 13/12/23 05:48, Arnd Bergmann wrote: > From: Arnd Bergmann > > prepare_kstatmount() constructs a copy of 'struct kstatmount' on the stack > and copies it into the local variable on the stack of its caller. Because > of the size of this structure, this ends up overflowing the limit for > a single function's stack frame when prepare_kstatmount() gets inlined > and both copies are on the same frame without the compiler being able > to collapse them into one: > > fs/namespace.c:4995:1: error: stack frame size (1536) exceeds limit (1024) in '__se_sys_statmount' [-Werror,-Wframe-larger-than] > 4995 | SYSCALL_DEFINE4(statmount, const struct mnt_id_req __user *, req, > > Mark the inner function as noinline_for_stack so the second copy is > freed before calling do_statmount() enters filesystem specific code. > The extra copy of the structure is a bit inefficient, but this > system call should not be performance critical. Are you sure this is not performance sensitive, or is the performance critical comment not related to the system call being called many times? It's going to be a while (if ever) before callers change there ways. Consider what happens when a bunch of mounts are being mounted. First there are a lot of events and making the getting of mount info. more efficient means more of those events get processed (itself an issue that's going to need notification sub-system improvement) resulting in the system call being called even more. There are 3 or 4 common programs that monitor the mounts, systemd is one of those, it usually has 3 processes concurrently listening for mount table events and every one of these processes grabs the entire table. Thing is systemd is actually quite good at handling events and can process a lot of them if they are being occuring. So this system call will be called a lot. Ian > > Fixes: 49889374ab92 ("statmount: simplify string option retrieval") > Signed-off-by: Arnd Bergmann > --- > fs/namespace.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/fs/namespace.c b/fs/namespace.c > index d036196f949c..e22fb5c4a9bb 100644 > --- a/fs/namespace.c > +++ b/fs/namespace.c > @@ -4950,7 +4950,8 @@ static inline bool retry_statmount(const long ret, size_t *seq_size) > return true; > } > > -static int prepare_kstatmount(struct kstatmount *ks, struct mnt_id_req *kreq, > +static int noinline_for_stack > +prepare_kstatmount(struct kstatmount *ks, struct mnt_id_req *kreq, > struct statmount __user *buf, size_t bufsize, > size_t seq_size) > {