From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752621AbZA3LoH (ORCPT ); Fri, 30 Jan 2009 06:44:07 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752852AbZA3Lnk (ORCPT ); Fri, 30 Jan 2009 06:43:40 -0500 Received: from www.tglx.de ([62.245.132.106]:40329 "EHLO www.tglx.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752621AbZA3Lnj (ORCPT ); Fri, 30 Jan 2009 06:43:39 -0500 Message-Id: <20090130114306.687072457@linutronix.de> User-Agent: quilt/0.47-1 Date: Fri, 30 Jan 2009 11:43:28 -0000 From: Thomas Gleixner To: LKML Cc: Steven Rostedt , Carsten Emde Subject: [patch-rt 1/5] commit 42ef73fe134732b2e91c0326df5fd568da17c4b2 Author: Peter Zijlstra Date: Fri Jan 23 17:37:49 2009 +0100 References: <20090130114230.100052140@linutronix.de> Content-Disposition: inline; filename=x86-mm-fix-pte-free.patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org x86, mm: fix pte_free() On -rt we were seeing spurious bad page states like: Bad page state in process 'firefox' page:c1bc2380 flags:0x40000000 mapping:c1bc2390 mapcount:0 count:0 Trying to fix it up, but a reboot is needed Backtrace: Pid: 503, comm: firefox Not tainted 2.6.26.8-rt13 #3 [] ? printk+0x14/0x19 [] bad_page+0x4e/0x79 [] free_hot_cold_page+0x5b/0x1d3 [] free_hot_page+0xf/0x11 [] __free_pages+0x20/0x2b [] __pte_alloc+0x87/0x91 [] handle_mm_fault+0xe4/0x733 [] ? rt_mutex_down_read_trylock+0x57/0x63 [] ? rt_mutex_down_read_trylock+0x57/0x63 [] do_page_fault+0x36f/0x88a This is the case where a concurrent fault already installed the PTE and we get to free the newly allocated one. This is due to pgtable_page_ctor() doing the spin_lock_init(&page->ptl) which is overlaid with the {private, mapping} struct. union { struct { unsigned long private; struct address_space *mapping; }; spinlock_t ptl; struct kmem_cache *slab; struct page *first_page; }; Normally the spinlock is small enough to not stomp on page->mapping, but PREEMPT_RT=y has huge 'spin'locks. But lockdep kernels should also be able to trigger this splat, as the lock tracking code grows the spinlock to cover page->mapping. The obvious fix is calling pgtable_page_dtor() like the regular pte free path __pte_free_tlb() does. It seems all architectures except x86 and nm10300 already do this, and nm10300 doesn't seem to use pgtable_page_ctor(), which suggests it doesn't do SMP or simply doesnt do MMU at all or something. Signed-off-by: Peter Zijlstra Signed-off-by: Ingo Molnar Cc: --- include/asm-x86/pgalloc.h | 1 + 1 file changed, 1 insertion(+) Index: linux-2.6.26.8/include/asm-x86/pgalloc.h =================================================================== --- linux-2.6.26.8.orig/include/asm-x86/pgalloc.h +++ linux-2.6.26.8/include/asm-x86/pgalloc.h @@ -38,6 +38,7 @@ static inline void pte_free_kernel(struc static inline void pte_free(struct mm_struct *mm, struct page *pte) { + pgtable_page_dtor(pte); __free_page(pte); }