Re: [PATCH 1/2] writeback: Improve busyloop prevention

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

 



> From 595677f8efcaa0d9f675bf74a7048739323afd06 Mon Sep 17 00:00:00 2001
> From: Jan Kara <jack@xxxxxxx>
> Date: Wed, 19 Oct 2011 13:44:46 +0200
> Subject: [PATCH] writeback: Retry kupdate work early if we need to retry some inode writeback
> 
> In case we could not do any writeback for some inodes, trigger next kupdate
> work early so that writeback on these inodes is not delayed for the whole
> dirty_writeback_interval.

Looks good, too.

> Signed-off-by: Jan Kara <jack@xxxxxxx>
> ---
>  fs/fs-writeback.c |   25 ++++++++++++++++++-------
>  1 files changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> index 8314241..e48da04 100644
> --- a/fs/fs-writeback.c
> +++ b/fs/fs-writeback.c
> @@ -701,6 +701,7 @@ static long wb_writeback(struct bdi_writeback *wb,
>  	unsigned long oldest_jif;
>  	struct inode *inode;
>  	long progress;
> +	long total_progress = 0;
>  
>  	oldest_jif = jiffies;
>  	work->older_than_this = &oldest_jif;
> @@ -750,6 +751,7 @@ static long wb_writeback(struct bdi_writeback *wb,
>  		else
>  			progress = __writeback_inodes_wb(wb, work);
>  		trace_writeback_written(wb->bdi, work);
> +		total_progress += progress;
>  
>  		wb_update_bandwidth(wb, wb_start);
>  
> @@ -783,7 +785,7 @@ static long wb_writeback(struct bdi_writeback *wb,
>  	}
>  	spin_unlock(&wb->list_lock);
>  
> -	return nr_pages - work->nr_pages;
> +	return total_progress;
>  }
>  
>  /*
> @@ -845,7 +847,7 @@ static long wb_check_old_data_flush(struct bdi_writeback *wb)
>  
>  	expired = wb->last_old_flush +
>  			msecs_to_jiffies(dirty_writeback_interval * 10);
> -	if (time_before(jiffies, expired))
> +	if (time_before(jiffies, expired) && list_empty(&wb->b_more_io_wait))
>  		return 0;
>  
>  	wb->last_old_flush = jiffies;
> @@ -915,7 +917,11 @@ int bdi_writeback_thread(void *data)
>  {
>  	struct bdi_writeback *wb = data;
>  	struct backing_dev_info *bdi = wb->bdi;
> -	long pages_written;
> +	long progress;

I'd like to separate out the pages_written=>progress changes,
which will make two more clear patches.

Thanks,
Fengguang

> +	unsigned int pause = 1;
> +	unsigned int max_pause = dirty_writeback_interval ?
> +			msecs_to_jiffies(dirty_writeback_interval * 10) :
> +			HZ;
>  
>  	current->flags |= PF_SWAPWRITE;
>  	set_freezable();
> @@ -935,12 +941,14 @@ int bdi_writeback_thread(void *data)
>  		 */
>  		del_timer(&wb->wakeup_timer);
>  
> -		pages_written = wb_do_writeback(wb, 0);
> +		progress = wb_do_writeback(wb, 0);
>  
>  		trace_writeback_pages_written(pages_written);
>  
> -		if (pages_written)
> +		if (progress) {
>  			wb->last_active = jiffies;
> +			pause = 1;
> +		}
>  
>  		set_current_state(TASK_INTERRUPTIBLE);
>  		if (!list_empty(&bdi->work_list) || kthread_should_stop()) {
> @@ -948,8 +956,11 @@ int bdi_writeback_thread(void *data)
>  			continue;
>  		}
>  
> -		if (wb_has_dirty_io(wb) && dirty_writeback_interval)
> -			schedule_timeout(msecs_to_jiffies(dirty_writeback_interval * 10));
> +		if (!list_empty(&wb->b_more_io_wait) && pause < max_pause) {
> +			schedule_timeout(pause);
> +			pause <<= 1;
> +		} else if (wb_has_dirty_io(wb) && dirty_writeback_interval)
> +			schedule_timeout(max_pause);
>  		else {
>  			/*
>  			 * We have nothing to do, so can go sleep without any
> -- 
> 1.7.1
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]
  Powered by Linux