linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: linux-kernel@vger.kernel.org
Cc: minchan@kernel.org, Matthew Wilcox <mawilcox@microsoft.com>,
	akpm@linuxfoundation.org, mpe@ellerman.id.au
Subject: [PATCH v4 6/8] zram: Convert to using memset_l
Date: Thu, 20 Jul 2017 11:45:37 -0700	[thread overview]
Message-ID: <20170720184539.31609-7-willy@infradead.org> (raw)
In-Reply-To: <20170720184539.31609-1-willy@infradead.org>

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 | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 856d5dc02451..2df50d82dc29 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -175,20 +175,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)
-- 
2.13.2

  parent reply	other threads:[~2017-07-20 18:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-20 18:45 [PATCH v4 0/8] Multibyte memset variations Matthew Wilcox
2017-07-20 18:45 ` [PATCH v4 1/8] Add multibyte memset functions Matthew Wilcox
2017-07-20 18:45 ` [PATCH v4 2/8] Add testcases for memset16/32/64 Matthew Wilcox
2017-07-20 18:45 ` [PATCH v4 3/8] x86: Implement memset16, memset32 & memset64 Matthew Wilcox
2017-07-20 18:45 ` [PATCH v4 4/8] ARM: Implement " Matthew Wilcox
2017-07-20 18:45 ` [PATCH v4 5/8] alpha: Add support for memset16 Matthew Wilcox
2017-07-20 18:45 ` Matthew Wilcox [this message]
2017-07-20 18:45 ` [PATCH v4 7/8] sym53c8xx_2: Convert to use memset32 Matthew Wilcox
2017-07-20 18:45 ` [PATCH v4 8/8] vga: Optimise console scrolling Matthew Wilcox
2017-07-25  5:27 ` [PATCH v4 0/8] Multibyte memset variations Michael Ellerman
2017-07-25 13:08   ` Matthew Wilcox

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170720184539.31609-7-willy@infradead.org \
    --to=willy@infradead.org \
    --cc=akpm@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mawilcox@microsoft.com \
    --cc=minchan@kernel.org \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).