Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1608624

[PATCH v3 5/7] zram: Convert to using memset_l

From Matthew Wilcox <willy@infradead.org>
Newsgroups linux.kernel
Subject [PATCH v3 5/7] zram: Convert to using memset_l
Date 2017-03-24 17:20 +0100
Message-ID <toA6u-48t-27@gated-at.bofh.it> (permalink)
References <toA6t-48t-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Matthew Wilcox <mawilcox@microsoft.com>

zram was the motivation for creating memset_l().  Minchan Kim sees a 7%
performance improvement on x86 with 100MB of non-zero deduplicatable
data:

        perf stat -r 10 dd if=/dev/zram0 of=/dev/null

vanilla:        0.232050465 seconds time elapsed ( +-  0.51% )
memset_l:	0.217219387 seconds time elapsed ( +-  0.07% )

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>
Tested-by: Minchan Kim <minchan@kernel.org>
---
 drivers/block/zram/zram_drv.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index e27d89a36c34..25dcad309695 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -157,20 +157,11 @@ static inline void update_used_max(struct zram *zram,
 	} while (old_max != cur_max);
 }
 
-static inline void zram_fill_page(char *ptr, unsigned long len,
+static inline void zram_fill_page(void *ptr, unsigned long len,
 					unsigned long value)
 {
-	int i;
-	unsigned long *page = (unsigned long *)ptr;
-
 	WARN_ON_ONCE(!IS_ALIGNED(len, sizeof(unsigned long)));
-
-	if (likely(value == 0)) {
-		memset(ptr, 0, len);
-	} else {
-		for (i = 0; i < len / sizeof(*page); i++)
-			page[i] = value;
-	}
+	memset_l(ptr, value, len / sizeof(unsigned long));
 }
 
 static bool page_same_filled(void *ptr, unsigned long *element)
@@ -193,7 +184,7 @@ static bool page_same_filled(void *ptr, unsigned long *element)
 static void handle_same_page(struct bio_vec *bvec, unsigned long element)
 {
 	struct page *page = bvec->bv_page;
-	void *user_mem;
+	char *user_mem;
 
 	user_mem = kmap_atomic(page);
 	zram_fill_page(user_mem + bvec->bv_offset, bvec->bv_len, element);
-- 
2.11.0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v3 0/7] Add memsetN functions Matthew Wilcox <willy@infradead.org> - 2017-03-24 17:20 +0100
  [PATCH v3 1/7] Add multibyte memset functions Matthew Wilcox <willy@infradead.org> - 2017-03-24 17:20 +0100
  [PATCH v3 5/7] zram: Convert to using memset_l Matthew Wilcox <willy@infradead.org> - 2017-03-24 17:20 +0100
    Re: [PATCH v3 5/7] zram: Convert to using memset_l Minchan Kim <minchan@kernel.org> - 2017-03-27 07:10 +0200
  [PATCH v3 4/7] alpha: Add support for memset16 Matthew Wilcox <willy@infradead.org> - 2017-03-24 17:20 +0100
  [PATCH v3 2/7] ARM: Implement memset16, memset32 & memset64 Matthew Wilcox <willy@infradead.org> - 2017-03-24 17:20 +0100

csiph-web