linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: prevent NR_ISOLATE_* stats from going negative
@ 2017-04-20 10:24 Rabin Vincent
  2017-04-20 12:32 ` Michal Hocko
  0 siblings, 1 reply; 2+ messages in thread
From: Rabin Vincent @ 2017-04-20 10:24 UTC (permalink / raw)
  To: akpm
  Cc: linux-mm, linux-kernel, Rabin Vincent, Ming Ling, Michal Hocko,
	Minchan Kim, Vlastimil Babka, stable

From: Rabin Vincent <rabinv@axis.com>

Commit 6afcf8ef0ca0 ("mm, compaction: fix NR_ISOLATED_* stats for pfn
based migration") moved the dec_node_page_state() call (along with the
page_is_file_cache() call) to after putback_lru_page().  But
page_is_file_cache() can change after putback_lru_page() is called, so
it should be called before putback_lru_page(), as it was before that
patch, to prevent NR_ISOLATE_* stats from going negative.

Without this fix, non-CONFIG_SMP kernels end up hanging in the
while(too_many_isolated()) { congestion_wait() } loop in
shrink_active_list() due to the negative stats.

 Mem-Info:
  active_anon:32567 inactive_anon:121 isolated_anon:1
  active_file:6066 inactive_file:6639 isolated_file:4294967295
                                                    ^^^^^^^^^^
  unevictable:0 dirty:115 writeback:0 unstable:0
  slab_reclaimable:2086 slab_unreclaimable:3167
  mapped:3398 shmem:18366 pagetables:1145 bounce:0
  free:1798 free_pcp:13 free_cma:0

Fixes: 6afcf8ef0ca0 ("mm, compaction: fix NR_ISOLATED_* stats for pfn based migration")
Cc: Ming Ling <ming.ling@spreadtrum.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Rabin Vincent <rabinv@axis.com>
---
 mm/migrate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/migrate.c b/mm/migrate.c
index ed97c2c..738f1d5 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -184,9 +184,9 @@ void putback_movable_pages(struct list_head *l)
 			unlock_page(page);
 			put_page(page);
 		} else {
-			putback_lru_page(page);
 			dec_node_page_state(page, NR_ISOLATED_ANON +
 					page_is_file_cache(page));
+			putback_lru_page(page);
 		}
 	}
 }
-- 
2.7.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: prevent NR_ISOLATE_* stats from going negative
  2017-04-20 10:24 [PATCH] mm: prevent NR_ISOLATE_* stats from going negative Rabin Vincent
@ 2017-04-20 12:32 ` Michal Hocko
  0 siblings, 0 replies; 2+ messages in thread
From: Michal Hocko @ 2017-04-20 12:32 UTC (permalink / raw)
  To: Rabin Vincent
  Cc: akpm, linux-mm, linux-kernel, Rabin Vincent, Ming Ling,
	Minchan Kim, Vlastimil Babka, stable

On Thu 20-04-17 12:24:25, Rabin Vincent wrote:
> From: Rabin Vincent <rabinv@axis.com>
> 
> Commit 6afcf8ef0ca0 ("mm, compaction: fix NR_ISOLATED_* stats for pfn
> based migration") moved the dec_node_page_state() call (along with the
> page_is_file_cache() call) to after putback_lru_page().  But
> page_is_file_cache() can change after putback_lru_page() is called, so
> it should be called before putback_lru_page(), as it was before that
> patch, to prevent NR_ISOLATE_* stats from going negative.
> 
> Without this fix, non-CONFIG_SMP kernels end up hanging in the
> while(too_many_isolated()) { congestion_wait() } loop in
> shrink_active_list() due to the negative stats.
> 
>  Mem-Info:
>   active_anon:32567 inactive_anon:121 isolated_anon:1
>   active_file:6066 inactive_file:6639 isolated_file:4294967295
>                                                     ^^^^^^^^^^
>   unevictable:0 dirty:115 writeback:0 unstable:0
>   slab_reclaimable:2086 slab_unreclaimable:3167
>   mapped:3398 shmem:18366 pagetables:1145 bounce:0
>   free:1798 free_pcp:13 free_cma:0
> 
> Fixes: 6afcf8ef0ca0 ("mm, compaction: fix NR_ISOLATED_* stats for pfn based migration")
> Cc: Ming Ling <ming.ling@spreadtrum.com>
> Cc: Michal Hocko <mhocko@suse.com>
> Cc: Minchan Kim <minchan@kernel.org>
> Cc: Vlastimil Babka <vbabka@suse.cz>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Rabin Vincent <rabinv@axis.com>

Thanks for catching and fixing this. This is definitely my fault whe
reworking Ming's original patch

Acked-by: Michal Hocko <mhocko@suse.com>

> ---
>  mm/migrate.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/migrate.c b/mm/migrate.c
> index ed97c2c..738f1d5 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -184,9 +184,9 @@ void putback_movable_pages(struct list_head *l)
>  			unlock_page(page);
>  			put_page(page);
>  		} else {
> -			putback_lru_page(page);
>  			dec_node_page_state(page, NR_ISOLATED_ANON +
>  					page_is_file_cache(page));
> +			putback_lru_page(page);
>  		}
>  	}
>  }
> -- 
> 2.7.0
> 

-- 
Michal Hocko
SUSE Labs

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-20 12:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-20 10:24 [PATCH] mm: prevent NR_ISOLATE_* stats from going negative Rabin Vincent
2017-04-20 12:32 ` Michal Hocko

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