Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2563065rdb; Mon, 4 Dec 2023 00:32:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGf88rmi4DrI32h7zty7tWELwklj3RJr7JnkLEyM1ImemWoR3e3bjc2d8SJcSEHYtxUGJ5 X-Received: by 2002:a05:6358:280e:b0:170:17eb:9c45 with SMTP id k14-20020a056358280e00b0017017eb9c45mr5219377rwb.38.1701678733563; Mon, 04 Dec 2023 00:32:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701678733; cv=none; d=google.com; s=arc-20160816; b=EhVREu1hJmdrU0kWLe0mAfuWpDB8GsxXpgdtOsL/L6SC77PugpOqnT0yM36xrEI4yP lxAE8hEjCsnWiu3eAmkHS40t4A4jZJ2fcVVUrkM/G1gPabyYQ5ZsndMuUMQJcahzH8QK vZWhv6pCQUyn6eaGx3n6oa48ACnh+i9O3YTxvyzxLtcKounWRx196qsRcjOFGToslSpc 9bpLaNVqogZBbMknuIbbODvkzuad6yAM6FPSytRf3eHmDaRuG7aoj55NAmoup1ikFZm8 2tTjdwDrrDaP1kn3fuCgmdeT4wGLDl1zGViWQrioRbT+eTvZWT4UfNcmAXWaG2JllOxZ 2OCg== 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 :references:to:subject:cc:user-agent:mime-version:date:message-id; bh=Is3ac8guj7qEm0u+2mzIaXo6nIQpW3IfLEDUNHDzGCE=; fh=iYi3YJtN3aCOHsi1UQZQg9Z3pSqNALve9c0GrbOpYp8=; b=sN811jTpibENczyrewz66neoh/SMorewwII2QhLqwL41mjNUvfh1TH7Bd7D0zIwG6R wi/N2+so1MuErqRDLUb8pL+y4pQoIUlY78UUF65YoIjuUtV1PAQ45DDlC9R5HgMfc2Vu 3N+5f5ezjC4XnVLv3/S5X2duw+++ggLdn/epGr1wN/OwZBw8SJMDqKbi+H1Y+KTG5UuF v4z+vJUdScJHqfh4AMvlQi86R8rpfFsDdJ39FF6EsXjOOwBWJDHS+6Xnqf12ow4MlmLq oCxfTsh0Cd3xZxPQDS3VKVFkmRUaSdm1rKxs8P5ROkQ/A0sP1jsMLuw3wgguQmFPIkP7 wbOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id cd23-20020a056a02079700b005c677919049si2365031pgb.757.2023.12.04.00.32.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 00:32:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 19C6D808EF75; Mon, 4 Dec 2023 00:32:11 -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 S231478AbjLDIb6 (ORCPT + 99 others); Mon, 4 Dec 2023 03:31:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbjLDIb5 (ORCPT ); Mon, 4 Dec 2023 03:31:57 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BE7BD5; Mon, 4 Dec 2023 00:32:03 -0800 (PST) Received: from kwepemm000007.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4SkGxl6yRdzShgS; Mon, 4 Dec 2023 16:27:39 +0800 (CST) Received: from [10.67.120.192] (10.67.120.192) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 4 Dec 2023 16:32:00 +0800 Message-ID: <5402aa8a-a20f-4d28-bd36-3b88702ea6ae@huawei.com> Date: Mon, 4 Dec 2023 16:31:59 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird CC: , Arnd Bergmann , Hao Chen , , Subject: Re: [PATCH] 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 References: <20231204072932.1077878-1-arnd@kernel.org> From: Jijie Shao In-Reply-To: <20231204072932.1077878-1-arnd@kernel.org> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.120.192] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm000007.china.huawei.com (7.193.23.189) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-0.8 required=5.0 tests=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 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]); Mon, 04 Dec 2023 00:32:11 -0800 (PST) on 2023/12/4 15:29, Arnd Bergmann wrote: > From: Arnd Bergmann > > > @@ -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; Thanks, But it would be better if there is an empty line here. > + 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); > } > all exception condition also need to free memory before return. eg: for (i = 0; i < pri_num; i++) { ret = hclge_tm_get_pri_sch_mode(hdev, i, &sch_mode); if (ret) return ret; ret = hclge_tm_get_pri_weight(hdev, i, &weight); if (ret) return ret; > + kfree(data_str); > return 0; > } >