mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Ingo Molnar <mingo@elte.hu>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] tracing/function-return-tracer: don't trace kfree while it frees the return stack
Date: Sun, 23 Nov 2008 14:24:42 -0500 (EST)	[thread overview]
Message-ID: <alpine.DEB.1.10.0811231237470.13888@gandalf.stny.rr.com> (raw)
In-Reply-To: <20081123164013.GC6206@elte.hu>


On Sun, 23 Nov 2008, Ingo Molnar wrote:
> > 
> > diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> > index 90d99fb..ffff7ec 100644
> > --- a/kernel/trace/ftrace.c
> > +++ b/kernel/trace/ftrace.c
> > @@ -1628,8 +1628,9 @@ void ftrace_retfunc_init_task(struct task_struct *t)
> >  
> >  void ftrace_retfunc_exit_task(struct task_struct *t)
> >  {
> > -	kfree(t->ret_stack);
> > +	struct ftrace_ret_stack	*ret_stack = t->ret_stack;
> >  	t->ret_stack = NULL;
> > +	kfree(ret_stack);
> 
> heh, nice one :)
> 
> note that we also need to keep gcc from reordering things here (no 
> matter how unlikely in this particular case).

I first thought that too, but thinking about it, if gcc does do that, then
it will break the logic for a correct C program.

t is passed in as a pointer, then it modifies the contents of t (which 
could be a global pointer), then it calls a external function, that might 
also reference the global pointer.

This means that if it were to reorder the two, it would break C, because 
the compiler can not assume that the called function will read the global 
pointer either.

In other words, the compiler should not need to worry about SMP or 
modifications done by interrupts or other threads. But the compiler should 
always preserve the order that is assumed by a single context.

-- Steve

  parent reply	other threads:[~2008-11-23 19:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-23 16:33 Frederic Weisbecker
2008-11-23 16:40 ` Ingo Molnar
2008-11-23 16:44   ` Ingo Molnar
2008-11-23 17:43     ` Frederic Weisbecker
2008-11-23 19:24   ` Steven Rostedt [this message]
2008-11-23 19:35     ` Ingo Molnar
2008-11-23 19:48       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.1.10.0811231237470.13888@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®