From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756399Ab2LMO2c (ORCPT ); Thu, 13 Dec 2012 09:28:32 -0500 Received: from e34.co.us.ibm.com ([32.97.110.152]:60094 "EHLO e34.co.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755942Ab2LMO23 (ORCPT ); Thu, 13 Dec 2012 09:28:29 -0500 Date: Thu, 13 Dec 2012 19:27:26 +0530 From: Srikar Dronamraju To: Ingo Molnar 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: Re: [PATCH] sched: Fix task_numa_fault() + KSM crash Message-ID: <20121213135726.GE29086@linux.vnet.ibm.com> Reply-To: Srikar Dronamraju 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> <20121210124458.GA10252@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20121210124458.GA10252@gmail.com> User-Agent: Mutt/1.5.20 (2009-06-14) X-Content-Scanned: Fidelis XPS MAILER x-cbid: 12121314-2876-0000-0000-000003177949 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Ingo Molnar [2012-12-10 13:44:58]: > 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. > I do confirm that with this change, I dont see the assert anymore. > 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); >