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


Groups > linux.kernel > #1278529 > unrolled thread

[PATCH 0/2] zram: cleanup stream's ->private allocation code

Started bySergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
First post2015-11-27 05:30 +0100
Last post2015-11-30 08:20 +0100
Articles 6 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/2] zram: cleanup stream's ->private allocation code Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-27 05:30 +0100
    [PATCH 1/2] zram: pass gfp from zcomp frontend to backend Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-27 05:30 +0100
      Re: [PATCH 1/2] zram: pass gfp from zcomp frontend to backend Andrew Morton <akpm@linux-foundation.org> - 2015-12-01 01:20 +0100
        Re: [PATCH 1/2] zram: pass gfp from zcomp frontend to backend Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-12-01 01:50 +0100
    [PATCH 2/2] zram/zcomp: do not zero out zcomp private pages Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2015-11-27 05:30 +0100
      Re: [PATCH 2/2] zram/zcomp: do not zero out zcomp private pages Minchan Kim <minchan@kernel.org> - 2015-11-30 08:20 +0100

#1278529 — [PATCH 0/2] zram: cleanup stream's ->private allocation code

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2015-11-27 05:30 +0100
Subject[PATCH 0/2] zram: cleanup stream's ->private allocation code
Message-ID<qziPw-6lh-5@gated-at.bofh.it>
Hello,
	Two patches that 'cleanup' compression streams allocation.
Patch #1 consolidates GFP flags used for stream's ->private
allocation in underlying compression backends.

Patch #2 drops GFP_ZERO flag from ->private allocation.


This patch set depends on the patch set published here
http://marc.info/?l=linux-kernel&m=144859748015849


Minchan Kim (1):
  zram: pass gfp from zcomp frontend to backend

Sergey Senozhatsky (1):
  zram/zcomp: do not zero out zcomp private pages

 drivers/block/zram/zcomp.c     | 24 ++++++++++++++++--------
 drivers/block/zram/zcomp.h     |  2 +-
 drivers/block/zram/zcomp_lz4.c | 16 +++-------------
 drivers/block/zram/zcomp_lzo.c | 16 +++-------------
 4 files changed, 23 insertions(+), 35 deletions(-)

-- 
2.6.3.368.gf34be46

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1278530 — [PATCH 1/2] zram: pass gfp from zcomp frontend to backend

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2015-11-27 05:30 +0100
Subject[PATCH 1/2] zram: pass gfp from zcomp frontend to backend
Message-ID<qziPw-6lh-11@gated-at.bofh.it>
In reply to#1278529
From: Minchan Kim <minchan@kernel.org>

Each zcomp backend uses own gfp flag but it's pointless
because the context they could be called is driven by upper
layer(ie, zcomp frontend). As well, zcomp frondend could
call them in different context. One context(ie, zram init part)
is it should be better to make sure successful allocation
other context(ie, further stream allocation part for accelarating
I/O speed) is just optional so let's pass gfp down from driver
(ie, zcomp frontend) like normal MM convention.

[sergey: add missing __vmalloc zero and highmem gfps]
Signed-off-by: Minchan Kim <minchan@kernel.org>
Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 drivers/block/zram/zcomp.c     | 24 ++++++++++++++++--------
 drivers/block/zram/zcomp.h     |  2 +-
 drivers/block/zram/zcomp_lz4.c | 16 +++-------------
 drivers/block/zram/zcomp_lzo.c | 16 +++-------------
 4 files changed, 23 insertions(+), 35 deletions(-)

diff --git a/drivers/block/zram/zcomp.c b/drivers/block/zram/zcomp.c
index c536177..2bc4aea 100644
--- a/drivers/block/zram/zcomp.c
+++ b/drivers/block/zram/zcomp.c
@@ -74,18 +74,18 @@ static void zcomp_strm_free(struct zcomp *comp, struct zcomp_strm *zstrm)
  * allocate new zcomp_strm structure with ->private initialized by
  * backend, return NULL on error
  */
-static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
+static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp, gfp_t flags)
 {
-	struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_NOIO);
+	struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), flags);
 	if (!zstrm)
 		return NULL;
 
-	zstrm->private = comp->backend->create();
+	zstrm->private = comp->backend->create(flags);
 	/*
 	 * allocate 2 pages. 1 for compressed data, plus 1 extra for the
 	 * case when compressed size is larger than the original one
 	 */
-	zstrm->buffer = (void *)__get_free_pages(GFP_NOIO | __GFP_ZERO, 1);
+	zstrm->buffer = (void *)__get_free_pages(flags | __GFP_ZERO, 1);
 	if (!zstrm->private || !zstrm->buffer) {
 		zcomp_strm_free(comp, zstrm);
 		zstrm = NULL;
@@ -120,8 +120,16 @@ static struct zcomp_strm *zcomp_strm_multi_find(struct zcomp *comp)
 		/* allocate new zstrm stream */
 		zs->avail_strm++;
 		spin_unlock(&zs->strm_lock);
-
-		zstrm = zcomp_strm_alloc(comp);
+		/*
+		 * This function can be called in swapout/fs write path
+		 * so we can't use GFP_FS|IO. And it assumes we already
+		 * have at least one stream in zram initialization so we
+		 * don't do best effort to allocate more stream in here.
+		 * A default stream will work well without further multiple
+		 * streams. That's why we use NORETRY | NOWARN | NOMEMALLOC.
+		 */
+		zstrm = zcomp_strm_alloc(comp, GFP_NOIO | __GFP_NORETRY |
+					__GFP_NOWARN | __GFP_NOMEMALLOC);
 		if (!zstrm) {
 			spin_lock(&zs->strm_lock);
 			zs->avail_strm--;
@@ -209,7 +217,7 @@ static int zcomp_strm_multi_create(struct zcomp *comp, int max_strm)
 	zs->max_strm = max_strm;
 	zs->avail_strm = 1;
 
-	zstrm = zcomp_strm_alloc(comp);
+	zstrm = zcomp_strm_alloc(comp, GFP_KERNEL);
 	if (!zstrm) {
 		kfree(zs);
 		return -ENOMEM;
@@ -259,7 +267,7 @@ static int zcomp_strm_single_create(struct zcomp *comp)
 
 	comp->stream = zs;
 	mutex_init(&zs->strm_lock);
-	zs->zstrm = zcomp_strm_alloc(comp);
+	zs->zstrm = zcomp_strm_alloc(comp, GFP_KERNEL);
 	if (!zs->zstrm) {
 		kfree(zs);
 		return -ENOMEM;
diff --git a/drivers/block/zram/zcomp.h b/drivers/block/zram/zcomp.h
index 46e2b9f..b7d2a4b 100644
--- a/drivers/block/zram/zcomp.h
+++ b/drivers/block/zram/zcomp.h
@@ -33,7 +33,7 @@ struct zcomp_backend {
 	int (*decompress)(const unsigned char *src, size_t src_len,
 			unsigned char *dst);
 
-	void *(*create)(void);
+	void *(*create)(gfp_t flags);
 	void (*destroy)(void *private);
 
 	const char *name;
diff --git a/drivers/block/zram/zcomp_lz4.c b/drivers/block/zram/zcomp_lz4.c
index f2bfced..dc2338d 100644
--- a/drivers/block/zram/zcomp_lz4.c
+++ b/drivers/block/zram/zcomp_lz4.c
@@ -15,24 +15,14 @@
 
 #include "zcomp_lz4.h"
 
-static void *zcomp_lz4_create(void)
+static void *zcomp_lz4_create(gfp_t flags)
 {
 	void *ret;
 
-	/*
-	 * This function can be called in swapout/fs write path
-	 * so we can't use GFP_FS|IO. And it assumes we already
-	 * have at least one stream in zram initialization so we
-	 * don't do best effort to allocate more stream in here.
-	 * A default stream will work well without further multiple
-	 * streams. That's why we use NORETRY | NOWARN | NOMEMALLOC.
-	 */
-	ret = kzalloc(LZ4_MEM_COMPRESS, GFP_NOIO | __GFP_NORETRY |
-					__GFP_NOWARN | __GFP_NOMEMALLOC);
+	ret = kzalloc(LZ4_MEM_COMPRESS, flags);
 	if (!ret)
 		ret = __vmalloc(LZ4_MEM_COMPRESS,
-				GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN |
-				__GFP_NOMEMALLOC | __GFP_ZERO | __GFP_HIGHMEM,
+				flags | __GFP_ZERO | __GFP_HIGHMEM,
 				PAGE_KERNEL);
 	return ret;
 }
diff --git a/drivers/block/zram/zcomp_lzo.c b/drivers/block/zram/zcomp_lzo.c
index 7fbb4a3..0ab6fce 100644
--- a/drivers/block/zram/zcomp_lzo.c
+++ b/drivers/block/zram/zcomp_lzo.c
@@ -15,24 +15,14 @@
 
 #include "zcomp_lzo.h"
 
-static void *lzo_create(void)
+static void *lzo_create(gfp_t flags)
 {
 	void *ret;
 
-	/*
-	 * This function can be called in swapout/fs write path
-	 * so we can't use GFP_FS|IO. And it assumes we already
-	 * have at least one stream in zram initialization so we
-	 * don't do best effort to allocate more stream in here.
-	 * A default stream will work well without further multiple
-	 * streams. That's why we use NORETRY | NOWARN | NOMEMALLOC.
-	 */
-	ret = kzalloc(LZO1X_MEM_COMPRESS, GFP_NOIO | __GFP_NORETRY |
-					__GFP_NOWARN | __GFP_NOMEMALLOC);
+	ret = kzalloc(LZO1X_MEM_COMPRESS, flags);
 	if (!ret)
 		ret = __vmalloc(LZO1X_MEM_COMPRESS,
-				GFP_NOIO | __GFP_NORETRY | __GFP_NOWARN |
-				__GFP_NOMEMALLOC | __GFP_ZERO | __GFP_HIGHMEM,
+				flags | __GFP_ZERO | __GFP_HIGHMEM,
 				PAGE_KERNEL);
 	return ret;
 }
-- 
2.6.3.368.gf34be46

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1280418 — Re: [PATCH 1/2] zram: pass gfp from zcomp frontend to backend

FromAndrew Morton <akpm@linux-foundation.org>
Date2015-12-01 01:20 +0100
SubjectRe: [PATCH 1/2] zram: pass gfp from zcomp frontend to backend
Message-ID<qAGPL-2hv-5@gated-at.bofh.it>
In reply to#1278530
On Fri, 27 Nov 2015 13:23:13 +0900 Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> wrote:

> From: Minchan Kim <minchan@kernel.org>
> 
> Each zcomp backend uses own gfp flag but it's pointless
> because the context they could be called is driven by upper
> layer(ie, zcomp frontend). As well, zcomp frondend could
> call them in different context. One context(ie, zram init part)
> is it should be better to make sure successful allocation
> other context(ie, further stream allocation part for accelarating
> I/O speed) is just optional so let's pass gfp down from driver
> (ie, zcomp frontend) like normal MM convention.
> 
> [sergey: add missing __vmalloc zero and highmem gfps]
> Signed-off-by: Minchan Kim <minchan@kernel.org>
> Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

I changed this to signed-off-by:you.  Documentation/SubmittingPatches
section 11 explains why ;)

(Hm, rule (c) is recursive.  Nice!)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1280432 — Re: [PATCH 1/2] zram: pass gfp from zcomp frontend to backend

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2015-12-01 01:50 +0100
SubjectRe: [PATCH 1/2] zram: pass gfp from zcomp frontend to backend
Message-ID<qAHiN-2re-3@gated-at.bofh.it>
In reply to#1280418
On (11/30/15 16:10), Andrew Morton wrote:
> > From: Minchan Kim <minchan@kernel.org>
> > 
> > Each zcomp backend uses own gfp flag but it's pointless
> > because the context they could be called is driven by upper
> > layer(ie, zcomp frontend). As well, zcomp frondend could
> > call them in different context. One context(ie, zram init part)
> > is it should be better to make sure successful allocation
> > other context(ie, further stream allocation part for accelarating
> > I/O speed) is just optional so let's pass gfp down from driver
> > (ie, zcomp frontend) like normal MM convention.
> > 
> > [sergey: add missing __vmalloc zero and highmem gfps]
> > Signed-off-by: Minchan Kim <minchan@kernel.org>
> > Acked-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
> 
> I changed this to signed-off-by:you.  Documentation/SubmittingPatches
> section 11 explains why ;)

Thank you.

> (Hm, rule (c) is recursive.  Nice!)

	-ss
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1278531 — [PATCH 2/2] zram/zcomp: do not zero out zcomp private pages

FromSergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Date2015-11-27 05:30 +0100
Subject[PATCH 2/2] zram/zcomp: do not zero out zcomp private pages
Message-ID<qziPw-6lh-3@gated-at.bofh.it>
In reply to#1278529
Do not __GFP_ZERO allocated zcomp ->private pages. We keep
allocated streams around and use them for read/write requests,
so we supply a zeroed out ->private to compression algorithm
as a scratch buffer only once -- the first time we use that
stream. For the rest of IO requests served by this stream
->private usually contains some temporarily data from the
previous requests.

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
---
 drivers/block/zram/zcomp_lz4.c | 4 ++--
 drivers/block/zram/zcomp_lzo.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/block/zram/zcomp_lz4.c b/drivers/block/zram/zcomp_lz4.c
index dc2338d..0110086 100644
--- a/drivers/block/zram/zcomp_lz4.c
+++ b/drivers/block/zram/zcomp_lz4.c
@@ -19,10 +19,10 @@ static void *zcomp_lz4_create(gfp_t flags)
 {
 	void *ret;
 
-	ret = kzalloc(LZ4_MEM_COMPRESS, flags);
+	ret = kmalloc(LZ4_MEM_COMPRESS, flags);
 	if (!ret)
 		ret = __vmalloc(LZ4_MEM_COMPRESS,
-				flags | __GFP_ZERO | __GFP_HIGHMEM,
+				flags | __GFP_HIGHMEM,
 				PAGE_KERNEL);
 	return ret;
 }
diff --git a/drivers/block/zram/zcomp_lzo.c b/drivers/block/zram/zcomp_lzo.c
index 0ab6fce..ed7a1f0 100644
--- a/drivers/block/zram/zcomp_lzo.c
+++ b/drivers/block/zram/zcomp_lzo.c
@@ -19,10 +19,10 @@ static void *lzo_create(gfp_t flags)
 {
 	void *ret;
 
-	ret = kzalloc(LZO1X_MEM_COMPRESS, flags);
+	ret = kmalloc(LZO1X_MEM_COMPRESS, flags);
 	if (!ret)
 		ret = __vmalloc(LZO1X_MEM_COMPRESS,
-				flags | __GFP_ZERO | __GFP_HIGHMEM,
+				flags | __GFP_HIGHMEM,
 				PAGE_KERNEL);
 	return ret;
 }
-- 
2.6.3.368.gf34be46

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


#1279608 — Re: [PATCH 2/2] zram/zcomp: do not zero out zcomp private pages

FromMinchan Kim <minchan@kernel.org>
Date2015-11-30 08:20 +0100
SubjectRe: [PATCH 2/2] zram/zcomp: do not zero out zcomp private pages
Message-ID<qAqUF-tv-3@gated-at.bofh.it>
In reply to#1278531
On Fri, Nov 27, 2015 at 01:23:14PM +0900, Sergey Senozhatsky wrote:
> Do not __GFP_ZERO allocated zcomp ->private pages. We keep
> allocated streams around and use them for read/write requests,
> so we supply a zeroed out ->private to compression algorithm
> as a scratch buffer only once -- the first time we use that
> stream. For the rest of IO requests served by this stream
> ->private usually contains some temporarily data from the
> previous requests.
> 
> Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web