Skip to content

Commit

Permalink
brd: add cond_resched to brd_free_pages
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Mikulas Patocka authored and Jens Axboe committed May 9, 2019
1 parent cf12c67 commit 936b33f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/block/brd.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,12 @@ static void brd_free_pages(struct brd_device *brd)

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,
Expand Down

0 comments on commit 936b33f

Please sign in to comment.