lkml.org 
[lkml]   [2012]   [Dec]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH] sched: Fix task_numa_fault() + KSM crash
Srikar Dronamraju reported that the following assert triggers on 
his box:

kernel BUG at ../kernel/sched/fair.c:2371!

Call Trace:
[<ffffffff8113cd0e>] __do_numa_page+0xde/0x160
[<ffffffff8113de9e>] handle_pte_fault+0x32e/0xcd0
[<ffffffffa01c22c0>] ? drop_large_spte+0x30/0x30 [kvm]
[<ffffffffa01bf215>] ? kvm_set_spte_hva+0x25/0x30 [kvm]
[<ffffffff8113eab9>] handle_mm_fault+0x279/0x760
[<ffffffff8115c024>] break_ksm+0x74/0xa0
[<ffffffff8115c222>] break_cow+0xa2/0xb0
[<ffffffff8115e38c>] ksm_scan_thread+0xb5c/0xd50
[<ffffffff810771c0>] ? wake_up_bit+0x40/0x40
[<ffffffff8115d830>] ? run_store+0x340/0x340
[<ffffffff8107692e>] kthread+0xce/0xe0

This means that task_numa_fault() was called for a kernel thread
which has no fault tracking.

This scenario is actually possible if a kernel thread does
fault processing on behalf of a user-space task - ignore
the page fault in that case.

Also remove the (now never triggering) assert and robustify
a nearby assert.

Reported-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Rik van Riel <riel@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Hugh Dickins <hughd@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
kernel/sched/fair.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 9d11a8a..61c7a10 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -2351,6 +2351,13 @@ void task_numa_fault(unsigned long addr, int node, int last_cpupid, int pages, b
int priv;
int idx;

+ /*
+ * Kernel threads might not have an mm but might still
+ * do fault processing (such as KSM):
+ */
+ if (!p->numa_faults)
+ return;
+
if (last_cpupid != cpu_pid_to_cpupid(-1, -1)) {
/* Did we access it last time around? */
if (last_pid == this_pid) {
@@ -2367,8 +2374,8 @@ void task_numa_fault(unsigned long addr, int node, int last_cpupid, int pages, b

idx = 2*node + priv;

- WARN_ON_ONCE(last_cpu == -1 || node == -1);
- BUG_ON(!p->numa_faults);
+ if (WARN_ON_ONCE(last_cpu == -1 || node == -1))
+ return;

p->numa_faults_curr[idx] += pages;
shared_fault_tick(p, node, last_cpu, pages);

\
 
 \ /
  Last update: 2012-12-10 14:01    [W:0.114 / U:0.836 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site