aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-08-15 11:11:59 -0400
committerMike Snitzer <snitzer@redhat.com>2017-09-11 11:00:54 -0400
commitb5e8ad92c3ac0b073bbf08ffd1a6a31d3449caae (patch)
tree2fa027fae03931a1eadfe5a0efb1c23c9d13620f
parent7c373d660420f74c3e16d148629b810f3a36ac9e (diff)
dm integrity: use init_completion instead of COMPLETION_INITIALIZER_ONSTACK
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 <arnd@arndb.de> Acked-by: Mikulas Patocka <mpatocka@redhat.com> Acked-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com>
-rw-r--r--drivers/md/dm-integrity.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 2b32342da556..ac0d7759594b 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
773 unsigned i; 773 unsigned i;
774 774
775 io_comp.ic = ic; 775 io_comp.ic = ic;
776 io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp); 776 init_completion(&io_comp.comp);
777 777
778 if (commit_start + commit_sections <= ic->journal_sections) { 778 if (commit_start + commit_sections <= ic->journal_sections) {
779 io_comp.in_flight = (atomic_t)ATOMIC_INIT(1); 779 io_comp.in_flight = (atomic_t)ATOMIC_INIT(1);
780 if (ic->journal_io) { 780 if (ic->journal_io) {
781 crypt_comp_1.ic = ic; 781 crypt_comp_1.ic = ic;
782 crypt_comp_1.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_1.comp); 782 init_completion(&crypt_comp_1.comp);
783 crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0); 783 crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0);
784 encrypt_journal(ic, true, commit_start, commit_sections, &crypt_comp_1); 784 encrypt_journal(ic, true, commit_start, commit_sections, &crypt_comp_1);
785 wait_for_completion_io(&crypt_comp_1.comp); 785 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
795 to_end = ic->journal_sections - commit_start; 795 to_end = ic->journal_sections - commit_start;
796 if (ic->journal_io) { 796 if (ic->journal_io) {
797 crypt_comp_1.ic = ic; 797 crypt_comp_1.ic = ic;
798 crypt_comp_1.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_1.comp); 798 init_completion(&crypt_comp_1.comp);
799 crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0); 799 crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0);
800 encrypt_journal(ic, true, commit_start, to_end, &crypt_comp_1); 800 encrypt_journal(ic, true, commit_start, to_end, &crypt_comp_1);
801 if (try_wait_for_completion(&crypt_comp_1.comp)) { 801 if (try_wait_for_completion(&crypt_comp_1.comp)) {
802 rw_journal(ic, REQ_OP_WRITE, REQ_FUA, commit_start, to_end, &io_comp); 802 rw_journal(ic, REQ_OP_WRITE, REQ_FUA, commit_start, to_end, &io_comp);
803 crypt_comp_1.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_1.comp); 803 reinit_completion(&crypt_comp_1.comp);
804 crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0); 804 crypt_comp_1.in_flight = (atomic_t)ATOMIC_INIT(0);
805 encrypt_journal(ic, true, 0, commit_sections - to_end, &crypt_comp_1); 805 encrypt_journal(ic, true, 0, commit_sections - to_end, &crypt_comp_1);
806 wait_for_completion_io(&crypt_comp_1.comp); 806 wait_for_completion_io(&crypt_comp_1.comp);
807 } else { 807 } else {
808 crypt_comp_2.ic = ic; 808 crypt_comp_2.ic = ic;
809 crypt_comp_2.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp_2.comp); 809 init_completion(&crypt_comp_2.comp);
810 crypt_comp_2.in_flight = (atomic_t)ATOMIC_INIT(0); 810 crypt_comp_2.in_flight = (atomic_t)ATOMIC_INIT(0);
811 encrypt_journal(ic, true, 0, commit_sections - to_end, &crypt_comp_2); 811 encrypt_journal(ic, true, 0, commit_sections - to_end, &crypt_comp_2);
812 wait_for_completion_io(&crypt_comp_1.comp); 812 wait_for_completion_io(&crypt_comp_1.comp);
@@ -1679,7 +1679,7 @@ sleep:
1679 dio->in_flight = (atomic_t)ATOMIC_INIT(2); 1679 dio->in_flight = (atomic_t)ATOMIC_INIT(2);
1680 1680
1681 if (need_sync_io) { 1681 if (need_sync_io) {
1682 read_comp = COMPLETION_INITIALIZER_ONSTACK(read_comp); 1682 init_completion(&read_comp);
1683 dio->completion = &read_comp; 1683 dio->completion = &read_comp;
1684 } else 1684 } else
1685 dio->completion = NULL; 1685 dio->completion = NULL;
@@ -1840,7 +1840,7 @@ static void do_journal_write(struct dm_integrity_c *ic, unsigned write_start,
1840 1840
1841 comp.ic = ic; 1841 comp.ic = ic;
1842 comp.in_flight = (atomic_t)ATOMIC_INIT(1); 1842 comp.in_flight = (atomic_t)ATOMIC_INIT(1);
1843 comp.comp = COMPLETION_INITIALIZER_ONSTACK(comp.comp); 1843 init_completion(&comp.comp);
1844 1844
1845 i = write_start; 1845 i = write_start;
1846 for (n = 0; n < write_sections; n++, i++, wraparound_section(ic, &i)) { 1846 for (n = 0; n < write_sections; n++, i++, wraparound_section(ic, &i)) {
@@ -2067,7 +2067,7 @@ static void replay_journal(struct dm_integrity_c *ic)
2067 if (ic->journal_io) { 2067 if (ic->journal_io) {
2068 struct journal_completion crypt_comp; 2068 struct journal_completion crypt_comp;
2069 crypt_comp.ic = ic; 2069 crypt_comp.ic = ic;
2070 crypt_comp.comp = COMPLETION_INITIALIZER_ONSTACK(crypt_comp.comp); 2070 init_completion(&crypt_comp.comp);
2071 crypt_comp.in_flight = (atomic_t)ATOMIC_INIT(0); 2071 crypt_comp.in_flight = (atomic_t)ATOMIC_INIT(0);
2072 encrypt_journal(ic, false, 0, ic->journal_sections, &crypt_comp); 2072 encrypt_journal(ic, false, 0, ic->journal_sections, &crypt_comp);
2073 wait_for_completion(&crypt_comp.comp); 2073 wait_for_completion(&crypt_comp.comp);
@@ -2640,7 +2640,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
2640 memset(iv, 0x00, ivsize); 2640 memset(iv, 0x00, ivsize);
2641 2641
2642 skcipher_request_set_crypt(req, sg, sg, PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, iv); 2642 skcipher_request_set_crypt(req, sg, sg, PAGE_SIZE * ic->journal_pages + sizeof ic->commit_ids, iv);
2643 comp.comp = COMPLETION_INITIALIZER_ONSTACK(comp.comp); 2643 init_completion(&comp.comp);
2644 comp.in_flight = (atomic_t)ATOMIC_INIT(1); 2644 comp.in_flight = (atomic_t)ATOMIC_INIT(1);
2645 if (do_crypt(true, req, &comp)) 2645 if (do_crypt(true, req, &comp))
2646 wait_for_completion(&comp.comp); 2646 wait_for_completion(&comp.comp);
@@ -2697,7 +2697,7 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
2697 2697
2698 sg_init_one(&sg, crypt_data, crypt_len); 2698 sg_init_one(&sg, crypt_data, crypt_len);
2699 skcipher_request_set_crypt(req, &sg, &sg, crypt_len, iv); 2699 skcipher_request_set_crypt(req, &sg, &sg, crypt_len, iv);
2700 comp.comp = COMPLETION_INITIALIZER_ONSTACK(comp.comp); 2700 init_completion(&comp.comp);
2701 comp.in_flight = (atomic_t)ATOMIC_INIT(1); 2701 comp.in_flight = (atomic_t)ATOMIC_INIT(1);
2702 if (do_crypt(true, req, &comp)) 2702 if (do_crypt(true, req, &comp))
2703 wait_for_completion(&comp.comp); 2703 wait_for_completion(&comp.comp);