linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Zhang, Di" <di.zhang@intel.com>
To: "linux-mm@kvack.org" <linux-mm@kvack.org>
Cc: "Tu, Xiaobing" <xiaobing.tu@intel.com>
Subject: [PATCH] x86/mm: move WARN after pgd synced in vmalloc_fault
Date: Tue, 14 May 2013 02:03:24 +0000	[thread overview]
Message-ID: <460540DE12BFB64696D05F1149972ECD01568DF0@SHSMSX102.ccr.corp.intel.com> (raw)

From: Zhang Di <di.zhang@intel.com>
Date: Tue, 14 May 2013 09:46:36 +0800
Subject: [PATCH] x86/mm: move WARN after pgd synced in vmalloc_fault

Kernel panic is seen after running "perf record -a -g".
The scenario is:
do_nmi->perf_event_nmi_handler->perf_callchain_kernel->dump_trace->
__kernel_text_address->__module_address->within_module_core
/*here page fault happened on mod->module_core since the module pgd
hasn't be synced to the thread's pgd*/
->do_page_fault->vmalloc_fault->WARN_ON_ONCE(in_nmi())
/*notice we are in nmi*/
->warn_slowpath_common->print_modules
/*here page fault happened again when accessing the modules*/
->do_page_fault->vmalloc_fault->WARN_ON_ONCE(in_nmi())
/*notice we are in nmi*/
->warn_slowpath_common->print_modules
/*here page fault happened again when accessing the modules*/
... ...

So it is trapped in this infinite loop until the kernel stack overflowed
and then panics.

The solution is moving WARN_ON_ONCE(in_nmi()) later after the pgd synced,
so there won't be this kind of dead loop.

Signed-off-by: Zhang Di <di.zhang@intel.com>
---
 arch/x86/mm/fault.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
index 654be4a..6864c3b 100644
--- a/arch/x86/mm/fault.c
+++ b/arch/x86/mm/fault.c
@@ -268,8 +268,6 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
 	if (!(address >= VMALLOC_START && address < VMALLOC_END))
 		return -1;
 
-	WARN_ON_ONCE(in_nmi());
-
 	/*
 	 * Synchronize this task's top level page-table
 	 * with the 'reference' page table.
@@ -279,6 +277,9 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
 	 */
 	pgd_paddr = read_cr3();
 	pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
+
+	WARN_ON_ONCE(in_nmi());
+
 	if (!pmd_k)
 		return -1;
 
-- 
1.7.5.4

--
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:[~2013-05-14  2:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=460540DE12BFB64696D05F1149972ECD01568DF0@SHSMSX102.ccr.corp.intel.com \
    --to=di.zhang@intel.com \
    --cc=linux-mm@kvack.org \
    --cc=xiaobing.tu@intel.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