Re: [stable] writeback: fix dirtied pages accounting on redirty

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

 



Hi Ben,

On Sun, Apr 07, 2013 at 08:01:38PM +0100, Ben Hutchings wrote:
> This is missing from 3.0.y and 3.2.y; should we have it?

It would help 3.2.y, however not as much for 3.0.y.

The background is, when the IO-less dirty throttling patches
go upstream, there were concerns that the change set is too complex.
So it end up being merged in two stages: v3.2 includes the core bits
and v3.3 includes the improvement/optimization bits.

This patch falls into the latter category.

As for pre-3.2 kernels, they run the old threshold based
balance_dirty_pages() and are not sensible to dirty accounting errors.

Thanks,
Fengguang

> ---
> From: Wu Fengguang <fengguang.wu@xxxxxxxxx>
> Date: Mon, 8 Aug 2011 15:22:00 -0600
> Subject: writeback: fix dirtied pages accounting on redirty
> 
> commit 2f800fbd777b792de54187088df19a7df0251254 upstream.
> 
> De-account the accumulative dirty counters on page redirty.
> 
> Page redirties (very common in ext4) will introduce mismatch between
> counters (a) and (b)
> 
> a) NR_DIRTIED, BDI_DIRTIED, tsk->nr_dirtied
> b) NR_WRITTEN, BDI_WRITTEN
> 
> This will introduce systematic errors in balanced_rate and result in
> dirty page position errors (ie. the dirty pages are no longer balanced
> around the global/bdi setpoints).
> 
> Acked-by: Jan Kara <jack@xxxxxxx>
> Acked-by: Peter Zijlstra <a.p.zijlstra@xxxxxxxxx>
> Signed-off-by: Wu Fengguang <fengguang.wu@xxxxxxxxx>
> ---
>  include/linux/writeback.h |    2 ++
>  mm/page-writeback.c       |   19 +++++++++++++++++++
>  2 files changed, 21 insertions(+)
> 
> diff --git a/include/linux/writeback.h b/include/linux/writeback.h
> index 05eaf5e..b30419c 100644
> --- a/include/linux/writeback.h
> +++ b/include/linux/writeback.h
> @@ -197,6 +197,8 @@ void writeback_set_ratelimit(void);
>  void tag_pages_for_writeback(struct address_space *mapping,
>  			     pgoff_t start, pgoff_t end);
>  
> +void account_page_redirty(struct page *page);
> +
>  /* pdflush.c */
>  extern int nr_pdflush_threads;	/* Global so it can be exported to sysctl
>  				   read-only. */
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 5d1ef5d..96b3e7a 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -1825,6 +1825,24 @@ int __set_page_dirty_nobuffers(struct page *page)
>  EXPORT_SYMBOL(__set_page_dirty_nobuffers);
>  
>  /*
> + * Call this whenever redirtying a page, to de-account the dirty counters
> + * (NR_DIRTIED, BDI_DIRTIED, tsk->nr_dirtied), so that they match the written
> + * counters (NR_WRITTEN, BDI_WRITTEN) in long term. The mismatches will lead to
> + * systematic errors in balanced_dirty_ratelimit and the dirty pages position
> + * control.
> + */
> +void account_page_redirty(struct page *page)
> +{
> +	struct address_space *mapping = page->mapping;
> +	if (mapping && mapping_cap_account_dirty(mapping)) {
> +		current->nr_dirtied--;
> +		dec_zone_page_state(page, NR_DIRTIED);
> +		dec_bdi_stat(mapping->backing_dev_info, BDI_DIRTIED);
> +	}
> +}
> +EXPORT_SYMBOL(account_page_redirty);
> +
> +/*
>   * When a writepage implementation decides that it doesn't want to write this
>   * page for some reason, it should redirty the locked page via
>   * redirty_page_for_writepage() and it should then unlock the page and return 0
> @@ -1832,6 +1850,7 @@ EXPORT_SYMBOL(__set_page_dirty_nobuffers);
>  int redirty_page_for_writepage(struct writeback_control *wbc, struct page *page)
>  {
>  	wbc->pages_skipped++;
> +	account_page_redirty(page);
>  	return __set_page_dirty_nobuffers(page);
>  }
>  EXPORT_SYMBOL(redirty_page_for_writepage);
> 
> 
> -- 
> Ben Hutchings
> I'm not a reverse psychological virus.  Please don't copy me into your sig.


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




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]