From patchwork Tue Aug 15 15:11:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9902085 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 76D1160230 for ; Tue, 15 Aug 2017 15:32:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5ECD9287A1 for ; Tue, 15 Aug 2017 15:32:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 52DBB28881; Tue, 15 Aug 2017 15:32:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D3482287A1 for ; Tue, 15 Aug 2017 15:32:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFE605F7BE; Tue, 15 Aug 2017 15:32:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AFE605F7BE Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com AFE605F7BE Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6BE8318EC1; Tue, 15 Aug 2017 15:32:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 27D3B1864DBE; Tue, 15 Aug 2017 15:32:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v7FFRZ2x016237 for ; Tue, 15 Aug 2017 11:27:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 41BDB6E735; Tue, 15 Aug 2017 15:27:35 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3040717A7A; Tue, 15 Aug 2017 15:27:31 +0000 (UTC) Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.17.13]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 80E263E6; Tue, 15 Aug 2017 15:27:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 80E263E6 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=arndb.de Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=arnd@arndb.de DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 80E263E6 Received: from wuerfel.lan ([95.208.155.18]) by mrelayeu.kundenserver.de (mreue103 [212.227.15.145]) with ESMTPA (Nemesis) id 0MKt72-1dhdWh0KFE-0004yF; Tue, 15 Aug 2017 17:13:03 +0200 From: Arnd Bergmann To: Alasdair Kergon , Mike Snitzer , dm-devel@redhat.com, Shaohua Li Date: Tue, 15 Aug 2017 17:11:59 +0200 Message-Id: <20170815151242.2637861-2-arnd@arndb.de> In-Reply-To: <20170815151242.2637861-1-arnd@arndb.de> References: <20170815151242.2637861-1-arnd@arndb.de> X-Provags-ID: V03:K0:kpcjh0viFXnPg6c+DNM5GlAPnisGa1w0roZoTNOreiu+6bSKG65 3BeBuQhs9muxBJ1t/+0Kj5Jl5ZrrRzcOU0/4YyNHUncAqg4TAaabbSPhK+vnJK7iPl5P7WE WNGz07q0zSmzktzvBhj3z9ePwQpJzwlC9PT7htm1yCwN1VNIXo3gMiKoQia45QTDkHKOu8E +ZKqU6REAvGOe1tHKn7ww== X-UI-Out-Filterresults: notjunk:1; V01:K0:2FgNfBW+8ec=:M10e2vu5UhPUZW9av7mGdB diMkJqei1ChIlBkP+GA2Jesv9gfbMqlLJUxDsD/jL/p8830Ppf9ClQUuawwXA1CqV2K/hiHdh I3iI8hTcIExd2ePBjrxOeb126z4JI/Rp+dJ3qKkmdGRbweOU6GpBH1r6zRhrvu/Blt0UUO34I bxtXfWg8ciILerELxaVugxuOKMimFNX0ayuBGnJK29EZWC/wDZU6Zw3c1tryWC9EsMLTXAgnI 9DG0TgnczwEfWzkcYEm7+hHLMNIHQDMoRAZbvVpSnElAaZ1woAsZPLrWZVK6xX2ZH7vuidy5y fehdCpCBFAhLozUF4mtcKQalgiPeGdtEoxI3jWgWKs2oj4IBooLfk8OHG2lOrM8uZ139oKdNp A94cXXXTBOjf4e2BhbdZgd6c3b5DBfZtJ4MQE0cTpJ7TnFUg3nL3DELHK5nKPNxpDEzO9EqE7 sCKDbPg9HJboPW7BHTCREHpbAqV6uM2g0gXc2dB4NfpJWV1bwh5pv2lPSKlnSidPEUtZb3D/n 7VEWnNgmtyZ/HW7Mbkl4e+9q8kI6LYUsQcF1mQjKNS0hUK/54s8+RN9ai3EwHWtB0ciLe46DF ZIuaUY4QKME4/gZeDltRggI7jY7WGQmO2tCUUPDKFMENcx3+v2PTvsSzNE/CKt/Mr4OBsoyR4 LQ2Y5ockgrK2WTIKVQjNHu9pQOISxTeMTIXlN3Q6kfDzWaMhxPDLhPns+mc1xvVH0OqLyawrn ZBESqGDMPQn/agh3rabmukYKZsrQS2LhT7EFdQ== X-Greylist: Delayed for 00:14:15 by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 15 Aug 2017 15:27:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 15 Aug 2017 15:27:29 +0000 (UTC) for IP:'212.227.17.13' DOMAIN:'mout.kundenserver.de' HELO:'mout.kundenserver.de' FROM:'arnd@arndb.de' RCPT:'' X-RedHat-Spam-Score: -2.81 (RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2) 212.227.17.13 mout.kundenserver.de 212.227.17.13 mout.kundenserver.de X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: dm-devel@redhat.com Cc: Jens Axboe , linux-raid@vger.kernel.org, Arnd Bergmann , Peter Zijlstra , linux-kernel@vger.kernel.org, Byungchul Park , Mikulas Patocka , Ingo Molnar Subject: [dm-devel] [PATCH 2/2] dm integrity: use init_completion instead of COMPLETION_INITIALIZER_ONSTACK X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Tue, 15 Aug 2017 15:32:40 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP The new lockdep support for completions causeed the stack usage in dm-integrity to explode, in case of write_journal from 504 bytes to 1120 (using arm gcc-7.1.1): drivers/md/dm-integrity.c: In function 'write_journal': drivers/md/dm-integrity.c:827:1: error: the frame size of 1120 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] The problem is that not only the size of 'struct completion' grows significantly, but we end up having multiple copies of it on the stack when we assign it from a local variable after the initial declaration. COMPLETION_INITIALIZER_ONSTACK() is the right thing to use when we want to declare and initialize a completion on the stack. However, this driver doesn't do that and instead initializes the completion just before it is used. In this case, init_completion() does the same thing more efficiently, and drops the stack usage for the function above down to 496 bytes. While the other functions in this file are not bad enough to cause a warning, they benefit equally from the change, so I do the change across the entire file. In the one place where we reuse a completion, I picked the cheaper reinit_completion() over init_completion(). Fixes: cd8084f91c02 ("locking/lockdep: Apply crossrelease to completions") Signed-off-by: Arnd Bergmann Acked-by: Mikulas Patocka Acked-by: Mike Snitzer --- The patch causing this is currently part of linux-next, scheduled for 4.14, so it would be good to have this in the same release. --- drivers/md/dm-integrity.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index 293a19652d55..b16010bcbd17 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c @@ -773,13 +773,13 @@ static void write_journal(struct dm_integrity_c *ic, unsigned commit_start, unsi unsigned i; io_comp.ic = ic; - io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp); + init_completion(&io_comp.comp); if (commit_start + commit_sections <= ic->journal_sections) { io_comp.in_flight = (atomic_t)ATOMIC_INIT(1); if (ic->journal_io) { crypt_comp_1.ic = ic; - crypt_comp_1.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_1.comp); + init_completion(&crypt_comp_1.comp); crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0); encrypt_journal(ic, true, commit_start, commit_sections, &crypt_comp_1); wait_for_completion_io(&crypt_comp_1.comp); @@ -795,18 +795,18 @@ static void write_journal(struct dm_integrity_c *ic, unsigned commit_start, unsi to_end = ic->journal_sections - commit_start; if (ic->journal_io) { crypt_comp_1.ic = ic; - crypt_comp_1.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_1.comp); + init_completion(&crypt_comp_1.comp); crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0); encrypt_journal(ic, true, commit_start, to_end, &crypt_comp_1); if (try_wait_for_completion(&crypt_comp_1.comp)) { rw_journal(ic, REQ_OP_WRITE, REQ_FUA, commit_start, to_end, &io_comp); - crypt_comp_1.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_1.comp); + reinit_completion(&crypt_comp_1.comp); crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0); encrypt_journal(ic, true, 0, commit_sections - to_end, &crypt_comp_1); wait_for_completion_io(&crypt_comp_1.comp); } else { crypt_comp_2.ic = ic; - crypt_comp_2.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_2.comp); + init_completion(&crypt_comp_2.comp); crypt_comp_2.in_flight = (atomic_t)ATOMIC_INIT(0); encrypt_journal(ic, true, 0, commit_sections - to_end, &crypt_comp_2); wait_for_completion_io(&crypt_comp_1.comp); @@ -1679,7 +1679,7 @@ static void dm_integrity_map_continue(struct dm_integrity_io *dio, bool from_map dio->in_flight = (atomic_t)ATOMIC_INIT(2); if (need_sync_io) { - read_comp = COMPLETION_INITIALIZER_ONSTACK(read_comp); + init_completion(&read_comp); dio->completion = &read_comp; } else dio->completion = NULL; @@ -1836,7 +1836,7 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned write_start, comp.ic = ic; comp.in_flight = (atomic_t)ATOMIC_INIT(1); - comp.comp = COMPLETION_INITIALIZER_ONSTACK(comp.comp); + init_completion(&comp.comp); i = write_start; for (n = 0; n < write_sections; n++, i++, wraparound_section(ic, &i)) { @@ -2063,7 +2063,7 @@ static void replay_journal(struct dm_integrity_c *ic) if (ic->journal_io) { struct journal_completion crypt_comp; crypt_comp.ic = ic; - crypt_comp.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp.comp); + init_completion(&crypt_comp.comp); crypt_comp.in_flight = (atomic_t)ATOMIC_INIT(0); encrypt_journal(ic, false, 0, ic->journal_sections, &crypt_comp); wait_for_completion(&crypt_comp.comp); @@ -2636,7 +2636,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error) memset(iv, 0x00, ivsize); skcipher_request_set_crypt(req, sg, sg, PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, iv); - comp.comp = COMPLETION_INITIALIZER_ONSTACK(comp.comp); + init_completion(&comp.comp); comp.in_flight = (atomic_t)ATOMIC_INIT(1); if (do_crypt(true, req, &comp)) wait_for_completion(&comp.comp); @@ -2693,7 +2693,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error) sg_init_one(&sg, crypt_data, crypt_len); skcipher_request_set_crypt(req, &sg, &sg, crypt_len, iv); - comp.comp = COMPLETION_INITIALIZER_ONSTACK(comp.comp); + init_completion(&comp.comp); comp.in_flight = (atomic_t)ATOMIC_INIT(1); if (do_crypt(true, req, &comp)) wait_for_completion(&comp.comp);