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


Groups > linux.kernel > #1693173 > unrolled thread

[PATCH v4 0/8] Multibyte memset variations

Started byMatthew Wilcox <willy@infradead.org>
First post2017-07-20 20:50 +0200
Last post2017-07-25 15:10 +0200
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v4 0/8] Multibyte memset variations Matthew Wilcox <willy@infradead.org> - 2017-07-20 20:50 +0200
    [PATCH v4 6/8] zram: Convert to using memset_l Matthew Wilcox <willy@infradead.org> - 2017-07-20 20:50 +0200
    Re: [PATCH v4 0/8] Multibyte memset variations Michael Ellerman <mpe@ellerman.id.au> - 2017-07-25 07:30 +0200
      Re: [PATCH v4 0/8] Multibyte memset variations Matthew Wilcox <willy@infradead.org> - 2017-07-25 15:10 +0200

#1693173 — [PATCH v4 0/8] Multibyte memset variations

FromMatthew Wilcox <willy@infradead.org>
Date2017-07-20 20:50 +0200
Subject[PATCH v4 0/8] Multibyte memset variations
Message-ID<u5oGl-2GI-3@gated-at.bofh.it>
From: Matthew Wilcox <mawilcox@microsoft.com>

A relatively common idiom we're missing is a function to fill an area
of memory with a pattern which is larger than a single byte.  I first
noticed this with a zram patch which wanted to fill a page with an
'unsigned long' value.  There turn out to be quite a few places in
the kernel which can benefit from using an optimised function rather
than a loop; sometimes text size, sometimes speed, and sometimes both.
The optimised PowerPC version (not included here) improves performance
by about 30% on POWER8 on just the raw memset_l().

Most of the extra lines of code come from the three testcases I added.

Matthew Wilcox (8):
  Add multibyte memset functions
  Add testcases for memset16/32/64
  x86: Implement memset16, memset32 & memset64
  ARM: Implement memset32 & memset64
  alpha: Add support for memset16
  zram: Convert to using memset_l
  sym53c8xx_2: Convert to use memset32
  vga: Optimise console scrolling

 arch/alpha/include/asm/string.h     |  15 +--
 arch/alpha/include/asm/vga.h        |   2 +-
 arch/alpha/lib/memset.S             |  10 +-
 arch/arm/include/asm/string.h       |  14 +++
 arch/arm/kernel/armksyms.c          |   2 +
 arch/arm/lib/memset.S               |  24 +++--
 arch/mips/include/asm/vga.h         |   7 ++
 arch/powerpc/include/asm/vga.h      |   8 ++
 arch/sparc/include/asm/vga.h        |  25 +++++
 arch/x86/include/asm/string_32.h    |  24 +++++
 arch/x86/include/asm/string_64.h    |  36 +++++++
 drivers/block/zram/zram_drv.c       |  13 +--
 drivers/scsi/sym53c8xx_2/sym_hipd.c |  11 +-
 include/linux/string.h              |  30 ++++++
 include/linux/vt_buffer.h           |  12 +++
 lib/Kconfig                         |   3 +
 lib/string.c                        | 196 ++++++++++++++++++++++++++++++++++++
 17 files changed, 394 insertions(+), 38 deletions(-)

-- 
2.13.2

[toc] | [next] | [standalone]


#1693174 — [PATCH v4 6/8] zram: Convert to using memset_l

FromMatthew Wilcox <willy@infradead.org>
Date2017-07-20 20:50 +0200
Subject[PATCH v4 6/8] zram: Convert to using memset_l
Message-ID<u5oGm-2GI-45@gated-at.bofh.it>
In reply to#1693173
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

[toc] | [prev] | [next] | [standalone]


#1695391

FromMichael Ellerman <mpe@ellerman.id.au>
Date2017-07-25 07:30 +0200
Message-ID<u70zT-78Y-9@gated-at.bofh.it>
In reply to#1693173
Matthew Wilcox <willy@infradead.org> writes:

> From: Matthew Wilcox <mawilcox@microsoft.com>
>
> A relatively common idiom we're missing is a function to fill an area
> of memory with a pattern which is larger than a single byte.  I first
> noticed this with a zram patch which wanted to fill a page with an
> 'unsigned long' value.  There turn out to be quite a few places in
> the kernel which can benefit from using an optimised function rather
> than a loop; sometimes text size, sometimes speed, and sometimes both.
> The optimised PowerPC version (not included here) improves performance
> by about 30% on POWER8 on just the raw memset_l().

Is the plan that Andrew will merge this series, or are you planning to
put them in a tree of yours?

cheers

[toc] | [prev] | [next] | [standalone]


#1695718

FromMatthew Wilcox <willy@infradead.org>
Date2017-07-25 15:10 +0200
Message-ID<u77L4-3dw-11@gated-at.bofh.it>
In reply to#1695391
On Tue, Jul 25, 2017 at 03:27:38PM +1000, Michael Ellerman wrote:
> Matthew Wilcox <willy@infradead.org> writes:
> 
> > From: Matthew Wilcox <mawilcox@microsoft.com>
> >
> > A relatively common idiom we're missing is a function to fill an area
> > of memory with a pattern which is larger than a single byte.  I first
> > noticed this with a zram patch which wanted to fill a page with an
> > 'unsigned long' value.  There turn out to be quite a few places in
> > the kernel which can benefit from using an optimised function rather
> > than a loop; sometimes text size, sometimes speed, and sometimes both.
> > The optimised PowerPC version (not included here) improves performance
> > by about 30% on POWER8 on just the raw memset_l().
> 
> Is the plan that Andrew will merge this series, or are you planning to
> put them in a tree of yours?

I'm hoping Andrew will take it, but I can put it in my own tree if he
doesn't want to take it.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web