]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
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 17defbf4f332c5267b5cc38e94c25e54a5246d6a..2da615b45b3144b8b6eaebef600627ccae572476 100644 (file)
@@ -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,