Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755169AbZJVMGQ (ORCPT ); Thu, 22 Oct 2009 08:06:16 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754840AbZJVMGP (ORCPT ); Thu, 22 Oct 2009 08:06:15 -0400 Received: from ey-out-2122.google.com ([74.125.78.25]:58561 "EHLO ey-out-2122.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753334AbZJVMGO (ORCPT ); Thu, 22 Oct 2009 08:06:14 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=mvbmBaAW0yhasbiIaeLmQdYsljbvNmp2SBt4xztUf5OVof/HRpf4L+tQVOVtSYPQOo lr2bU8vDrsWzega4MWKOjTMx22ngJyMIepMl03wHmZ6l2iebPdivmfyTeSrXNmsQffrA VFa5+t+PqrueRfuu1CPyyd0xlxkyIh2Y2n+j0= Date: Thu, 22 Oct 2009 14:06:17 +0200 From: Frederic Weisbecker To: "Leonidas ." Cc: linux-kernel Subject: Re: Can current macro be accessed from interrupt context? Message-ID: <20091022120613.GB4928@nowhere> References: <20091022112746.GA4928@nowhere> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1594 Lines: 39 On Thu, Oct 22, 2009 at 04:43:38AM -0700, Leonidas . wrote: > > Yep. > > For example we do that in the function graph tracer. Because we store return > > addresses of functions in the "current" task structure. Even if the task > > is interrupted, it still makes sense to use current because we want > > to know the flow of execution as a linear thing per cpu, the interrupt > > is part of that flow > > > > I hope that helps. > > > > Can you give pointers to the source code of this project? Yep, it's in kernel/trace/trace_functions_graph.c (with a little part in arch/*/kernel/ftrace.c and arch/*/kernel/entry*.S) and also parts in kernel/trace/ftrace.c We do that from the former file in ftrace_push_return_trace() and ftrace_pop_return_trace() We deref current from whatever context, this part of the code doesn't care about interrupt or process context, and this code can be called from every contexts, since it is tracing 99% of the kernel function calls. We do care about the context in which the trace has been taken while displaying these traces to the user, later, just to inform the user, but this is already post-processing at this stage, even though it's done from the kernel. Anyway, the point is that it's safe to deref current from an irq handler. But whether it makes sense to do that. It depends on what you want to do. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/