OSDN Git Service

brd: add cond_resched to brd_free_pages
authorMikulas Patocka <mpatocka@redhat.com>
Thu, 9 May 2019 18:51:27 +0000 (12:51 -0600)
committerJens Axboe <axboe@kernel.dk>
Thu, 9 May 2019 18:51:27 +0000 (12:51 -0600)
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>
drivers/block/brd.c

index 17defbf..2da615b 100644 (file)
@@ -153,6 +153,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,
                 * so will this have to.