Re: [PATCH] brd: add cond_resched to brd_free_pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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@xxxxxxxxxx>
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@xxxxxxxxxx>

---
 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.



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux