linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] brd: add cond_resched to brd_free_pages
@ 2019-05-09 16:54 Mikulas Patocka
  2019-05-09 16:56 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2019-05-09 16:54 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block

The loop that frees all the pages can take unbounded amount of time, so
add cond_resched() to it.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/block/brd.c |    2 ++
 1 file changed, 2 insertions(+)

Index: linux-4.19.41/drivers/block/brd.c
===================================================================
--- linux-4.19.41.orig/drivers/block/brd.c	2019-01-22 12:26:42.000000000 +0100
+++ linux-4.19.41/drivers/block/brd.c	2019-05-09 17:09:11.000000000 +0200
@@ -157,6 +157,8 @@ static void brd_free_pages(struct brd_de
 
 		pos++;
 
+		cond_resched();
+
 		/*
 		 * This assumes radix_tree_gang_lookup always returns as
 		 * many pages as possible. If the radix-tree code changes,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] brd: add cond_resched to brd_free_pages
  2019-05-09 16:54 [PATCH] brd: add cond_resched to brd_free_pages Mikulas Patocka
@ 2019-05-09 16:56 ` Jens Axboe
  2019-05-09 18:50   ` Mikulas Patocka
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2019-05-09 16:56 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: linux-block

On 5/9/19 10:54 AM, Mikulas Patocka wrote:
> The loop that frees all the pages can take unbounded amount of time, so
> add cond_resched() to it.

Looks fine to me, would be nice with a comment on why the cond_resched()
is needed though.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] brd: add cond_resched to brd_free_pages
  2019-05-09 16:56 ` Jens Axboe
@ 2019-05-09 18:50   ` Mikulas Patocka
  2019-05-09 18:51     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Mikulas Patocka @ 2019-05-09 18:50 UTC (permalink / raw)
  To: Jens Axboe; +Cc: linux-block



On Thu, 9 May 2019, Jens Axboe wrote:

> On 5/9/19 10:54 AM, Mikulas Patocka wrote:
> > The loop that frees all the pages can take unbounded amount of time, so
> > add cond_resched() to it.
> 
> Looks fine to me, would be nice with a comment on why the cond_resched()
> is needed though.
> 
> -- 
> Jens Axboe

OK - here I added the comment.

Mikulas



From: Mikulas Patocka <mpatocka@redhat.com>
Subject: [PATCH] brd: add cond_resched to brd_free_pages

The loop that frees all the pages can take unbounded amount of time, so
add cond_resched() to it.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/block/brd.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: linux-2.6/drivers/block/brd.c
===================================================================
--- linux-2.6.orig/drivers/block/brd.c	2019-05-09 20:46:23.000000000 +0200
+++ linux-2.6/drivers/block/brd.c	2019-05-09 20:47:43.000000000 +0200
@@ -158,6 +158,12 @@ static void brd_free_pages(struct brd_de
 		pos++;
 
 		/*
+		 * It takes 3.4 seconds to remove 80GiB ramdisk.
+		 * So, we need cond_resched to avoid stalling the CPU.
+		 */
+		cond_resched();
+
+		/*
 		 * This assumes radix_tree_gang_lookup always returns as
 		 * many pages as possible. If the radix-tree code changes,
 		 * so will this have to.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] brd: add cond_resched to brd_free_pages
  2019-05-09 18:50   ` Mikulas Patocka
@ 2019-05-09 18:51     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-05-09 18:51 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: linux-block

On 5/9/19 12:50 PM, Mikulas Patocka wrote:
> 
> 
> On Thu, 9 May 2019, Jens Axboe wrote:
> 
>> On 5/9/19 10:54 AM, Mikulas Patocka wrote:
>>> The loop that frees all the pages can take unbounded amount of time, so
>>> add cond_resched() to it.
>>
>> Looks fine to me, would be nice with a comment on why the cond_resched()
>> is needed though.
>>
>> -- 
>> Jens Axboe
> 
> OK - here I added the comment.

Great thanks, applied.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-09 19:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-09 16:54 [PATCH] brd: add cond_resched to brd_free_pages Mikulas Patocka
2019-05-09 16:56 ` Jens Axboe
2019-05-09 18:50   ` Mikulas Patocka
2019-05-09 18:51     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).