Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2540537rdb; Sun, 3 Dec 2023 23:29:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfGeAh9rasgWKiTLpryqsE5lULfZRQKete7ZosBT5PO9SIsFZSbLxnPYlxWJEAN48+1bFV X-Received: by 2002:a17:903:1c6:b0:1d0:9013:a139 with SMTP id e6-20020a17090301c600b001d09013a139mr548504plh.43.1701674990476; Sun, 03 Dec 2023 23:29:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701674990; cv=none; d=google.com; s=arc-20160816; b=MZHYKBHNkxRsSC2R8uDB3gzGn9xClbTc/LAQ+OnRtvoq5ePo61FjSMYKeM5Uku0vQj 3X+Yntnm/rq6S3Xx8dLIg7gl0ZiUPxqfmBTvGmEc+4GMeAyabTndIZuapK/XDyKbSKCN wvhZq4E+p9e00xeR4ATMUEBISaZLgoPK0fr7SR1KwsGz19ZRmJz08lyQncZCNbSHsGyw CT7x6Rax5DB1IKfEwWqhyKxTLktxxwNWeHZs6ZoKRxtj1ImVSYqYU5FyP20FGv7jR6dQ XEqe9PKKyRbJ83OG0YBMOH/AdKS3VFrlPP6L3dt6MRdQYUV8cNr/6Z8d/DoxLTRUiTpE Hcqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nuarUcJNbIteswyaxZD15TLh/RkUHpGwktGN6adJpQ0=; fh=RvB7DWBlOFSAAw/IhZLvJYsDCYK4Cqyj+geogNhbM1s=; b=dnTc7CD5rmBqkcPdUCH0FkqQD/qpDhkOuJkEmEftrsQ09gqFoCoyMYpNcj3x04tK8t TgGIi/hblXgcR2Pr6iesvQYN/3VGe2cg8DHSo7f7gYnAMGhNODiArOwY0jP9zAUvY96W 9SIkDbUNLMpnsT1LKxJX4K+fO8J/Yxd9Y2qX8McsPKCjcNhqk5+OscLQ8X3mLA4oCScI sqCZX//NC6RTWfWsE1zoWw16OuTo1YS/FHSdrmpOUyRWUy0ClwitcBeK/+CWTQzF16Xk TGxk3ZHFGjGnk5pJgs3tXeSSHX5zf5cmXNJnDkht2tcVE9xmgJhjxYXq/RauUtvDXZuF WWKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nog7iae6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id i12-20020a17090332cc00b001d08f5169dfsi1959013plr.140.2023.12.03.23.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 23:29:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nog7iae6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 34607805DEDE; Sun, 3 Dec 2023 23:29:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234593AbjLDH3e (ORCPT + 99 others); Mon, 4 Dec 2023 02:29:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229693AbjLDH3c (ORCPT ); Mon, 4 Dec 2023 02:29:32 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2428BD7 for ; Sun, 3 Dec 2023 23:29:39 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A4FBC433C7; Mon, 4 Dec 2023 07:29:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701674978; bh=lx62nJVG4/6em/8jt1aqDoujqgICoMUEYiBiTLEn73Y=; h=From:To:Cc:Subject:Date:From; b=nog7iae6jWPOzuuLLHIjTtIIR1wUlPeXTtYx6JU36WNc+KBRZQgguWN1dbv5+T5lg Fjzn1RrFvEy7EE7bzcRCdl9yA+A2Mwb0649qdILXy/q5ukZNEZvO2esnJk4EP/S2OB nSWitwqna1qDusCKomMCS0OMAJM4TJq56buV0RbnzZ3hnMDlni73NNqP7xUSGHTXq8 mxE5yVi8INWw6LEC1w4/1kTE/SmR0c+f+dTzj0hMPtKcusfc7oGngdziM8El5jV8jH uzLOtNVVO1umCVcp+pzj/ZIju5PdRuD2HERFscymZylWn22jeuPHpieIlDbwQUFOTf TyE5aygJE8Dww== From: Arnd Bergmann To: Yisen Zhuang , Salil Mehta , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Arnd Bergmann , Jijie Shao , Hao Chen , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net: hns3: reduce stack usage in hclge_dbg_dump_tm_pri() Date: Mon, 4 Dec 2023 08:29:26 +0100 Message-Id: <20231204072932.1077878-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, 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 pete.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 (pete.vger.email [0.0.0.0]); Sun, 03 Dec 2023 23:29:48 -0800 (PST) From: Arnd Bergmann This function exceeds the stack frame warning limit: drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c: In function 'hclge_dbg_dump_tm_pri': drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c:1039:1: error: the frame size of 1408 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] Use dynamic allocation for the largest stack object instead. It would be nice to rewrite this file to completely avoid the extra buffer and just use the one that was already allocated by debugfs, but that is a much larger change. Signed-off-by: Arnd Bergmann --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c index ff3f8f424ad9..9b5d46fdfd6c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_debugfs.c @@ -981,7 +981,7 @@ static const struct hclge_dbg_item tm_pri_items[] = { static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) { - char data_str[ARRAY_SIZE(tm_pri_items)][HCLGE_DBG_DATA_STR_LEN]; + char *data_str; struct hclge_tm_shaper_para c_shaper_para, p_shaper_para; char *result[ARRAY_SIZE(tm_pri_items)], *sch_mode_str; char content[HCLGE_DBG_TM_INFO_LEN]; @@ -991,9 +991,13 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) ret = hclge_tm_get_pri_num(hdev, &pri_num); if (ret) return ret; + data_str = kcalloc(ARRAY_SIZE(tm_pri_items), HCLGE_DBG_DATA_STR_LEN, + GFP_KERNEL); + if (!data_str) + return -ENOMEM; for (i = 0; i < ARRAY_SIZE(tm_pri_items); i++) - result[i] = &data_str[i][0]; + result[i] = &data_str[i * HCLGE_DBG_DATA_STR_LEN]; hclge_dbg_fill_content(content, sizeof(content), tm_pri_items, NULL, ARRAY_SIZE(tm_pri_items)); @@ -1035,6 +1039,7 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) pos += scnprintf(buf + pos, len - pos, "%s", content); } + kfree(data_str); return 0; } -- 2.39.2