linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] dm verity: use sector_div for division
@ 2015-12-08 15:42 Arnd Bergmann
  2015-12-08 17:10 ` Mike Snitzer
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2015-12-08 15:42 UTC (permalink / raw)
  To: Mike Snitzer, dm-devel
  Cc: Alasdair Kergon, linux-raid, Neil Brown, linux-kernel,
	linux-arm-kernel, Sami Tolvanen

The dm verity sec implementation uses do_div for dividing a sector_t,
which is slower than necessary when sector_t is a 32-bit type, and
we now get a warning for this case:

include/asm-generic/div64.h:224:22: warning: passing argument 1 of '__div64_32' from incompatible pointer type [-Wincompatible-pointer-types]
drivers/md/dm-verity-fec.c:725:6: note: in expansion of macro 'do_div'
  if (do_div(f->rounds, f->rsn))

This changes the code to use sector_div instead, which does the
right thing and avoids the warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/md/dm-verity-fec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I believe we had a fix for this in the series that introduced the optimized
do_div, but the file got moved around and the fix got lost.

diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c
index e722ce57520f..1bddaca37e98 100644
--- a/drivers/md/dm-verity-fec.c
+++ b/drivers/md/dm-verity-fec.c
@@ -722,7 +722,7 @@ int verity_fec_ctr(struct dm_verity *v)
 	}
 
 	f->rounds = f->blocks;
-	if (do_div(f->rounds, f->rsn))
+	if (sector_div(f->rounds, f->rsn))
 		f->rounds++;
 
 	/*
-- 
2.1.0.rc2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: dm verity: use sector_div for division
  2015-12-08 15:42 [PATCH] dm verity: use sector_div for division Arnd Bergmann
@ 2015-12-08 17:10 ` Mike Snitzer
  0 siblings, 0 replies; 2+ messages in thread
From: Mike Snitzer @ 2015-12-08 17:10 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: dm-devel, Neil Brown, linux-kernel, linux-raid, Alasdair Kergon,
	Sami Tolvanen, linux-arm-kernel

On Tue, Dec 08 2015 at 10:42am -0500,
Arnd Bergmann <arnd@arndb.de> wrote:

> The dm verity sec implementation uses do_div for dividing a sector_t,
> which is slower than necessary when sector_t is a 32-bit type, and
> we now get a warning for this case:
> 
> include/asm-generic/div64.h:224:22: warning: passing argument 1 of '__div64_32' from incompatible pointer type [-Wincompatible-pointer-types]
> drivers/md/dm-verity-fec.c:725:6: note: in expansion of macro 'do_div'
>   if (do_div(f->rounds, f->rsn))
> 
> This changes the code to use sector_div instead, which does the
> right thing and avoids the warning.

Thanks, I'll fold this in.

(Btw, I did review this use of do_div(): but only to answer whether there
was potential for a 64bit divide.  I concluded do_div() was fine but didn't
look to see the data type for f->rounds was actually sector_t.)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-08 17:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-12-08 15:42 [PATCH] dm verity: use sector_div for division Arnd Bergmann
2015-12-08 17:10 ` Mike Snitzer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).