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: 110175 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp5601626obb; Tue, 15 Aug 2017 08:13:49 -0700 (PDT) X-Received: by 10.99.97.10 with SMTP id v10mr19023666pgb.199.1502810029820; Tue, 15 Aug 2017 08:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1502810029; cv=none; d=google.com; s=arc-20160816; b=XcxLIe2eT1N+60DgxWuYykvxumhxrGEEfY6BPr52wSS7lgdCYJH8CnhAGIRn75hoJH 4OVvC/4gM4I1UYbYw/87yP+2Q+L8MH/amXtfxZ5Haylq4VydvNetpIWo9QXUvEq6x915 Jxly37JYMoBz/C9kexStlhNUxxApqWvOOOeQFUI8NUsxv6/OrNfksmqs6WSUlgKiZpzI qjvEXN5s+wO14etXF1DHOXmbsnh7kRqAfTqV53r1GEmPQwJR1jBFEIVJq3y+FMeWgNi8 eweUQsjnJF8/uxzX7dim8qpt6F37YJIkJz71NuqrsXtkmPPdw8dNQXRSDRYS+FLU87U/ RMlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=JYqq2/gsxbkeTpnu6v5EhMFSXCnFZ2gLpfIhWNhJ1Es=; b=HKztIOmX1RqmeGkyLYPbKpmSINOH6J2rhXRg4J2D1TMSnYKfwLV8UdYmdq7qInKOOS zTsdWX24HRCkzQJ69lyl+iyEl476F+WrWCLsd60Ip13KkLgLaLvBCEp9AhPp0ZgYBDJa 6/8seim1rE+cXKvLuW8Na9cjLG6ulBPzLRvnPmRRk+YbV8yIMrTytXHSYKMi2f9QUJB1 Dyc9JLXa4jkVUObhBa1wg/75k83362ilXzCKSoM5qsHq1Bw4diIxeOe1NouvDjk/K2iK bQkgpMHVXsrNtzb9StdR/RNIfeawSoPmnJD5fcU0KCSvK4jhOv8Q6jukkM+HMb2jgP4B YQ0g== 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 k7si6297966pln.934.2017.08.15.08.13.49; Tue, 15 Aug 2017 08:13:49 -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 S1752790AbdHOPNq (ORCPT + 25 others); Tue, 15 Aug 2017 11:13:46 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:56652 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbdHOPNo (ORCPT ); Tue, 15 Aug 2017 11:13:44 -0400 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 Cc: Ingo Molnar , Byungchul Park , Peter Zijlstra , Arnd Bergmann , Mikulas Patocka , Jens Axboe , linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] dm integrity: use init_completion instead of COMPLETION_INITIALIZER_ONSTACK Date: Tue, 15 Aug 2017 17:11:59 +0200 Message-Id: <20170815151242.2637861-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 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:/XuJJtyd1e0=:cvJIz8rrQY535MXu3Dmnvs e2sgWfno7ynKnijYNaxfvt+Psf5yntiD2gddnMmifs7cauMULMizUVBdNd5Y5PVBtGURIpY5J sFE6hrtswWpgXgplw7EopL3UQWLWlRazGWBo2gSbXn2+OCcVEagF+N81hA+CcXS/XXjTZk7KK a68xg1q92C16T5DX8JaiBuJ6T4Bt+2djjaGboJ/uZgXxGf6N4MFXOkdHtSDcFbb2cbXtHfSma UxWddVJSaJkeq1cfhQqFjA67bIg376Ju2DBEjs7iJg3TW1RmeNKLK9d7b8JZoYTFreQ53Jg4t QlVW8SN58takzg4NTIJyAxx5a/ZUZ5Dg7QjbGlkMLTfLRD0GyjU52tlZFmPIgzt7OqXskU9fq a5vqF4vE8INQ7whL4T4rlHZdb3Nco3MuFTphffjwoIVQTSytc5MT//wGfM7YW/ol5hXTlTuLT NJ1p7YtJGoSmuSAt5WSwxDRC6VDB9lCf0PrVvyGvRPiZmv+5F468oiPm9rdTsy1L0PsuXgS4V YtWFeHxiqQW+93W1b4MXrDpOnTN8WLimI4A0tjY7UEN6Ai2JgfnPHTH8Vi1G2OlSmM5rMubBs 1yXen6wph0EuQNI7hLarKfq6L+6fOtHcekotNjzU4T6i0stzwBql6xnN8s41SlkcPcRZHTYEV OgN3Lfm+RKrF30YKH7E4NY/SDINdHk8KiMhH3LxoeSa6DM+xZXVhjZPgYKkZ2/zxau+m3cFK8 FnTSh+x0nhjobKZDeuBcPCGXyNg6/pyrMDP+Jg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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(-) -- 2.9.0 Acked-by: Mikulas Patocka Acked-by: Mike Snitzer 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);