Re: [PATCH v2 3/3] zram: pass gfp from zcomp frontend to backend
From: Sergey Senozhatsky
Date: Thu Nov 26 2015 - 21:30:47 EST
On (11/27/15 11:19), Sergey Senozhatsky wrote:
[..]
> > > +static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp, gfp_t flags)
> > > {
> > > + zstrm = zcomp_strm_alloc(comp, GFP_NOIO|__GFP_NORETRY|
> > > + __GFP_NOWARN|__GFP_NOMEMALLOC);
> >
> >
> > and it seems that after 3/3 (v2) we also lost GFP_ZERO for private
> > allocation. kzalloc->kmalloc, and no explicit __GFP_ZERO for __vmalloc().
> >
>
> well, we probably don't really need __GFP_ZERO for ->private, but
> let's address it in a separate patch, not as an undocumented change.
hm... something like this perhaps. I don't think there any security
issues with removing __GFP_ZERO, we have 'garbage' in ->private anyway.
zram/zcomp: do not zero out zcomp private pages
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.
---
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;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/