OSDN Git Service

dm integrity: use init_completion instead of COMPLETION_INITIALIZER_ONSTACK
authorArnd Bergmann <arnd@arndb.de>
Tue, 15 Aug 2017 15:11:59 +0000 (17:11 +0200)
committerMike Snitzer <snitzer@redhat.com>
Mon, 11 Sep 2017 15:00:54 +0000 (11:00 -0400)
commitb5e8ad92c3ac0b073bbf08ffd1a6a31d3449caae
tree2fa027fae03931a1eadfe5a0efb1c23c9d13620f
parent7c373d660420f74c3e16d148629b810f3a36ac9e
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>
drivers/md/dm-integrity.c