提交 f0fe9984 编写于 作者: S Sangwoo Park 提交者: Linus Torvalds

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.comSigned-off-by: NSangwoo Park <sangwoo2.park@lge.com>
Reviewed-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: NMinchan Kim <minchan@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 302128dc
...@@ -195,15 +195,17 @@ static bool page_same_filled(void *ptr, unsigned long *element) ...@@ -195,15 +195,17 @@ static bool page_same_filled(void *ptr, unsigned long *element)
{ {
unsigned int pos; unsigned int pos;
unsigned long *page; unsigned long *page;
unsigned long val;
page = (unsigned long *)ptr; page = (unsigned long *)ptr;
val = page[0];
for (pos = 0; pos < PAGE_SIZE / sizeof(*page) - 1; pos++) { for (pos = 1; pos < PAGE_SIZE / sizeof(*page); pos++) {
if (page[pos] != page[pos + 1]) if (val != page[pos])
return false; return false;
} }
*element = page[pos]; *element = val;
return true; return true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册