[PATCH] dm: optimize modulo max_io_len

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi

This patch should be applied after 
dm-support-non-power-of-two-target-max_io_len.patch. It optimizes a case 
when max_io_len is a power of two.

Mikulas

---

dm: optimize modulo max_io_len

Change slow modulo operation to fast bitwise and when max_io_len is a
power of two.

Signed-off-by: Mikulas Patocka <mpatocka@xxxxxxxxxx>

---
 drivers/md/dm.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Index: linux-3.4.2-fast/drivers/md/dm.c
===================================================================
--- linux-3.4.2-fast.orig/drivers/md/dm.c	2012-06-18 11:40:17.000000000 +0200
+++ linux-3.4.2-fast/drivers/md/dm.c	2012-06-18 11:41:05.000000000 +0200
@@ -1004,7 +1004,11 @@ static sector_t max_io_len(sector_t sect
 	 */
 	if (ti->max_io_len) {
 		offset = dm_target_offset(ti, sector);
-		max_len = ti->max_io_len - sector_div(offset, ti->max_io_len);
+		if (unlikely(ti->max_io_len & (ti->max_io_len - 1)))
+			max_len = sector_div(offset, ti->max_io_len);
+		else
+			max_len = offset & (ti->max_io_len - 1);
+		max_len = ti->max_io_len - max_len;
 
 		if (len > max_len)
 			len = max_len;

--
dm-devel mailing list
dm-devel@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/dm-devel


[Index of Archives]     [DM Crypt]     [Fedora Desktop]     [ATA RAID]     [Fedora Marketing]     [Fedora Packaging]     [Fedora SELinux]     [Yosemite Discussion]     [KDE Users]     [Fedora Docs]

  Powered by Linux