Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3793982ybi; Mon, 29 Jul 2019 12:45:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwMSClvzBNJzLLFUj1JQsgCz92yj1KCLQAA7j7bq16qtE+RPPszAaBDB29e2/vNAtu5yfph X-Received: by 2002:a17:902:2aa9:: with SMTP id j38mr106502012plb.206.1564429514228; Mon, 29 Jul 2019 12:45:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429514; cv=none; d=google.com; s=arc-20160816; b=QfkxIA55Fhs+607rN1zlzQnNnM/oUgOrYg1x7IYc12bkkwxdrvniqgPVInRwciwy+t o8tV/E4t1gFDRJ3rKn//rbf+MVmq1vP+pPoSRf9EmT9glCREnNvsoSz/iseObkrRWdPY 4DQhjVWr+9BHgCQE3h+fgTNmOnGeZmGdHB+SyD72hetbaIefvpIphJ5gpwMNevMxgtCq ZP+AG6DcRMui+bPaKgVxDGuihOFnaO2Bf++ShNsJAqmNkY0ceS2CY8VmjcxUow8tzrst 34GNqT5o8cNaucIq7b0oJ18r1m3plvfWsY14VzpMPYlEo12tB14oiW53PABt50EKGThT wgKQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=g74nF5iAu30R2WEyEuE3b323GHZSlNjBlJ3aWqY2PG4=; b=bXGzKVeMzJE1wtQniiwlH1TRc+SzjEtmbWPdfd73wNkwxJ4EckSiLFuHFG9Kue5lsl uXJmoYkRw5SfyYVXGMriFGNxP42X08hiBbgRsM1xUvVdaKYgIob2KwmJYMhW8avHokca M6EwMGuwYawUsH93LzyExwTAXVVRf8gsLCMxRBtRQtHD62JWxmRdVzUM7TM3HulG0m0L MuTm6nQZwPsvahK7x+hAfVbBvfxv+ViaWOMTUOaZ3ruEVRIZx86fRv4BiJhBZI6UPh8s QBx3NnktZ2ykFgWwwKNMtwYb9DVTku1F+VZNL/tIraC/b4MTRhUH72GJ344NXl51FyGx ci9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I5osa37B; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j62si27650334pgd.170.2019.07.29.12.44.59; Mon, 29 Jul 2019 12:45:14 -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=I5osa37B; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389710AbfG2Tnu (ORCPT + 99 others); Mon, 29 Jul 2019 15:43:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:60282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389680AbfG2Tnp (ORCPT ); Mon, 29 Jul 2019 15:43:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71A9320C01; Mon, 29 Jul 2019 19:43:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429424; bh=/Wi2A+EetNzhILvEGcYGvMmll5Cs67u1h0XisClzJpw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I5osa37BGiWgl1OZARnqEX+LOBg7fWshK5Gm5TWPB86PS+jw3xLc726eWBCkySvfD Fy57KLrbbhuCt96Tv/rgL+0uvuOn/dO82860OEjWr49PLtE6zkqh9Zx36u86ReDUBU BarcCxhPeiPgPrcAaiECYDEPVKP2/pBTO8GKh1Zk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 093/113] cxgb4: reduce kernel stack usage in cudbg_collect_mem_region() Date: Mon, 29 Jul 2019 21:23:00 +0200 Message-Id: <20190729190717.776068837@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ 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 d97e0d7e541a..b766362031c3 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cudbg_lib.c @@ -1065,14 +1065,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; @@ -1086,7 +1084,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