linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Zhouping Liu <zliu@redhat.com>
To: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Rik van Riel <riel@redhat.com>,
	Andrea Arcangeli <aarcange@redhat.com>,
	Mel Gorman <mgorman@suse.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Ingo Molnar <mingo@kernel.org>, CAI Qian <caiqian@redhat.com>
Subject: Re: [PATCH 00/31] numa/core patches
Date: Fri, 02 Nov 2012 11:23:34 +0800	[thread overview]
Message-ID: <50933CB6.6000909@redhat.com> (raw)
In-Reply-To: <alpine.LNX.2.00.1211010636140.3648@eggly.anvils>

On 11/01/2012 09:41 PM, Hugh Dickins wrote:
> On Wed, 31 Oct 2012, Hugh Dickins wrote:
>> On Wed, 31 Oct 2012, Zhouping Liu wrote:
>>> On 10/31/2012 03:26 PM, Hugh Dickins wrote:
>>>> There's quite a few put_page()s in do_huge_pmd_numa_page(), and it
>>>> would help if we could focus on the one which is giving the trouble,
>>>> but I don't know which that is.  Zhouping, if you can, please would
>>>> you do an "objdump -ld vmlinux >bigfile" of your kernel, then extract
>>>> from bigfile just the lines from "<do_huge_pmd_numa_page>:" to whatever
>>>> is the next function, and post or mail privately just that disassembly.
>>>> That should be good to identify which of the put_page()s is involved.
>>> Hugh, I didn't find the next function, as I can't find any words that matched
>>> "do_huge_pmd_numa_page".
>>> is there any other methods?
>> Hmm, do_huge_pmd_numa_page does appear in your stacktrace,
>> unless I've made a typo but am blind to it.
>>
>> Were you applying objdump to the vmlinux which gave you the
>> BUG at mm/memcontrol.c:1134! ?
> Thanks for the further info you then sent privately: I have not made any
> more effort to reproduce the issue, but your objdump did tell me that the
> put_page hitting the problem is the one on line 872 of mm/huge_memory.c,
> "Drop the local reference", just before successful return after migration.
>
> I didn't really get the inspiration I'd hoped for out of knowing that,
> but it did make wonder whether you're suffering from one of the issues
> I already mentioned, and I can now see a way in which it might cause
> the mm/memcontrol.c:1134 BUG:-
>
> migrate_page_copy() does TestClearPageActive on the source page:
> so given the unsafe way in which do_huge_pmd_numa_page() was proceeding
> with a !PageLRU page, it's quite possible that the page was sitting in
> a pagevec, and added to the active lru (so added to the lru_size of the
> active lru), but our final put_page removes it from lru, active flag has
> been cleared, so we subtract it from the lru_size of the inactive lru -
> that could indeed make it go negative and trigger the BUG.
>
> Here's a patch fixing and tidying up that and a few other things there.
> But I'm not signing it off yet, partly because I've barely tested it
> (quite probably I didn't even have any numa pmd migration happening
> at all), and partly because just a moment ago I ran across this
> instructive comment in __collapse_huge_page_isolate():
> 	/* cannot use mapcount: can't collapse if there's a gup pin */
> 	if (page_count(page) != 1) {
>
> Hmm, yes, below I've added the page_mapcount() check I proposed to
> do_huge_pmd_numa_page(), but is even that safe enough?  Do we actually
> need a page_count() check (for 2?) to guard against get_user_pages()?
> I suspect we do, but then do we have enough locking to stabilize such
> a check?  Probably, but...
>
> This will take more time, and I doubt get_user_pages() is an issue in
> your testing, so please would you try the patch below, to see if it
> does fix the BUGs you are seeing?  Thanks a lot.

Hugh, I have tested the patch for 5 more hours, the issue can't be 
reproduced again,
so I think it has fixed the issue, thank you :)

Zhouping

>
> Not-Yet-Signed-off-by: Hugh Dickins <hughd@google.com>
> ---
>
>   mm/huge_memory.c |   24 +++++++++---------------
>   1 file changed, 9 insertions(+), 15 deletions(-)
>
> --- 3.7-rc2+schednuma+johannes/mm/huge_memory.c	2012-11-01 04:10:43.812155671 -0700
> +++ linux/mm/huge_memory.c	2012-11-01 05:52:19.512153771 -0700
> @@ -745,7 +745,7 @@ void do_huge_pmd_numa_page(struct mm_str
>   	struct mem_cgroup *memcg = NULL;
>   	struct page *new_page = NULL;
>   	struct page *page = NULL;
> -	int node, lru;
> +	int node = -1;
>   
>   	spin_lock(&mm->page_table_lock);
>   	if (unlikely(!pmd_same(*pmd, entry)))
> @@ -762,7 +762,8 @@ void do_huge_pmd_numa_page(struct mm_str
>   		VM_BUG_ON(!PageCompound(page) || !PageHead(page));
>   
>   		get_page(page);
> -		node = mpol_misplaced(page, vma, haddr);
> +		if (page_mapcount(page) == 1)	/* Only do exclusively mapped */
> +			node = mpol_misplaced(page, vma, haddr);
>   		if (node != -1)
>   			goto migrate;
>   	}
> @@ -801,13 +802,11 @@ migrate:
>   	if (!new_page)
>   		goto alloc_fail;
>   
> -	lru = PageLRU(page);
> -
> -	if (lru && isolate_lru_page(page)) /* does an implicit get_page() */
> +	if (isolate_lru_page(page))	/* Does an implicit get_page() */
>   		goto alloc_fail;
>   
> -	if (!trylock_page(new_page))
> -		BUG();
> +	__set_page_locked(new_page);
> +	SetPageSwapBacked(new_page);
>   
>   	/* anon mapping, we can simply copy page->mapping to the new page: */
>   	new_page->mapping = page->mapping;
> @@ -820,8 +819,6 @@ migrate:
>   	spin_lock(&mm->page_table_lock);
>   	if (unlikely(!pmd_same(*pmd, entry))) {
>   		spin_unlock(&mm->page_table_lock);
> -		if (lru)
> -			putback_lru_page(page);
>   
>   		unlock_page(new_page);
>   		ClearPageActive(new_page);	/* Set by migrate_page_copy() */
> @@ -829,6 +826,7 @@ migrate:
>   		put_page(new_page);		/* Free it */
>   
>   		unlock_page(page);
> +		putback_lru_page(page);
>   		put_page(page);			/* Drop the local reference */
>   
>   		return;
> @@ -859,16 +857,12 @@ migrate:
>   	mem_cgroup_end_migration(memcg, page, new_page, true);
>   	spin_unlock(&mm->page_table_lock);
>   
> -	put_page(page);			/* Drop the rmap reference */
> -
>   	task_numa_fault(node, HPAGE_PMD_NR);
>   
> -	if (lru)
> -		put_page(page);		/* drop the LRU isolation reference */
> -
>   	unlock_page(new_page);
> -
>   	unlock_page(page);
> +	put_page(page);			/* Drop the rmap reference */
> +	put_page(page);			/* Drop the LRU isolation reference */
>   	put_page(page);			/* Drop the local reference */
>   
>   	return;
>
> --
> 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>

--
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:[~2012-11-02  3:21 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-25 12:16 [PATCH 00/31] numa/core patches Peter Zijlstra
2012-10-25 12:16 ` [PATCH 01/31] sched, numa, mm: Make find_busiest_queue() a method Peter Zijlstra
2012-10-25 12:16 ` [PATCH 02/31] sched, numa, mm: Describe the NUMA scheduling problem formally Peter Zijlstra
2012-11-01  9:56   ` Mel Gorman
2012-11-01 13:13     ` Rik van Riel
2012-10-25 12:16 ` [PATCH 03/31] mm/thp: Preserve pgprot across huge page split Peter Zijlstra
2012-11-01 10:22   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 04/31] x86/mm: Introduce pte_accessible() Peter Zijlstra
2012-10-25 20:10   ` Linus Torvalds
2012-10-26  6:24     ` [PATCH 04/31, v2] " Ingo Molnar
2012-11-01 10:42   ` [PATCH 04/31] " Mel Gorman
2012-10-25 12:16 ` [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags() Peter Zijlstra
2012-10-25 20:17   ` Linus Torvalds
2012-10-26  2:30     ` Rik van Riel
2012-10-26  2:56       ` Linus Torvalds
2012-10-26  3:57         ` Rik van Riel
2012-10-26  4:23           ` Linus Torvalds
2012-10-26  6:42             ` Ingo Molnar
2012-10-26 12:34             ` Michel Lespinasse
2012-10-26 12:48               ` Andi Kleen
2012-10-26 13:16                 ` Rik van Riel
2012-10-26 13:26                   ` Ingo Molnar
2012-10-26 13:28                     ` Ingo Molnar
2012-10-26 18:44                     ` [PATCH 1/3] x86/mm: only do a local TLB flush in ptep_set_access_flags() Rik van Riel
2012-10-26 18:49                       ` Linus Torvalds
2012-10-26 19:16                         ` Rik van Riel
2012-10-26 19:18                           ` Linus Torvalds
2012-10-26 19:21                             ` Rik van Riel
2012-10-29 15:23                             ` Rik van Riel
2012-12-21  9:57                               ` trailing flush_tlb_fix_spurious_fault in handle_pte_fault (was Re: [PATCH 1/3] x86/mm: only do a local TLB flush in ptep_set_access_flags()) Vineet Gupta
2012-10-26 18:45                     ` [PATCH 2/3] x86,mm: drop TLB flush from ptep_set_access_flags Rik van Riel
2012-10-26 21:12                       ` Alan Cox
2012-10-27  3:49                         ` Rik van Riel
2012-10-27 10:29                           ` Ingo Molnar
2012-10-27 13:40                         ` Rik van Riel
2012-10-29 16:57                           ` Borislav Petkov
2012-10-29 17:06                             ` Linus Torvalds
2012-11-17 14:50                               ` Borislav Petkov
2012-11-17 14:56                                 ` Linus Torvalds
2012-11-17 15:17                                   ` Borislav Petkov
2012-11-17 15:24                                   ` Rik van Riel
2012-11-17 21:53                                     ` Shentino
2012-11-18 15:29                                       ` Michel Lespinasse
2012-10-26 18:46                     ` [PATCH 3/3] mm,generic: only flush the local TLB in ptep_set_access_flags Rik van Riel
2012-10-26 18:48                       ` Linus Torvalds
2012-10-26 18:53                         ` Linus Torvalds
2012-10-26 18:57                         ` Rik van Riel
2012-10-26 19:16                           ` Linus Torvalds
2012-10-26 19:33                             ` [PATCH -v2 " Rik van Riel
2012-10-26 13:23                 ` [PATCH 05/31] x86/mm: Reduce tlb flushes from ptep_set_access_flags() Michel Lespinasse
2012-10-26 17:01               ` Linus Torvalds
2012-10-26 17:54                 ` Rik van Riel
2012-10-26 18:02                   ` Linus Torvalds
2012-10-26 18:14                     ` Rik van Riel
2012-10-26 18:41                       ` Linus Torvalds
2012-10-25 12:16 ` [PATCH 06/31] mm: Only flush the TLB when clearing an accessible pte Peter Zijlstra
2012-10-25 12:16 ` [PATCH 07/31] sched, numa, mm, s390/thp: Implement pmd_pgprot() for s390 Peter Zijlstra
2012-11-01 10:49   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 08/31] sched, numa, mm, MIPS/thp: Add pmd_pgprot() implementation Peter Zijlstra
2012-10-25 12:16 ` [PATCH 09/31] mm/pgprot: Move the pgprot_modify() fallback definition to mm.h Peter Zijlstra
2012-10-25 12:16 ` [PATCH 10/31] mm/mpol: Remove NUMA_INTERLEAVE_HIT Peter Zijlstra
2012-10-25 20:58   ` Andi Kleen
2012-10-26  7:59     ` Ingo Molnar
2012-10-25 12:16 ` [PATCH 11/31] mm/mpol: Make MPOL_LOCAL a real policy Peter Zijlstra
2012-11-01 10:58   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 12/31] mm/mpol: Add MPOL_MF_NOOP Peter Zijlstra
2012-11-01 11:10   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 13/31] mm/mpol: Check for misplaced page Peter Zijlstra
2012-10-25 12:16 ` [PATCH 14/31] mm/mpol: Create special PROT_NONE infrastructure Peter Zijlstra
2012-11-01 11:51   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 15/31] mm/mpol: Add MPOL_MF_LAZY Peter Zijlstra
2012-11-01 12:01   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 16/31] numa, mm: Support NUMA hinting page faults from gup/gup_fast Peter Zijlstra
2012-10-25 12:16 ` [PATCH 17/31] mm/migrate: Introduce migrate_misplaced_page() Peter Zijlstra
2012-11-01 12:20   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 18/31] mm/mpol: Use special PROT_NONE to migrate pages Peter Zijlstra
2012-10-25 12:16 ` [PATCH 19/31] sched, numa, mm: Introduce tsk_home_node() Peter Zijlstra
2012-11-01 13:48   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 20/31] sched, numa, mm/mpol: Make mempolicy home-node aware Peter Zijlstra
2012-11-01 13:58   ` Mel Gorman
2012-11-01 14:10     ` Don Morris
2012-10-25 12:16 ` [PATCH 21/31] sched, numa, mm: Introduce sched_feat_numa() Peter Zijlstra
2012-11-01 14:00   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 22/31] sched, numa, mm: Implement THP migration Peter Zijlstra
2012-11-01 14:16   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 23/31] sched, numa, mm: Implement home-node awareness Peter Zijlstra
2012-11-01 15:06   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 24/31] sched, numa, mm: Introduce last_nid in the pageframe Peter Zijlstra
2012-11-01 15:17   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 25/31] sched, numa, mm/mpol: Add_MPOL_F_HOME Peter Zijlstra
2012-10-25 12:16 ` [PATCH 26/31] sched, numa, mm: Add fault driven placement and migration policy Peter Zijlstra
2012-10-25 20:53   ` Linus Torvalds
2012-10-26  7:15     ` Ingo Molnar
2012-10-26 13:50       ` Ingo Molnar
2012-10-26 14:11         ` Peter Zijlstra
2012-10-26 14:14           ` Ingo Molnar
2012-10-26 16:47             ` Linus Torvalds
2012-10-30 19:23   ` Rik van Riel
2012-11-01 15:40   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 27/31] sched, numa, mm: Add credits for NUMA placement Peter Zijlstra
2012-10-25 12:16 ` [PATCH 28/31] sched, numa, mm: Implement constant, per task Working Set Sampling (WSS) rate Peter Zijlstra
2012-11-01 15:48   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 29/31] sched, numa, mm: Add NUMA_MIGRATION feature flag Peter Zijlstra
2012-10-25 12:16 ` [PATCH 30/31] sched, numa, mm: Implement slow start for working set sampling Peter Zijlstra
2012-11-01 15:52   ` Mel Gorman
2012-10-25 12:16 ` [PATCH 31/31] sched, numa, mm: Add memcg support to do_huge_pmd_numa_page() Peter Zijlstra
2012-10-26  9:07 ` [PATCH 00/31] numa/core patches Zhouping Liu
2012-10-26  9:08   ` Peter Zijlstra
2012-10-26  9:20     ` Ingo Molnar
2012-10-26  9:41       ` Zhouping Liu
2012-10-26 10:20       ` Zhouping Liu
2012-10-26 10:24         ` Ingo Molnar
2012-10-28 17:56     ` Johannes Weiner
2012-10-29  2:44       ` Zhouping Liu
2012-10-29  6:50         ` [PATCH] sched, numa, mm: Add memcg support to do_huge_pmd_numa_page() Ingo Molnar
2012-10-29  8:24           ` Johannes Weiner
2012-10-29  8:36             ` Zhouping Liu
2012-10-29 11:15             ` Ingo Molnar
2012-10-30  6:29       ` [PATCH 00/31] numa/core patches Zhouping Liu
2012-10-31  0:48         ` Johannes Weiner
2012-10-31  7:26           ` Hugh Dickins
2012-10-31 13:15             ` Zhouping Liu
2012-10-31 17:31               ` Hugh Dickins
2012-11-01 13:41                 ` Hugh Dickins
2012-11-02  3:23                   ` Zhouping Liu [this message]
2012-11-02 23:06                     ` Hugh Dickins
2012-10-30 12:20 ` Mel Gorman
2012-10-30 15:28   ` Andrew Morton
2012-10-30 16:59     ` Mel Gorman
2012-11-03 11:04   ` Alex Shi
2012-11-03 12:21     ` Mel Gorman
2012-11-10  2:47       ` Alex Shi
2012-11-12  9:50         ` Mel Gorman
2012-11-09  8:51   ` Rik van Riel
2012-11-05 17:11 ` Srikar Dronamraju

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=50933CB6.6000909@redhat.com \
    --to=zliu@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=aarcange@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=caiqian@redhat.com \
    --cc=hannes@cmpxchg.org \
    --cc=hughd@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mgorman@suse.de \
    --cc=mingo@kernel.org \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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).