Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2914986rdb; Mon, 4 Dec 2023 10:56:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdmMn89qKIlIsmfRox6txN4nUYoU8unJb8USyn7E1haiGQsrVPyG2q8gW7YcJFzOaVFSDu X-Received: by 2002:a17:90a:8597:b0:286:6f14:2870 with SMTP id m23-20020a17090a859700b002866f142870mr45494pjn.31.1701716162109; Mon, 04 Dec 2023 10:56:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701716162; cv=none; d=google.com; s=arc-20160816; b=0RhXi/7TpPhSkO8q68r13JDFU/QTA8bXWIjv19lg325Warc4gJoET71pslVPWFKpQZ yFdGF3T/la2odWQ9TFUHw6uJTVchAaMbH/jqJBddqhqiohEa9wLeRKm6qwpJo9AQy4z2 Uw3zbQIFsKZyaWZ/p9fkNY3aUEgKaoKPhY6Qqm3Tjp1k1WC/q+Xbh8w2MqfyePQ7+iMY CXOXetKc4ZMYGqyZl1vq89JVM68R065GhwMHh9o+H16maI29i3n9K5rszgpPDmsjsWdy KyY6OPhx61Ls6ITrbY2a/kSfR6AzGDH7M58bmq4WIdzZuht/5QsPa2GwU5RUk+ReQgRd HEbQ== 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:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=bA4kX9rxibdxURNPiiRaVXTSF7jjxSA+0KGcHMkxAZI=; fh=J5GA1HL7x0D4dN7YnbjDlNwYQT9fd4BHdINnuyUX2v0=; b=v6NiPKUxiY70aGokX/Kqn6hqX9EsHoZTO9yQ3qi+5cOuktbyo1J9XuLdwhostqivV9 /XJmbZS4Xl8ZE7OopMRum+tmBGx231e7cnjUmM3V6IixwvlsJ60nHSxIBIHof9NDf0aV 8aNMsfv3cBm5/4b475MfccmL/ItyOc9XUjNNOknPIFCTThVj+JUhOLPO7KtUTdlnI+Tj 6WIJlju/E7s5PkP2pH9MC/n7wWju92vf8e+O2H8VOt98c3OcwciY7thpzC1HPproCo+M ZEL7yksgGnFuSqtb8TGtURbjcmLukw8rp1Yq8HwJKtFmsTHMTjRuZRudf7X2nQnB2dgi EaBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=B5selm5V; 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=wanadoo.fr Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id lk9-20020a17090b33c900b0028526216f31si930214pjb.106.2023.12.04.10.56.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 10:56:02 -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=@wanadoo.fr header.s=t20230301 header.b=B5selm5V; 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=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id DE941803D5A8; Mon, 4 Dec 2023 10:55:23 -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 S231325AbjLDSy5 (ORCPT + 99 others); Mon, 4 Dec 2023 13:54:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234809AbjLDSyk (ORCPT ); Mon, 4 Dec 2023 13:54:40 -0500 Received: from smtp.smtpout.orange.fr (smtp-72.smtpout.orange.fr [80.12.242.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A18718E for ; Mon, 4 Dec 2023 10:54:27 -0800 (PST) Received: from [192.168.1.18] ([92.140.202.140]) by smtp.orange.fr with ESMTPA id AE5FrwDQ5Moj4AE5Frxl1d; Mon, 04 Dec 2023 19:54:25 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1701716065; bh=bA4kX9rxibdxURNPiiRaVXTSF7jjxSA+0KGcHMkxAZI=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=B5selm5VlHoKf3GqZnp0ROHcZkYFo/nfYqc6FE3VSbB8dLja2HdePtpnSyUawFxEq N8RlfWQj4TNrL1ob16+vh9b2jFuqOM90ro9Mce7Q5gzzgWZ31T68bzHmZ2iBsHLAFc b5e66ZS5QQML+aMN+ZuHfLd7zdkvYJzeivETaGHhpEe5JANuiqJYM1VmGdL8Aw7DOY qEJGfeeuQQwL6kfhnfwyqdwFTKCT28r0tH9vA7jTbkaw0Rq9su4lg35c3DyLLYnGe6 GBOyrCRHfZIbZEHje5zQ7/YbOx/BIvNd/juKvGJhIZgrCf3DSzYYvnkF/ZMOvHXkjH Uk9rae5k0Wmiw== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 04 Dec 2023 19:54:25 +0100 X-ME-IP: 92.140.202.140 Message-ID: <8f5f9a4b-f809-44cb-8f26-05e39b29dfb6@wanadoo.fr> Date: Mon, 4 Dec 2023 19:54:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [v2] net: hns3: reduce stack usage in hclge_dbg_dump_tm_pri() To: Arnd Bergmann , 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 References: <20231204085735.4112882-1-arnd@kernel.org> Content-Language: fr From: Christophe JAILLET In-Reply-To: <20231204085735.4112882-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,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]); Mon, 04 Dec 2023 10:55:24 -0800 (PST) Le 04/12/2023 à 09:57, Arnd Bergmann a écrit : > 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 > --- > v2: fix error handling leak > --- > .../hisilicon/hns3/hns3pf/hclge_debugfs.c | 21 ++++++++++++------- > 1 file changed, 14 insertions(+), 7 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..8f94e13c1edf 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]; > @@ -992,8 +992,13 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) > 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)); > @@ -1002,23 +1007,23 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) > for (i = 0; i < pri_num; i++) { > ret = hclge_tm_get_pri_sch_mode(hdev, i, &sch_mode); > if (ret) > - return ret; > + goto out; > > ret = hclge_tm_get_pri_weight(hdev, i, &weight); > if (ret) > - return ret; > + goto out; > > ret = hclge_tm_get_pri_shaper(hdev, i, > HCLGE_OPC_TM_PRI_C_SHAPPING, > &c_shaper_para); > if (ret) > - return ret; > + goto out; > > ret = hclge_tm_get_pri_shaper(hdev, i, > HCLGE_OPC_TM_PRI_P_SHAPPING, > &p_shaper_para); > if (ret) > - return ret; > + goto out; > > sch_mode_str = sch_mode & HCLGE_TM_TX_SCHD_DWRR_MSK ? "dwrr" : > "sp"; > @@ -1035,7 +1040,9 @@ static int hclge_dbg_dump_tm_pri(struct hclge_dev *hdev, char *buf, int len) > pos += scnprintf(buf + pos, len - pos, "%s", content); > } > > - return 0; > +out: > + kfree(data_str); > + return ret; > } > > static const struct hclge_dbg_item tm_qset_items[] = { Hi, could : pos += scnprintf(buf + pos, len - pos, "%s", ); be more widely used to avoid the alloc()/free() + copy of strings? CJ