aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSangwoo Park <sangwoo2.park@lge.com>2017-05-03 17:55:56 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-05-03 18:52:11 -0400
commitf0fe9984656604ea8effd5ff82709ff8ce1f954b (patch)
tree8b2998a6041eb33b592ed10abd551a7a29fc43b6
parent302128dce142d780417aa548bfd7ef4dfb89fa80 (diff)
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. Link: http://lkml.kernel.org/r/1488428104-7257-1-git-send-email-sangwoo2.park@lge.com Signed-off-by: Sangwoo Park <sangwoo2.park@lge.com> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> Acked-by: Minchan Kim <minchan@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/block/zram/zram_drv.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index d303334e3da3..debee952dcc1 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -195,15 +195,17 @@ static bool page_same_filled(void *ptr, unsigned long *element)
195{ 195{
196 unsigned int pos; 196 unsigned int pos;
197 unsigned long *page; 197 unsigned long *page;
198 unsigned long val;
198 199
199 page = (unsigned long *)ptr; 200 page = (unsigned long *)ptr;
201 val = page[0];
200 202
201 for (pos = 0; pos < PAGE_SIZE / sizeof(*page) - 1; pos++) { 203 for (pos = 1; pos < PAGE_SIZE / sizeof(*page); pos++) {
202 if (page[pos] != page[pos + 1]) 204 if (val != page[pos])
203 return false; 205 return false;
204 } 206 }
205 207
206 *element = page[pos]; 208 *element = val;
207 209
208 return true; 210 return true;
209} 211}