From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx131.postini.com [74.125.245.131]) by kanga.kvack.org (Postfix) with SMTP id 7DAEB6B005A for ; Mon, 10 Dec 2012 07:45:04 -0500 (EST) Received: by mail-bk0-f41.google.com with SMTP id jg9so1291289bkc.14 for ; Mon, 10 Dec 2012 04:45:02 -0800 (PST) Date: Mon, 10 Dec 2012 13:44:58 +0100 From: Ingo Molnar Subject: [PATCH] sched: Fix task_numa_fault() + KSM crash Message-ID: <20121210124458.GA10252@gmail.com> References: <1354875832-9700-1-git-send-email-mgorman@suse.de> <20121207110113.GB21482@gmail.com> <20121209203630.GC1009@suse.de> <20121210050710.GC22164@linux.vnet.ibm.com> <20121210062857.GA6348@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20121210062857.GA6348@linux.vnet.ibm.com> Sender: owner-linux-mm@kvack.org List-ID: To: Srikar Dronamraju Cc: Peter Zijlstra , Mel Gorman , Andrea Arcangeli , Rik van Riel , Johannes Weiner , Hugh Dickins , Thomas Gleixner , Paul Turner , Hillf Danton , David Rientjes , Lee Schermerhorn , Alex Shi , Aneesh Kumar , Linus Torvalds , Andrew Morton , Linux-MM , LKML Srikar Dronamraju reported that the following assert triggers on his box: kernel BUG at ../kernel/sched/fair.c:2371! Call Trace: [] __do_numa_page+0xde/0x160 [] handle_pte_fault+0x32e/0xcd0 [] ? drop_large_spte+0x30/0x30 [kvm] [] ? kvm_set_spte_hva+0x25/0x30 [kvm] [] handle_mm_fault+0x279/0x760 [] break_ksm+0x74/0xa0 [] break_cow+0xa2/0xb0 [] ksm_scan_thread+0xb5c/0xd50 [] ? wake_up_bit+0x40/0x40 [] ? run_store+0x340/0x340 [] 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 Cc: Linus Torvalds Cc: Andrew Morton Cc: Peter Zijlstra Cc: Andrea Arcangeli Cc: Rik van Riel Cc: Mel Gorman Cc: Hugh Dickins Cc: Thomas Gleixner Signed-off-by: Ingo Molnar --- 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); -- 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: email@kvack.org