Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1590840 > unrolled thread
| Started by | Sangwoo <sangwoo2.park@lge.com> |
|---|---|
| First post | 2017-03-02 05:20 +0100 |
| Last post | 2017-03-02 08:40 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] zram: reduce load operation in page_same_filled Sangwoo <sangwoo2.park@lge.com> - 2017-03-02 05:20 +0100
Re: [PATCH] zram: reduce load operation in page_same_filled Minchan Kim <minchan@kernel.org> - 2017-03-02 08:10 +0100
Re: [PATCH] zram: reduce load operation in page_same_filled Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-03-02 08:40 +0100
| From | Sangwoo <sangwoo2.park@lge.com> |
|---|---|
| Date | 2017-03-02 05:20 +0100 |
| Subject | [PATCH] zram: reduce load operation in page_same_filled |
| Message-ID | <tgqnD-5cO-7@gated-at.bofh.it> |
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@lge.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
[toc] | [next] | [standalone]
| From | Minchan Kim <minchan@kernel.org> |
|---|---|
| Date | 2017-03-02 08:10 +0100 |
| Message-ID | <tgt2a-7e2-21@gated-at.bofh.it> |
| In reply to | #1590840 |
Hi Sangwoo, On Thu, Mar 02, 2017 at 01:15:04PM +0900, Sangwoo wrote: > 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@lge.com> The rule is that you should use your full name Sangwoo Park for SOB. :) Anyway, Good spot! FYI, Ccing Andrew because he merges zram patches to mmotm tree. Acked-by: Minchan Kim <minchan@kernel.org> Thanks.
[toc] | [prev] | [next] | [standalone]
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Date | 2017-03-02 08:40 +0100 |
| Message-ID | <tgtvc-7o3-9@gated-at.bofh.it> |
| In reply to | #1590876 |
On (03/02/17 16:02), Minchan Kim wrote: > Acked-by: Minchan Kim <minchan@kernel.org> Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com> thanks. -ss
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web