diff mbox series

zram_drv: allow reclaim on bio_alloc

Message ID 20210906052926.6007-1-jaewon31.kim@samsung.com (mailing list archive)
State New
Headers show
Series zram_drv: allow reclaim on bio_alloc | expand

Commit Message

Jaewon Kim Sept. 6, 2021, 5:29 a.m. UTC
The read_from_bdev_async is not called on atomic context. So GFP_NOIO is
available rather than GFP_ATOMIC. If there were reclaimable pages with
GFP_NOIO, we can avoid allocation failure and page fault failure.

Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
---
 drivers/block/zram/zram_drv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Christoph Hellwig Sept. 6, 2021, 8:38 a.m. UTC | #1
On Mon, Sep 06, 2021 at 02:29:26PM +0900, Jaewon Kim wrote:
> The read_from_bdev_async is not called on atomic context. So GFP_NOIO is
> available rather than GFP_ATOMIC. If there were reclaimable pages with
> GFP_NOIO, we can avoid allocation failure and page fault failure.
> 
> Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
> Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
> ---
>  drivers/block/zram/zram_drv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> index fcaf2750f68f..53be528a39a2 100644
> --- a/drivers/block/zram/zram_drv.c
> +++ b/drivers/block/zram/zram_drv.c
> @@ -587,7 +587,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
>  {
>  	struct bio *bio;
>  
> -	bio = bio_alloc(GFP_ATOMIC, 1);
> +	bio = bio_alloc(GFP_NOIO|__GFP_HIGHMEM, 1);

Passing __GFP_HIGHMEM to bio_alloc does not make any sense whatsoever.
Jaewon Kim Sept. 6, 2021, 9:14 a.m. UTC | #2
> 
> 
>--------- Original Message ---------
>Sender : Christoph Hellwig <hch@infradead.org>
>Date : 2021-09-06 17:39 (GMT+9)
>Title : Re: [PATCH] zram_drv: allow reclaim on bio_alloc
> 
>On Mon, Sep 06, 2021 at 02:29:26PM +0900, Jaewon Kim wrote:
>> The read_from_bdev_async is not called on atomic context. So GFP_NOIO is
>> available rather than GFP_ATOMIC. If there were reclaimable pages with
>> GFP_NOIO, we can avoid allocation failure and page fault failure.
>> 
>> Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
>> Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
>> ---
>>  drivers/block/zram/zram_drv.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
>> index fcaf2750f68f..53be528a39a2 100644
>> --- a/drivers/block/zram/zram_drv.c
>> +++ b/drivers/block/zram/zram_drv.c
>> @@ -587,7 +587,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
>>  {
>>          struct bio *bio;
>>  
>> -        bio = bio_alloc(GFP_ATOMIC, 1);
>> +        bio = bio_alloc(GFP_NOIO|__GFP_HIGHMEM, 1);
> 
>Passing __GFP_HIGHMEM to bio_alloc does not make any sense whatsoever.
> 
Correct, let me remove __GFP_HIGHMEM if I send v2 patch.
Thank you
Minchan Kim Sept. 7, 2021, 5 p.m. UTC | #3
Hi Jaewon,

On Mon, Sep 06, 2021 at 06:14:48PM +0900, Jaewon Kim wrote:
> > 
> > 
> >--------- Original Message ---------
> >Sender : Christoph Hellwig <hch@infradead.org>
> >Date : 2021-09-06 17:39 (GMT+9)
> >Title : Re: [PATCH] zram_drv: allow reclaim on bio_alloc
> > 
> >On Mon, Sep 06, 2021 at 02:29:26PM +0900, Jaewon Kim wrote:
> >> The read_from_bdev_async is not called on atomic context. So GFP_NOIO is
> >> available rather than GFP_ATOMIC. If there were reclaimable pages with
> >> GFP_NOIO, we can avoid allocation failure and page fault failure.
> >> 
> >> Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
> >> Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>

Looks reasonable to me.
Feel free to add after dealing with Christoph's comment.

Acked-by: Minchan Kim <minchan@kernel.org>

Thank you.

> >> ---
> >>  drivers/block/zram/zram_drv.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
> >> index fcaf2750f68f..53be528a39a2 100644
> >> --- a/drivers/block/zram/zram_drv.c
> >> +++ b/drivers/block/zram/zram_drv.c
> >> @@ -587,7 +587,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
> >>  {
> >>          struct bio *bio;
> >>  
> >> -        bio = bio_alloc(GFP_ATOMIC, 1);
> >> +        bio = bio_alloc(GFP_NOIO|__GFP_HIGHMEM, 1);
> > 
> >Passing __GFP_HIGHMEM to bio_alloc does not make any sense whatsoever.
> > 
> Correct, let me remove __GFP_HIGHMEM if I send v2 patch.
> Thank you
Jaewon Kim Sept. 8, 2021, 12:41 a.m. UTC | #4
> 
> 
>--------- Original Message ---------
>Sender : Minchan Kim <minchan@kernel.org>
>Date : 2021-09-08 02:00 (GMT+9)
>Title : Re: (2) [PATCH] zram_drv: allow reclaim on bio_alloc
> 
>Hi Jaewon,
> 
>On Mon, Sep 06, 2021 at 06:14:48PM +0900, Jaewon Kim wrote:
>> > 
>> > 
>> >--------- Original Message ---------
>> >Sender : Christoph Hellwig <hch@infradead.org>
>> >Date : 2021-09-06 17:39 (GMT+9)
>> >Title : Re: [PATCH] zram_drv: allow reclaim on bio_alloc
>> > 
>> >On Mon, Sep 06, 2021 at 02:29:26PM +0900, Jaewon Kim wrote:
>> >> The read_from_bdev_async is not called on atomic context. So GFP_NOIO is
>> >> available rather than GFP_ATOMIC. If there were reclaimable pages with
>> >> GFP_NOIO, we can avoid allocation failure and page fault failure.
>> >> 
>> >> Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
>> >> Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
> 
>Looks reasonable to me.
>Feel free to add after dealing with Christoph's comment.
> 
>Acked-by: Minchan Kim <minchan@kernel.org>
> 
>Thank you.

Thank you, I will send v2 patch soon.

> 
>> >> ---
>> >>  drivers/block/zram/zram_drv.c | 2 +-
>> >>  1 file changed, 1 insertion(+), 1 deletion(-)
>> >> 
>> >> diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
>> >> index fcaf2750f68f..53be528a39a2 100644
>> >> --- a/drivers/block/zram/zram_drv.c
>> >> +++ b/drivers/block/zram/zram_drv.c
>> >> @@ -587,7 +587,7 @@ static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
>> >>  {
>> >>          struct bio *bio;
>> >>  
>> >> -        bio = bio_alloc(GFP_ATOMIC, 1);
>> >> +        bio = bio_alloc(GFP_NOIO|__GFP_HIGHMEM, 1);
>> > 
>> >Passing __GFP_HIGHMEM to bio_alloc does not make any sense whatsoever.
>> > 
>> Correct, let me remove __GFP_HIGHMEM if I send v2 patch.
>> Thank you
>
diff mbox series

Patch

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index fcaf2750f68f..53be528a39a2 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -587,7 +587,7 @@  static int read_from_bdev_async(struct zram *zram, struct bio_vec *bvec,
 {
 	struct bio *bio;
 
-	bio = bio_alloc(GFP_ATOMIC, 1);
+	bio = bio_alloc(GFP_NOIO|__GFP_HIGHMEM, 1);
 	if (!bio)
 		return -ENOMEM;