On Mon, 23 Nov 2015 22:27:59 +0900 Sergey Senozhatsky 
<[email protected]> wrote:

> We can end up allocating a new compression stream with GFP_KERNEL
> from within the IO path, which may result is nested (recursive) IO
> operations. That can introduce problems if the IO path in question
> is a reclaimer, holding some locks that will deadlock nested IOs.
> 
> Allocate streams and working memory using GFP_NOIO flag, forbidding
> recursive IO and FS operations.
> 
> ...
>
> --- a/drivers/block/zram/zcomp.c
> +++ b/drivers/block/zram/zcomp.c
> @@ -76,7 +76,7 @@ static void zcomp_strm_free(struct zcomp *comp, struct 
> zcomp_strm *zstrm)
>   */
>  static struct zcomp_strm *zcomp_strm_alloc(struct zcomp *comp)
>  {
> -     struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_KERNEL);
> +     struct zcomp_strm *zstrm = kmalloc(sizeof(*zstrm), GFP_NOIO);
>       if (!zstrm)
>               return NULL;
>  
> @@ -85,7 +85,7 @@ static struct zcomp_strm *zcomp_strm_alloc(struct zcomp 
> *comp)
>        * 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_KERNEL | __GFP_ZERO, 1);
> +     zstrm->buffer = (void *)__get_free_pages(GFP_NOIO | __GFP_ZERO, 1);

OK.

> --- a/drivers/block/zram/zcomp_lz4.c
> +++ b/drivers/block/zram/zcomp_lz4.c
> @@ -20,10 +20,13 @@ static void *zcomp_lz4_create(void)
>       void *ret;
>  
>       ret = kzalloc(LZ4_MEM_COMPRESS,
> -                     __GFP_NORETRY|__GFP_NOWARN|__GFP_NOMEMALLOC);
> -     if (!ret)
> -             ret = vzalloc(LZ4_MEM_COMPRESS);
> -     return ret;
> +                     __GFP_NORETRY | __GFP_NOWARN | __GFP_NOMEMALLOC);

But here we've still lost __GFP_RECLAIM, unnecessarily.  And it's quite
unclear why __GFP_NORETRY and __GFP_NOMEMALLOC are being used.

IOW, why not simply use (GFP_NOIO|__GFP_NOWARN)?


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

Reply via email to