Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6885682ybi; Mon, 8 Jul 2019 10:13:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqzDy7/DdEdB/InSvaqwyLvWBmWDo4IXGAUWWkJyAFeqe1p+Fc/pOSZzuMhkqqpsu2Bqe1Fl X-Received: by 2002:a65:4cc4:: with SMTP id n4mr25972679pgt.307.1562605985040; Mon, 08 Jul 2019 10:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562605985; cv=none; d=google.com; s=arc-20160816; b=stpHh0FYIkXjfQh8TCpdowwPYKLpnVNxjkB72KIdGxam7PTyqW4ILqNIAFj+qFEKg7 eUi33FGAd7bqR/FF4g6wXKquHsT3xOWX49yGQaKrApeN7AMIjhPRcahHe2JglMcy33Sm mfu3jsOdKAy5uRfm3pDsP11tb6FbaYWeeEePEo+d1bZYSVlqx5KrlEomg/PsnZ3obnX2 CoGb8ecWzzY62K1qAHVuqJ8znz9QmEsoZM5dF0RwpwDV+QHsuju3hdI8b3WVZV76ExGA SIj8WuybR+geA4+tOHPhf4ZnTkSq2n//zAHfaDcOkjVApKSajSM75fDwWpjWD5DBViO/ BF6w== 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 :message-id:date:subject:cc:to:from; bh=pT2dknTPKcJlkZKvheyQIvm71+kknR3BNnYmBJJYBf0=; b=K2kTGMVe/i5/1MRqVacipkzgKBNYgtymSU1bCUnG3BjJwF56VinWzUzWEfd9jv8zjN sloa5dg2RfKlKBXj0swWF3+cZk7klDvFxXD2Tms7zux4IAnGDzjQh5EFjU9JFRfHSX+O DomEqpaqBdQVWt6tpZ8+H4THikAsu1X5WSwe+TdvBSMZOFgYzk5X6lT6451d0zJGX6IB TA9EO59Arvu13FTv3WkRCsPgyX7ZZlZ2nErM4HCUXdGbuUSyn/3/SCT6ztE4AG7wNQCo eW0yftihFCewPL8K4TcnyktuvUP5EZKqINhSbTbdOTfLs4zjhM+FGOZFd8EyjtHSGytd xJgA== ARC-Authentication-Results: i=1; mx.google.com; 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 v2si165998pjy.48.2019.07.08.10.12.49; Mon, 08 Jul 2019 10:13:05 -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; 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 S1730849AbfGHMk7 (ORCPT + 99 others); Mon, 8 Jul 2019 08:40:59 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:35867 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727544AbfGHMk7 (ORCPT ); Mon, 8 Jul 2019 08:40:59 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1MODeL-1i8QoA0AXp-00OZfs; Mon, 08 Jul 2019 14:40:23 +0200 From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba Cc: Arnd Bergmann , Johannes Thumshirn , Nikolay Borisov , Andrea Gelmini , Qu Wenruo , Liu Bo , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs: reduce stack usage for btrfsic_process_written_block Date: Mon, 8 Jul 2019 14:40:09 +0200 Message-Id: <20190708124019.3374246-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: V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sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org btrfsic_process_written_block() cals btrfsic_process_metablock(), which has a fairly large stack usage due to the btrfsic_stack_frame variable. It also calls btrfsic_test_for_metadata(), which now needs several hundreds of bytes for its SHASH_DESC_ON_STACK(). In some configurations, we end up with both functions on the same stack, and gcc warns about the excessive stack usage that might cause the available stack space to run out: fs/btrfs/check-integrity.c:1743:13: error: stack frame size of 1152 bytes in function 'btrfsic_process_written_block' [-Werror,-Wframe-larger-than=] Marking both child functions as noinline_for_stack helps because this guarantees that the large variables are not on the same stack frame. Fixes: d5178578bcd4 ("btrfs: directly call into crypto framework for checksumming") Signed-off-by: Arnd Bergmann --- fs/btrfs/check-integrity.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 81a9731959a9..0b52ab4cb964 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c @@ -940,7 +940,7 @@ static void btrfsic_stack_frame_free(struct btrfsic_stack_frame *sf) kfree(sf); } -static int btrfsic_process_metablock( +static noinline_for_stack int btrfsic_process_metablock( struct btrfsic_state *state, struct btrfsic_block *const first_block, struct btrfsic_block_data_ctx *const first_block_ctx, @@ -1706,8 +1706,9 @@ static void btrfsic_dump_database(struct btrfsic_state *state) * Test whether the disk block contains a tree block (leaf or node) * (note that this test fails for the super block) */ -static int btrfsic_test_for_metadata(struct btrfsic_state *state, - char **datav, unsigned int num_pages) +static noinline_for_stack int btrfsic_test_for_metadata( + struct btrfsic_state *state, + char **datav, unsigned int num_pages) { struct btrfs_fs_info *fs_info = state->fs_info; SHASH_DESC_ON_STACK(shash, fs_info->csum_shash); -- 2.20.0