From nobody Thu Oct 9 02:52:17 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E16C27CCF5; Fri, 20 Jun 2025 11:33:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750419220; cv=none; b=eIPLIT/5a79mj+c8ZOJHu1I8UP4e87zk0xAre7kZVh/5ppOCc7xyFymlUghcM//VazxAe9BG+LA2IbBvU3bxMSjI/U6Mhek59QMgov5Pu7lm6SSA5SyjcSEd6xFZ0OTcO8sMfLyfZuPLx/xr0okdoerC03UEBa43NR7zZqXyhgQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750419220; c=relaxed/simple; bh=5vUxh8yETE3QhHBPPh1iEbiEEWY9o1VF0xJ6gLxw8qM=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=F7HrAHk8N+AClmle0+YNqrP1XBzGJVAWAxIc5XuZ+tovEQc1JxugeMOjSTj2kVrVhWHw3Yc+AYR3r573+fbXssbiKADMrBtCe/dzrxptP1w2WuKLdW+7FkLjZfxv6PvNJxtQkQv0lRJzxsI159wouHk2UO2dNMA2Xhbn97cIUkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dv0XNNCT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dv0XNNCT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 10238C4CEED; Fri, 20 Jun 2025 11:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750419219; bh=5vUxh8yETE3QhHBPPh1iEbiEEWY9o1VF0xJ6gLxw8qM=; h=From:To:Cc:Subject:Date:From; b=Dv0XNNCTNtyriD1ErcGQoHlDkuAvkdiPR0vI2vP5NQUnNbldfR/O3EaAAtWdcllK1 MoosQNkvjp/iMjnVJIJIMAgHiQA6BGLF10BxjnAhCw4HoiHwKnfe/k/DLd0wRGIdOI UxD0ZSX+IhcVmRE9U0XwcKveeZpxPqyAgG9t/WYLg+5opAu7fUQn3teQ/MoNnLh3lA l4fhPkOI+fJmzgNOQN+cUKiv5BSsNpnQadSiacIwvXSo7QduRjfFbau2WPW89eB3Zj fEIa+F8KpKx13wFYUKOfn0AXZB+mA+2YmjO+57mP9Vlet8kwqqSn2jORRsU5wwIqEm GEtcP/iI3RRow== From: Arnd Bergmann To: Jason Gunthorpe , Leon Romanovsky Cc: Arnd Bergmann , Chiara Meiohas , Mark Zhang , Michael Guralnik , linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] RDMA/core: reduce stack using in nldev_stat_get_doit() Date: Fri, 20 Jun 2025 13:33:26 +0200 Message-Id: <20250620113335.3776965-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Arnd Bergmann In the s390 defconfig, gcc-10 and earlier end up inlining three functions into nldev_stat_get_doit(), and each of them uses some 600 bytes of stack. The result is a function with an overly large stack frame and a warning: drivers/infiniband/core/nldev.c:2466:1: error: the frame size of 1720 bytes= is larger than 1280 bytes [-Werror=3Dframe-larger-than=3D] Mark the three functions noinline_for_stack to prevent this, ensuring that only one copy of the nlattr array is on the stack of each function. Signed-off-by: Arnd Bergmann --- drivers/infiniband/core/nldev.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/infiniband/core/nldev.c b/drivers/infiniband/core/nlde= v.c index a872643e8039..e9b7a6419291 100644 --- a/drivers/infiniband/core/nldev.c +++ b/drivers/infiniband/core/nldev.c @@ -1469,10 +1469,11 @@ static const struct nldev_fill_res_entry fill_entri= es[RDMA_RESTRACK_MAX] =3D { =20 }; =20 -static int res_get_common_doit(struct sk_buff *skb, struct nlmsghdr *nlh, - struct netlink_ext_ack *extack, - enum rdma_restrack_type res_type, - res_fill_func_t fill_func) +static noinline_for_stack int +res_get_common_doit(struct sk_buff *skb, struct nlmsghdr *nlh, + struct netlink_ext_ack *extack, + enum rdma_restrack_type res_type, + res_fill_func_t fill_func) { const struct nldev_fill_res_entry *fe =3D &fill_entries[res_type]; struct nlattr *tb[RDMA_NLDEV_ATTR_MAX]; @@ -2263,10 +2264,10 @@ static int nldev_stat_del_doit(struct sk_buff *skb,= struct nlmsghdr *nlh, return ret; } =20 -static int stat_get_doit_default_counter(struct sk_buff *skb, - struct nlmsghdr *nlh, - struct netlink_ext_ack *extack, - struct nlattr *tb[]) +static noinline_for_stack int +stat_get_doit_default_counter(struct sk_buff *skb, struct nlmsghdr *nlh, + struct netlink_ext_ack *extack, + struct nlattr *tb[]) { struct rdma_hw_stats *stats; struct nlattr *table_attr; @@ -2356,8 +2357,9 @@ static int stat_get_doit_default_counter(struct sk_bu= ff *skb, return ret; } =20 -static int stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh, - struct netlink_ext_ack *extack, struct nlattr *tb[]) +static noinline_for_stack int +stat_get_doit_qp(struct sk_buff *skb, struct nlmsghdr *nlh, + struct netlink_ext_ack *extack, struct nlattr *tb[]) =20 { static enum rdma_nl_counter_mode mode; --=20 2.39.5