lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Thu, 2 Mar 2017 13:15:04 +0900
From:   Sangwoo <sangwoo2.park@....com>
To:     <minchan@...nel.org>, <ngupta@...are.org>
CC:     <sergey.senozhatsky.work@...il.com>,
        <linux-kernel@...r.kernel.org>, Sangwoo <sangwoo2.park@....com>
Subject: [PATCH] zram: reduce load operation in page_same_filled

In page_same_filled function, all elements in the page is compared
with next index value. The current comparison routine compares
the (i)th and (i+1)th values of the page.
In this case, two load operaions occur for each comparison.
But if we store first value of the page stores at 'val' variable
and using it to compare with others, the load opearation is reduced.
It reduce load operation per page by up to 64times.

Signed-off-by: Sangwoo <sangwoo2.park@....com>
---
 drivers/block/zram/zram_drv.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e27d89a..87581d1 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -177,15 +177,17 @@ static bool page_same_filled(void *ptr, unsigned long *element)
 {
 	unsigned int pos;
 	unsigned long *page;
+	unsigned long val;
 
 	page = (unsigned long *)ptr;
+	val = page[0];
 
-	for (pos = 0; pos < PAGE_SIZE / sizeof(*page) - 1; pos++) {
-		if (page[pos] != page[pos + 1])
+	for (pos = 1; pos < PAGE_SIZE / sizeof(*page); pos++) {
+		if (val != page[pos])
 			return false;
 	}
 
-	*element = page[pos];
+	*element = val;
 
 	return true;
 }
-- 
2.6.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ