linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlastimil Babka <vbabka@suse.cz>
To: Mel Gorman <mgorman@techsingularity.net>,
	Andrew Morton <akpm@linux-foundation.org>,
	Linux-MM <linux-mm@kvack.org>
Cc: Rik van Riel <riel@surriel.com>,
	Johannes Weiner <hannes@cmpxchg.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 01/27] mm, vmstat: Add infrastructure for per-node vmstats
Date: Fri, 10 Jun 2016 15:31:41 +0200	[thread overview]
Message-ID: <575AC13D.2010104@suse.cz> (raw)
In-Reply-To: <1465495483-11855-2-git-send-email-mgorman@techsingularity.net>

On 06/09/2016 08:04 PM, Mel Gorman wrote:
> References: bnc#969297 PM performance -- intel_pstate
> Patch-mainline: No, expected 4.7 and queued in linux-mm
> Patch-name: patches.suse/mm-vmstat-Add-infrastructure-for-per-node-vmstats.patch

Remove?

> VM statistic counters for reclaim decisions are zone-based. If the kernel
> is to reclaim on a per-node basis then we need to track per-node statistics
> but there is no infrastructure for that. The most notable change is that
> the old node_page_state is renamed to sum_zone_node_page_state.  The new
> node_page_state takes a pglist_data and uses per-node stats but none exist
> yet. There is some renaming such as vm_stat to vm_zone_stat and the addition
> of vm_node_stat and the renaming of mod_state to mod_zone_state. Otherwise,
> this is mostly a mechanical patch with no functional change. There is a
> lot of similarity between the node and zone helpers which is unfortunate
> but there was no obvious way of reusing the code and maintaining type safety.
> 
> Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
> Acked-by: Johannes Weiner <hannes@cmpxchg.org>
> Signed-off-by: Mel Gorman <mgorman@suse.com>

Acked-by: Vlastimil Babka <vbabka@suse.cz>

Some nitpicks below.

> @@ -237,12 +286,26 @@ static inline void __inc_zone_page_state(struct page *page,
>  	__inc_zone_state(page_zone(page), item);
>  }
>  
> +static inline void __inc_node_page_state(struct page *page,
> +			enum node_stat_item item)
> +{
> +	__inc_node_state(page_zone(page)->zone_pgdat, item);

This page -> node translation looks needlessly ineffective. How about
using NODE_DATA(page_to_nid(page)).

> +}
> +
> +
>  static inline void __dec_zone_page_state(struct page *page,
>  			enum zone_stat_item item)
>  {
>  	__dec_zone_state(page_zone(page), item);
>  }
>  
> +static inline void __dec_node_page_state(struct page *page,
> +			enum node_stat_item item)
> +{
> +	__dec_node_state(page_zone(page)->zone_pgdat, item);
> +}

Ditto.

> @@ -188,9 +190,13 @@ void refresh_zone_stat_thresholds(void)
>  
>  		threshold = calculate_normal_threshold(zone);
>  
> -		for_each_online_cpu(cpu)
> +		for_each_online_cpu(cpu) {
> +			struct pglist_data *pgdat = zone->zone_pgdat;

Move the variable outside?

>  			per_cpu_ptr(zone->pageset, cpu)->stat_threshold
>  							= threshold;
> +			per_cpu_ptr(pgdat->per_cpu_nodestats, cpu)->stat_threshold
> +							= threshold;
> +		}
>  
>  		/*
>  		 * Only set percpu_drift_mark if there is a danger that
>  void __inc_zone_page_state(struct page *page, enum zone_stat_item item)

[...]

>  {
>  	__inc_zone_state(page_zone(page), item);
>  }
>  EXPORT_SYMBOL(__inc_zone_page_state);
>  
> +void __inc_node_page_state(struct page *page, enum node_stat_item item)
> +{
> +	__inc_node_state(page_zone(page)->zone_pgdat, item);

Same page -> node thing here.


> +void __dec_node_page_state(struct page *page, enum node_stat_item item)
> +{
> +	__dec_node_state(page_zone(page)->zone_pgdat, item);

And here.

>  
>  void dec_zone_page_state(struct page *page, enum zone_stat_item item)
>  {
> -	mod_state(page_zone(page), item, -1, -1);
> +	mod_zone_state(page_zone(page), item, -1, -1);
>  }
>  EXPORT_SYMBOL(dec_zone_page_state);
> +
> +static inline void mod_node_state(struct pglist_data *pgdat,
> +       enum node_stat_item item, int delta, int overstep_mode)
> +{
> +	struct per_cpu_nodestat __percpu *pcp = pgdat->per_cpu_nodestats;
> +	s8 __percpu *p = pcp->vm_node_stat_diff + item;
> +	long o, n, t, z;
> +
> +	do {
> +		z = 0;  /* overflow to zone counters */

s/zone/node/?

> +
> +		/*
> +		 * The fetching of the stat_threshold is racy. We may apply
> +		 * a counter threshold to the wrong the cpu if we get
> +		 * rescheduled while executing here. However, the next
> +		 * counter update will apply the threshold again and
> +		 * therefore bring the counter under the threshold again.
> +		 *
> +		 * Most of the time the thresholds are the same anyways
> +		 * for all cpus in a zone.

same here.

> +		 */
> +		t = this_cpu_read(pcp->stat_threshold);
> +
> +		o = this_cpu_read(*p);
> +		n = delta + o;
> +
> +		if (n > t || n < -t) {
> +			int os = overstep_mode * (t >> 1) ;
> +
> +			/* Overflow must be added to zone counters */

and here.

> +}
> +
> +void inc_node_page_state(struct page *page, enum node_stat_item item)
> +{
> +	mod_node_state(page_zone(page)->zone_pgdat, item, 1, 1);

Ditto about page -> nid.

> +}
> +EXPORT_SYMBOL(inc_node_page_state);
> +
> +void dec_node_page_state(struct page *page, enum node_stat_item item)
> +{
> +	mod_node_state(page_zone(page)->zone_pgdat, item, -1, -1);
> +}

Ditto.

> +EXPORT_SYMBOL(dec_node_page_state);
>  #else
>  /*
>   * Use interrupt disable to serialize counter updates
> @@ -436,21 +568,69 @@ void dec_zone_page_state(struct page *page, enum zone_stat_item item)
>  	local_irq_restore(flags);
>  }
>  EXPORT_SYMBOL(dec_zone_page_state);
> -#endif
>  
> +void inc_node_state(struct pglist_data *pgdat, enum node_stat_item item)
> +{
> +	unsigned long flags;
> +
> +	local_irq_save(flags);
> +	__inc_node_state(pgdat, item);
> +	local_irq_restore(flags);
> +}
> +EXPORT_SYMBOL(inc_node_state);
> +
> +void mod_node_page_state(struct pglist_data *pgdat, enum node_stat_item item,
> +					long delta)
> +{
> +	unsigned long flags;
> +
> +	local_irq_save(flags);
> +	__mod_node_page_state(pgdat, item, delta);
> +	local_irq_restore(flags);
> +}
> +EXPORT_SYMBOL(mod_node_page_state);
> +
> +void inc_node_page_state(struct page *page, enum node_stat_item item)
> +{
> +	unsigned long flags;
> +	struct pglist_data *pgdat;
> +
> +	pgdat = page_zone(page)->zone_pgdat;

And here.

,9 +736,11 @@ static int refresh_cpu_vm_stats(bool do_pagesets)
>   */
>  void cpu_vm_stats_fold(int cpu)
>  {
> +	struct pglist_data *pgdat;
>  	struct zone *zone;
>  	int i;
> -	int global_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, };
> +	int global_zone_diff[NR_VM_ZONE_STAT_ITEMS] = { 0, };
> +	int global_node_diff[NR_VM_NODE_STAT_ITEMS] = { 0, };
>  
>  	for_each_populated_zone(zone) {
>  		struct per_cpu_pageset *p;
> @@ -555,11 +754,27 @@ void cpu_vm_stats_fold(int cpu)
>  				v = p->vm_stat_diff[i];
>  				p->vm_stat_diff[i] = 0;
>  				atomic_long_add(v, &zone->vm_stat[i]);
> -				global_diff[i] += v;
> +				global_zone_diff[i] += v;
>  			}
>  	}
>  

  reply	other threads:[~2016-06-10 13:32 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-09 18:04 [PATCH 00/27] Move LRU page reclaim from zones to nodes v6 Mel Gorman
2016-06-09 18:04 ` [PATCH 01/27] mm, vmstat: Add infrastructure for per-node vmstats Mel Gorman
2016-06-10 13:31   ` Vlastimil Babka [this message]
2016-06-10 13:47     ` Mel Gorman
2016-06-13 17:26   ` Christoph Lameter
2016-06-14 14:25     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 02/27] mm, vmscan: Move lru_lock to the node Mel Gorman
2016-06-10 16:39   ` Vlastimil Babka
2016-06-10 17:48     ` Peter Zijlstra
2016-06-14 14:41     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 03/27] mm, vmscan: Move LRU lists to node Mel Gorman
2016-06-10 18:00   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 04/27] mm, vmscan: Begin reclaiming pages on a per-node basis Mel Gorman
2016-06-15 12:52   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 05/27] mm, vmscan: Have kswapd only scan based on the highest requested zone Mel Gorman
2016-06-15 13:13   ` Vlastimil Babka
2016-06-16  7:44     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 06/27] mm, vmscan: Make kswapd reclaim in terms of nodes Mel Gorman
2016-06-15 14:23   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 07/27] mm, vmscan: Remove balance gap Mel Gorman
2016-06-15 14:28   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 08/27] mm, vmscan: Simplify the logic deciding whether kswapd sleeps Mel Gorman
2016-06-15 15:18   ` Vlastimil Babka
2016-06-16  8:30     ` Mel Gorman
2016-06-16  9:16       ` Mel Gorman
2016-06-09 18:04 ` [PATCH 09/27] mm, vmscan: By default have direct reclaim only shrink once per node Mel Gorman
2016-06-16  8:59   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 10/27] mm, vmscan: Clear congestion, dirty and need for compaction on a per-node basis Mel Gorman
2016-06-16  9:29   ` Vlastimil Babka
2016-06-16 10:29     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 11/27] mm: vmscan: Do not reclaim from kswapd if there is any eligible zone Mel Gorman
2016-06-16 10:08   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 12/27] mm, vmscan: Make shrink_node decisions more node-centric Mel Gorman
2016-06-16 13:35   ` Vlastimil Babka
2016-06-16 14:47     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 13/27] mm, memcg: Move memcg limit enforcement from zones to nodes Mel Gorman
2016-06-16 15:06   ` Vlastimil Babka
2016-06-16 15:53     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 14/27] mm, workingset: Make working set detection node-aware Mel Gorman
2016-06-16 15:13   ` Vlastimil Babka
2016-06-16 15:56     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 15/27] mm, page_alloc: Consider dirtyable memory in terms of nodes Mel Gorman
2016-06-16 15:45   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 16/27] mm: Move page mapped accounting to the node Mel Gorman
2016-06-16 15:52   ` Vlastimil Babka
2016-06-16 16:04     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 17/27] mm: Rename NR_ANON_PAGES to NR_ANON_MAPPED Mel Gorman
2016-06-17  8:28   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 18/27] mm: Move most file-based accounting to the node Mel Gorman
2016-06-17  8:35   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 19/27] mm: Move vmscan writes and file write " Mel Gorman
2016-06-17  8:51   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 20/27] mm, vmscan: Update classzone_idx if buffer_heads_over_limit Mel Gorman
2016-06-17  8:53   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 21/27] mm, vmscan: Only wakeup kswapd once per node for the requested classzone Mel Gorman
2016-06-17 10:46   ` Vlastimil Babka
2016-06-17 12:03     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 22/27] mm: Convert zone_reclaim to node_reclaim Mel Gorman
2016-06-17 10:55   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 23/27] mm, vmscan: Add classzone information to tracepoints Mel Gorman
2016-06-17 10:57   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 24/27] mm, page_alloc: Remove fair zone allocation policy Mel Gorman
2016-06-17 11:27   ` Vlastimil Babka
2016-06-17 12:07     ` Mel Gorman
2016-06-09 18:04 ` [PATCH 25/27] mm: page_alloc: Cache the last node whose dirty limit is reached Mel Gorman
2016-06-17 11:31   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 26/27] mm: vmstat: Replace __count_zone_vm_events with a zone id equivalent Mel Gorman
2016-06-17 11:36   ` Vlastimil Babka
2016-06-09 18:04 ` [PATCH 27/27] mm: vmstat: Account per-zone stalls and pages skipped during reclaim Mel Gorman
2016-06-17 12:39   ` Vlastimil Babka
  -- strict thread matches above, loose matches on Subject: below --
2016-06-21 14:15 [PATCH 00/27] Move LRU page reclaim from zones to nodes v7 Mel Gorman
2016-06-21 14:15 ` [PATCH 01/27] mm, vmstat: Add infrastructure for per-node vmstats Mel Gorman
2016-06-21 11:43 [PATCH 00/27] Move LRU page reclaim from zones to nodes v7 Mel Gorman
2016-06-21 11:43 ` [PATCH 01/27] mm, vmstat: Add infrastructure for per-node vmstats Mel Gorman
2016-04-15  9:13 [PATCH 00/27] Move LRU page reclaim from zones to nodes v5 Mel Gorman
2016-04-15  9:13 ` [PATCH 01/27] mm, vmstat: Add infrastructure for per-node vmstats Mel Gorman

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=575AC13D.2010104@suse.cz \
    --to=vbabka@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@techsingularity.net \
    --cc=riel@surriel.com \
    --subject='Re: [PATCH 01/27] mm, vmstat: Add infrastructure for per-node vmstats' \
    /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

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