From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759561AbZDWPIw (ORCPT ); Thu, 23 Apr 2009 11:08:52 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1759473AbZDWPI0 (ORCPT ); Thu, 23 Apr 2009 11:08:26 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:34318 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759517AbZDWPIZ (ORCPT ); Thu, 23 Apr 2009 11:08:25 -0400 Date: Thu, 23 Apr 2009 11:08:22 -0400 (EDT) From: Steven Rostedt X-X-Sender: rostedt@gandalf.stny.rr.com To: Ingo Molnar cc: =?ISO-8859-15?Q?Fr=E9d=E9ric_Weisbecker?= , LKML , Andrew Morton , Glauber de Oliveira Costa , Chris Wright , Jeremy Fitzhardinge , Rusty Russell , Pekka Enberg Subject: Re: [PATCH 0/2] [GIT PULL] tracing: various bug fixes In-Reply-To: Message-ID: References: <20090420222257.267399830@goodmis.org> <20090421082354.GC12512@elte.hu> <20090421094616.GA14561@elte.hu> <20090423082031.GA599@elte.hu> User-Agent: Alpine 2.00 (DEB 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 23 Apr 2009, Steven Rostedt wrote: > > static inline void __native_flush_tlb_global(void) > { > unsigned long flags; > unsigned long cr4; > > /* > * Read-modify-write to CR4 - protect it from preemption and > * from interrupts. (Use the raw variant because this code can > * be called from deep inside debugging code.) > */ > raw_local_irq_save(flags); > > cr4 = read_cr4(); > /* clear PGE */ > write_cr4(cr4 & ~X86_CR4_PGE); > /* write old PGE again and flush TLBs */ > write_cr4(cr4); > > raw_local_irq_restore(flags); > } > > > Each of those read_cr4 and write_cr4 can be traced. But I still do not see > how this can cause corruption in the current task struct. > > The TLB just caches the pages we are using, not the contents inside. I > still do not see how this can corrupt a bit. Unless a register leaked :-/ Ah, this is a lockdep thing. The raw_local_irq_save/restore in __native_flush_tlb_global does not update hardirqs_enabled. When we call into ftrace, when we cross page bounderies, we disable interrupts using the normal local_irq_save/restore calls. But when we restore, it detects that interrupts are not going to be enabled, and keeps hardirqs_enabled off. The printk solved the issue because it called local_irq_restore, which set the variable back. I guess there's two solutions here. One, we can change the raw_local_irq_enable/disable variants in __native_flush_tlb_global to the non-raw type (it should protect against recursion). or we can try to make the ring buffer use the raw_local_irq variants too. I tried this once before, and it did cause issues. Note, there's a "check_flags" in lockdep, but it is only called on locking, it is not called when we only disable/enable interrupts. -- Steve