Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3102079ybi; Thu, 18 Jul 2019 21:04:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDlinHjHB+dyQeZQUFY8GPPBJ9lrzAb4u2JSaNveUjoGXo+WzqoadSGWLGLya7i5JNzn71 X-Received: by 2002:a17:90a:a00d:: with SMTP id q13mr54312191pjp.80.1563509057792; Thu, 18 Jul 2019 21:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563509057; cv=none; d=google.com; s=arc-20160816; b=gCQ6Ssa9tfrSoyTC+F5wx7oBqhPTsSegkMVY+idYhtadJK+/9rzzGSfakXU7hIobGs HWIDR2FAmruf67ediiKIOG/br5Qs9fXygqe2W/wS7mPe80+oQ5IaBl2ktRaxGXVHkYtK zmoaG1L18yGVzoMfjNZYSRgjny9muvFhz0tiUq1u6Y/HrdQZB8JnFJzGtxpXEm/v67aL WDZQe5hHxkAhRYuFVrGhs7Ud+oWj9CjoooWMBz0Bwo5loNH/wsejxV1Um3lhrVZIfjiG lt3VG4nSVHTXH4jTfXumIHHf+rdgH2kdMi6J00yraV1teRFUZKpxb6xJTocC/DBqhUvB oRKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NaVbcQ6cAecSR+ScnatzbnHsXl0g9xbPs6IweDDZEsI=; b=XqFJJ68Fiu/WLMQ/n9+tfXmwVYV8Y7JUAquKHKy5AX9gG9ghutqxUlBOxg+4m/HqQo V1LIvK8eR9mMTpYow3WHiAgECOtXboVLVfr+NsLLcVN9hynVyFmHacEU/mcZkupw0WSW pDH0e2VVrc6j1oWoey167eM1P3riPJopIamC9tYSswRpnGSguU1I19kbDKBtRnrgYzhX l7IbDBMRrgdCNy4tycG9m8v1rn8Vo4TANuohPluzndMXv1MK2xts6FG62zEqEcWkVELi HcatJaWdJhHJh3FFLWgCHPvigmaDZZHWg9JwUDY+Gd3yOtLfS1klSh/KN/2S8Hedw4uV qh/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2d2FmylP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m184si197253pgm.580.2019.07.18.21.04.02; Thu, 18 Jul 2019 21:04:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2d2FmylP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730154AbfGSECu (ORCPT + 99 others); Fri, 19 Jul 2019 00:02:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:34300 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727344AbfGSECX (ORCPT ); Fri, 19 Jul 2019 00:02:23 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A33C221882; Fri, 19 Jul 2019 04:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508942; bh=6qZTZz30NAHwEqFoGbZfRcIgZb51RzVxHwbCIXJpDnY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2d2FmylPKnp4owLBl1jVu+EGNTidX3EhT0IHdLzmDphh1skJQjuJWOhkDJML5DxWs wJjHY+5OWyPgo7KuBhJWmgk0ApKCywNPnf9garHwlXukhHhtMbkHxVJHTXNAginBk7 VOEssIuFtrpk3yxqpnzFce/DL4zvM4L9EsV/vk8Q= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , "David S . Miller" , Sasha Levin , netdev@vger.kernel.org, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.2 167/171] cxgb4: reduce kernel stack usage in cudbg_collect_mem_region() Date: Thu, 18 Jul 2019 23:56:38 -0400 Message-Id: <20190719035643.14300-167-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann [ Upstream commit 752c2ea2d8e7c23b0f64e2e7d4337f3604d44c9f ] The cudbg_collect_mem_region() and cudbg_read_fw_mem() both use several hundred kilobytes of kernel stack space. One gets inlined into the other, which causes the stack usage to be combined beyond the warning limit when building with clang: drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c:1057:12: error: stack frame size of 1244 bytes in function 'cudbg_collect_mem_region' [-Werror,-Wframe-larger-than=] Restructuring cudbg_collect_mem_region() lets clang do the same optimization that gcc does and reuse the stack slots as it can see that the large variables are never used together. A better fix might be to avoid using cudbg_meminfo on the stack altogether, but that requires a larger rewrite. Fixes: a1c69520f785 ("cxgb4: collect MC memory dump") Signed-off-by: Arnd Bergmann Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../net/ethernet/chelsio/cxgb4/cudbg_lib.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c index a76529a7662d..c2e92786608b 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c @@ -1054,14 +1054,12 @@ static void cudbg_t4_fwcache(struct cudbg_init *pdbg_init, } } -static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init, - struct cudbg_buffer *dbg_buff, - struct cudbg_error *cudbg_err, - u8 mem_type) +static unsigned long cudbg_mem_region_size(struct cudbg_init *pdbg_init, + struct cudbg_error *cudbg_err, + u8 mem_type) { struct adapter *padap = pdbg_init->adap; struct cudbg_meminfo mem_info; - unsigned long size; u8 mc_idx; int rc; @@ -1075,7 +1073,16 @@ static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init, if (rc) return rc; - size = mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base; + return mem_info.avail[mc_idx].limit - mem_info.avail[mc_idx].base; +} + +static int cudbg_collect_mem_region(struct cudbg_init *pdbg_init, + struct cudbg_buffer *dbg_buff, + struct cudbg_error *cudbg_err, + u8 mem_type) +{ + unsigned long size = cudbg_mem_region_size(pdbg_init, cudbg_err, mem_type); + return cudbg_read_fw_mem(pdbg_init, dbg_buff, mem_type, size, cudbg_err); } -- 2.20.1