linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Balbir Singh <balbir@linux.vnet.ibm.com>
To: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	linux-mm <linux-mm@kvack.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
	Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH 06/11] memcg: make inactive_anon_is_low()
Date: Wed, 3 Dec 2008 19:22:49 +0530	[thread overview]
Message-ID: <20081203135249.GE17701@balbir.in.ibm.com> (raw)
In-Reply-To: <20081201211457.1CDC.KOSAKI.MOTOHIRO@jp.fujitsu.com>

* KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> [2008-12-01 21:15:46]:

> Changelog:
>  v1 -> v2:
>    - add detail patch description
>    - fix coding style in mem_cgroup_set_inactive_ratio()
>    - add comment to mem_cgroup_set_inactive_ratio
>    - remove extra newline
>    - memcg::inactiveratio change type to unsigned int
>

[snip]
 
> +/*
> + * The inactive anon list should be small enough that the VM never has to
> + * do too much work, but large enough that each inactive page has a chance
> + * to be referenced again before it is swapped out.
> + *
> + * this calculation is straightforward porting from
> + * page_alloc.c::setup_per_zone_inactive_ratio().
> + * it describe more detail.
> + */
> +static void mem_cgroup_set_inactive_ratio(struct mem_cgroup *memcg)
> +{
> +	unsigned int gb, ratio;
> +
> +	gb = res_counter_read_u64(&memcg->res, RES_LIMIT) >> 30;
> +	if (gb)
> +		ratio = int_sqrt(10 * gb);

I don't understand where the magic number 10 comes from?

> +	else
> +		ratio = 1;
> +
> +	memcg->inactive_ratio = ratio;
> +
> +}
> +
>  static DEFINE_MUTEX(set_limit_mutex);
> 
>  static int mem_cgroup_resize_limit(struct mem_cgroup *memcg,
> @@ -1384,6 +1424,10 @@ static int mem_cgroup_resize_limit(struc
>  				GFP_HIGHUSER_MOVABLE, false);
>    		if (!progress)			retry_count--;
>  	}
> +
> +	if (!ret)
> +		mem_cgroup_set_inactive_ratio(memcg);
> +
>  	return ret;
>  }
> 
> @@ -1968,7 +2012,7 @@ mem_cgroup_create(struct cgroup_subsys *
>  		res_counter_init(&mem->res, NULL);
>  		res_counter_init(&mem->memsw, NULL);
>  	}
> -
> +	mem_cgroup_set_inactive_ratio(mem);
>  	mem->last_scanned_child = NULL;
> 
>  	return &mem->css;
> Index: b/mm/vmscan.c
> ===================================================================
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1369,14 +1369,7 @@ static void shrink_active_list(unsigned 
>  	pagevec_release(&pvec);
>  }
> 
> -/**
> - * inactive_anon_is_low - check if anonymous pages need to be deactivated
> - * @zone: zone to check
> - *
> - * Returns true if the zone does not have enough inactive anon pages,
> - * meaning some active anon pages need to be deactivated.
> - */
> -static int inactive_anon_is_low(struct zone *zone)
> +static int inactive_anon_is_low_global(struct zone *zone)
>  {
>  	unsigned long active, inactive;
> 
> @@ -1389,6 +1382,25 @@ static int inactive_anon_is_low(struct z
>  	return 0;
>  }
> 
> +/**
> + * inactive_anon_is_low - check if anonymous pages need to be deactivated
> + * @zone: zone to check
> + * @sc:   scan control of this context
> + *
> + * Returns true if the zone does not have enough inactive anon pages,
> + * meaning some active anon pages need to be deactivated.
> + */
> +static int inactive_anon_is_low(struct zone *zone, struct scan_control *sc)
> +{
> +	int low;
> +
> +	if (scan_global_lru(sc))
> +		low = inactive_anon_is_low_global(zone);
> +	else
> +		low = mem_cgroup_inactive_anon_is_low(sc->mem_cgroup, zone);
> +	return low;
> +}
> +
>  static unsigned long shrink_list(enum lru_list lru, unsigned long nr_to_scan,
>  	struct zone *zone, struct scan_control *sc, int priority)
>  {
> @@ -1400,7 +1412,7 @@ static unsigned long shrink_list(enum lr
>  	}
> 
>  	if (lru == LRU_ACTIVE_ANON &&
> -	    (!scan_global_lru(sc) || inactive_anon_is_low(zone))) {
> +	    inactive_anon_is_low(zone, sc)) {

Can't we merge the line with the "if" statement

>  		shrink_active_list(nr_to_scan, zone, sc, priority, file);
>  		return 0;
>  	}
> @@ -1565,9 +1577,7 @@ static void shrink_zone(int priority, st
>  	 * Even if we did not try to evict anon pages at all, we want to
>  	 * rebalance the anon lru active/inactive ratio.
>  	 */
> -	if (!scan_global_lru(sc) || inactive_anon_is_low(zone))
> -		shrink_active_list(SWAP_CLUSTER_MAX, zone, sc, priority, 0);
> -	else if (!scan_global_lru(sc))
> +	if (inactive_anon_is_low(zone, sc))
>  		shrink_active_list(SWAP_CLUSTER_MAX, zone, sc, priority, 0);
> 
>  	throttle_vm_writeout(sc->gfp_mask);
> @@ -1863,7 +1873,7 @@ loop_again:
>  			 * Do some background aging of the anon list, to give
>  			 * pages a chance to be referenced before reclaiming.
>  			 */
> -			if (inactive_anon_is_low(zone))
> +			if (inactive_anon_is_low(zone, &sc))
>  				shrink_active_list(SWAP_CLUSTER_MAX, zone,
>  							&sc, priority, 0);
> 
> 
> 

-- 
	Balbir

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

  reply	other threads:[~2008-12-03 13:52 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-01 12:10 [PATCH 00/11] memcg: split-lru feature for memcg take2 KOSAKI Motohiro
2008-12-01 12:11 ` [PATCH 01/11] inactive_anon_is_low() move to vmscan.c KOSAKI Motohiro
2008-12-01 12:12 ` [PATCH 02/11] introduce zone_reclaim struct KOSAKI Motohiro
2008-12-01 12:13 ` [PATCH 03/11] make zone_nr_pages() helper function KOSAKI Motohiro
2008-12-01 12:14 ` [PATCH 04/11] make get_scan_ratio() to memcg safe KOSAKI Motohiro
2008-12-01 14:50   ` Rik van Riel
2008-12-01 12:14 ` [PATCH 05/11] memcg: add null check to page_cgroup_zoneinfo() KOSAKI Motohiro
2008-12-01 14:52   ` Rik van Riel
2008-12-01 12:15 ` [PATCH 06/11] memcg: make inactive_anon_is_low() KOSAKI Motohiro
2008-12-03 13:52   ` Balbir Singh [this message]
2008-12-04  6:14     ` KOSAKI Motohiro
2008-12-01 12:16 ` [PATCH 07/11] memcg: make mem_cgroup_zone_nr_pages() KOSAKI Motohiro
2008-12-01 16:31   ` Rik van Riel
2008-12-03 13:58   ` Balbir Singh
2008-12-01 12:17 ` [PATCH 08/11] memcg: make zone_reclaim_stat KOSAKI Motohiro
2008-12-01 16:33   ` Rik van Riel
2008-12-03 14:06   ` Balbir Singh
2008-12-04  7:15     ` KOSAKI Motohiro
2008-12-01 12:18 ` [PATCH 09/11] memcg: remove mem_cgroup_calc_reclaim() KOSAKI Motohiro
2008-12-01 17:09   ` Rik van Riel
2008-12-01 12:19 ` [PATCH 10/11] memcg: show inactive_ratio KOSAKI Motohiro
2008-12-01 17:10   ` Rik van Riel
2008-12-02  9:05   ` KAMEZAWA Hiroyuki
2008-12-01 12:19 ` [PATCH 11/11] memcg: show reclaim_stat KOSAKI Motohiro
2008-12-01 17:11   ` Rik van Riel
2008-12-02  9:05   ` KAMEZAWA Hiroyuki
2008-12-03 14:19     ` Balbir Singh
2008-12-03 16:15       ` KAMEZAWA Hiroyuki
2008-12-02  4:25 ` [PATCH 00/11] memcg: split-lru feature for memcg take2 KAMEZAWA Hiroyuki

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=20081203135249.GE17701@balbir.in.ibm.com \
    --to=balbir@linux.vnet.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=kamezawa.hiroyu@jp.fujitsu.com \
    --cc=kosaki.motohiro@jp.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=riel@redhat.com \
    /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