linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Hocko <mhocko@suse.cz>
To: Johannes Weiner <hannes@cmpxchg.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Tejun Heo <tj@kernel.org>, Rik van Riel <riel@redhat.com>,
	Mel Gorman <mgorman@suse.de>,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [patch 1/2] mm: page-writeback: fix dirty_balance_reserve subtraction from dirtyable memory
Date: Tue, 28 Jan 2014 14:48:49 +0100	[thread overview]
Message-ID: <20140128134849.GA4625@dhcp22.suse.cz> (raw)
In-Reply-To: <1390600984-13925-2-git-send-email-hannes@cmpxchg.org>

On Fri 24-01-14 17:03:03, Johannes Weiner wrote:
> The dirty_balance_reserve is an approximation of the fraction of free
> pages that the page allocator does not make available for page cache
> allocations.  As a result, it has to be taken into account when
> calculating the amount of "dirtyable memory", the baseline to which
> dirty_background_ratio and dirty_ratio are applied.
> 
> However, currently the reserve is subtracted from the sum of free and
> reclaimable pages, which is non-sensical and leads to erroneous
> results when the system is dominated by unreclaimable pages and the
> dirty_balance_reserve is bigger than free+reclaimable.  In that case,
> at least the already allocated cache should be considered dirtyable.
> 
> Fix the calculation by subtracting the reserve from the amount of free
> pages, then adding the reclaimable pages on top.
> 
> Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>

Makes sense
Reviewed-by: Michal Hocko <mhocko@suse.cz>

> ---
>  mm/page-writeback.c | 52 +++++++++++++++++++++++-----------------------------
>  1 file changed, 23 insertions(+), 29 deletions(-)
> 
> diff --git a/mm/page-writeback.c b/mm/page-writeback.c
> index 63807583d8e8..79cf52b058a7 100644
> --- a/mm/page-writeback.c
> +++ b/mm/page-writeback.c
> @@ -191,6 +191,25 @@ static unsigned long writeout_period_time = 0;
>   * global dirtyable memory first.
>   */
>  
> +/**
> + * zone_dirtyable_memory - number of dirtyable pages in a zone
> + * @zone: the zone
> + *
> + * Returns the zone's number of pages potentially available for dirty
> + * page cache.  This is the base value for the per-zone dirty limits.
> + */
> +static unsigned long zone_dirtyable_memory(struct zone *zone)
> +{
> +	unsigned long nr_pages;
> +
> +	nr_pages = zone_page_state(zone, NR_FREE_PAGES);
> +	nr_pages -= min(nr_pages, zone->dirty_balance_reserve);
> +
> +	nr_pages += zone_reclaimable_pages(zone);
> +
> +	return nr_pages;
> +}
> +
>  static unsigned long highmem_dirtyable_memory(unsigned long total)
>  {
>  #ifdef CONFIG_HIGHMEM
> @@ -201,8 +220,7 @@ static unsigned long highmem_dirtyable_memory(unsigned long total)
>  		struct zone *z =
>  			&NODE_DATA(node)->node_zones[ZONE_HIGHMEM];
>  
> -		x += zone_page_state(z, NR_FREE_PAGES) +
> -		     zone_reclaimable_pages(z) - z->dirty_balance_reserve;
> +		x += zone_dirtyable_memory(zone);
>  	}
>  	/*
>  	 * Unreclaimable memory (kernel memory or anonymous memory
> @@ -238,9 +256,11 @@ static unsigned long global_dirtyable_memory(void)
>  {
>  	unsigned long x;
>  
> -	x = global_page_state(NR_FREE_PAGES) + global_reclaimable_pages();
> +	x = global_page_state(NR_FREE_PAGES);
>  	x -= min(x, dirty_balance_reserve);
>  
> +	x += global_reclaimable_pages();
> +
>  	if (!vm_highmem_is_dirtyable)
>  		x -= highmem_dirtyable_memory(x);
>  
> @@ -289,32 +309,6 @@ void global_dirty_limits(unsigned long *pbackground, unsigned long *pdirty)
>  }
>  
>  /**
> - * zone_dirtyable_memory - number of dirtyable pages in a zone
> - * @zone: the zone
> - *
> - * Returns the zone's number of pages potentially available for dirty
> - * page cache.  This is the base value for the per-zone dirty limits.
> - */
> -static unsigned long zone_dirtyable_memory(struct zone *zone)
> -{
> -	/*
> -	 * The effective global number of dirtyable pages may exclude
> -	 * highmem as a big-picture measure to keep the ratio between
> -	 * dirty memory and lowmem reasonable.
> -	 *
> -	 * But this function is purely about the individual zone and a
> -	 * highmem zone can hold its share of dirty pages, so we don't
> -	 * care about vm_highmem_is_dirtyable here.
> -	 */
> -	unsigned long nr_pages = zone_page_state(zone, NR_FREE_PAGES) +
> -		zone_reclaimable_pages(zone);
> -
> -	/* don't allow this to underflow */
> -	nr_pages -= min(nr_pages, zone->dirty_balance_reserve);
> -	return nr_pages;
> -}
> -
> -/**
>   * zone_dirty_limit - maximum number of dirty pages allowed in a zone
>   * @zone: the zone
>   *
> -- 
> 1.8.4.2
> 
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org.  For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

-- 
Michal Hocko
SUSE Labs

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  parent reply	other threads:[~2014-01-28 13:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-24 22:03 [patch 0/2] mm: reduce reclaim stalls with heavy anon and dirty cache Johannes Weiner
2014-01-24 22:03 ` [patch 1/2] mm: page-writeback: fix dirty_balance_reserve subtraction from dirtyable memory Johannes Weiner
2014-01-24 23:05   ` Rik van Riel
2014-01-28 13:48   ` Michal Hocko [this message]
2014-01-24 22:03 ` [patch 2/2] mm: page-writeback: do not count anon pages as " Johannes Weiner
2014-01-24 23:25   ` Rik van Riel
2014-01-28 13:58   ` Michal Hocko
2014-01-24 22:21 ` [patch 0/2] mm: reduce reclaim stalls with heavy anon and dirty cache Tejun Heo
2014-01-24 23:31   ` Tejun Heo
2014-01-24 22:30 ` Andrew Morton
2014-01-24 22:51   ` Johannes Weiner
2014-01-24 23:26     ` Rik van Riel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140128134849.GA4625@dhcp22.suse.cz \
    --to=mhocko@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=riel@redhat.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).