From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753531Ab2LJMpK (ORCPT ); Mon, 10 Dec 2012 07:45:10 -0500 Received: from mail-bk0-f46.google.com ([209.85.214.46]:51659 "EHLO mail-bk0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753282Ab2LJMpD (ORCPT ); Mon, 10 Dec 2012 07:45:03 -0500 Date: Mon, 10 Dec 2012 13:44:58 +0100 From: Ingo Molnar 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 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> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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);