mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jens Axboe <axboe@kernel.dk>
To: Dongyun Liu <dongyun.liu3@gmail.com>,
	minchan@kernel.org, senozhatsky@chromium.org
Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org,
	lincheng.yang@transsion.com, jiajun.ling@transsion.com,
	ldys2014@foxmail.com, Dongyun Liu <dongyun.liu@transsion.com>
Subject: Re: [PATCH] zram: Using GFP_ATOMIC instead of GFP_KERNEL to allocate bitmap memory in backing_dev_store
Date: Thu, 30 Nov 2023 08:37:40 -0700	[thread overview]
Message-ID: <feb0a163-c1d3-4087-96dc-f64d0dde235b@kernel.dk> (raw)
In-Reply-To: <20231130152047.200169-1-dongyun.liu@transsion.com>

On 11/30/23 8:20 AM, Dongyun Liu wrote:
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index d77d3664ca08..ee6c22c50e09 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -514,7 +514,7 @@ static ssize_t backing_dev_store(struct device *dev,
>  
>  	nr_pages = i_size_read(inode) >> PAGE_SHIFT;
>  	bitmap_sz = BITS_TO_LONGS(nr_pages) * sizeof(long);
> -	bitmap = kvzalloc(bitmap_sz, GFP_KERNEL);
> +	bitmap = kmalloc(bitmap_sz, GFP_ATOMIC);
>  	if (!bitmap) {
>  		err = -ENOMEM;
>  		goto out;

Outside of this moving from a zeroed alloc to one that does not, the
change looks woefully incomplete. Why does this allocation need to be
GFP_ATOMIC, and:

1) file_name = kmalloc(PATH_MAX, GFP_KERNEL); does not
2) filp_open() -> getname_kernel() -> __getname() does not
3) filp_open() -> getname_kernel() does not
4) bdev_open_by_dev() does not

IOW, you have a slew of GFP_KERNEL allocations in there, and you
probably just patched the largest one. But the core issue remains.

The whole handling of backing_dev_store() looks pretty broken.

-- 
Jens Axboe


  reply	other threads:[~2023-11-30 15:37 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 15:20 Dongyun Liu
2023-11-30 15:37 ` Jens Axboe [this message]
2023-12-01  6:51   ` Dongyun Liu
2023-12-01 14:19     ` Jens Axboe
2023-12-01 15:28       ` Sergey Senozhatsky
2023-12-02 13:54       ` Dongyun Liu
2023-12-01 15:39 ` Sergey Senozhatsky
2023-12-02 15:50   ` Dongyun Liu
2023-12-03  1:23     ` Sergey Senozhatsky
2023-12-03 14:45       ` Dongyun Liu
2023-12-01 18:41 ` Minchan Kim

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=feb0a163-c1d3-4087-96dc-f64d0dde235b@kernel.dk \
    --to=axboe@kernel.dk \
    --cc=dongyun.liu3@gmail.com \
    --cc=dongyun.liu@transsion.com \
    --cc=jiajun.ling@transsion.com \
    --cc=ldys2014@foxmail.com \
    --cc=lincheng.yang@transsion.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=minchan@kernel.org \
    --cc=senozhatsky@chromium.org \
    /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

all inboxes | Powered by JetHome®