mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Helight.Xu" <helight.xu@gmail.com>
Cc: Li Zefan <lizf@cn.fujitsu.com>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	Frederic Weisbecker <fweisbec@gmail.com>
Subject: Re: [PATCH V2] fix a warning on kernel/trace/trace_branch.c and trace_hw_branches.c
Date: Wed, 07 Oct 2009 09:46:20 -0400	[thread overview]
Message-ID: <1254923180.1696.138.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <4ACC7E35.4050001@gmail.com>

On Wed, 2009-10-07 at 19:40 +0800, Helight.Xu wrote:
> Li Zefan wrote:
> > Zhenwen Xu wrote:
> >   
> >> fix warnings that caused the API change of trace_buffer_lock_reserve()
> >> change files: kernel/trace/trace_hw_branch.c
> >> 	      kernel/trace/trace_branch.c
> >>
> >>     
> >
> > Hmm, did you really compile trace_hw_branch.c while testing
> > this patch?
> >
> > This change is necessary too:
> >
> > -	trace_buffer_unlock_commit(tr, event, 0, 0);
> > +	trace_buffer_unlock_commit(tr->buffer, event, 0, 0);
> >
> > And use a varaible "buffer = tr->buffer" should be better.
> >   
> oh!   sorry for my careless!
> >   
> >> Signed-off-by: Zhenwen Xu <helight.xu@gmail.com>
> >> ---
> >>  kernel/trace/trace_branch.c      |    2 +-
> >>  kernel/trace/trace_hw_branches.c |    2 +-
> >>  2 files changed, 2 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/kernel/trace/trace_branch.c b/kernel/trace/trace_branch.c
> >> index 7a7a9fd..216e2dd 100644
> >> --- a/kernel/trace/trace_branch.c
> >> +++ b/kernel/trace/trace_branch.c
> >> @@ -54,7 +54,7 @@ probe_likely_condition(struct ftrace_branch_data *f, int val, int expect)
> >>  		goto out;
> >>  
> >>  	pc = preempt_count();
> >> -	event = trace_buffer_lock_reserve(tr, TRACE_BRANCH,
> >> +	event = trace_buffer_lock_reserve(tr->buffer, TRACE_BRANCH,
> >>  					  sizeof(*entry), flags, pc);

Also, You should not pass in the buffer directly. This is because the
tr->buffer can change, and if it changes between the reserve and commit,
then you can corrupt the ring buffer.

What you want to do is:

	struct ring_buffer *buffer = tr->buffer;

	event = trace_buffer_lock_reserve(buffer, TRACE_BRANCH ...)

[...]

	ring_buffer_unlock_commit(buffer, ...)


-- Steve

> >>  	if (!event)
> >>  		goto out;
> >> diff --git a/kernel/trace/trace_hw_branches.c b/kernel/trace/trace_hw_branches.c
> >> index 23b6385..1cc17ca 100644
> >> --- a/kernel/trace/trace_hw_branches.c
> >> +++ b/kernel/trace/trace_hw_branches.c
> >> @@ -180,7 +180,7 @@ void trace_hw_branch(u64 from, u64 to)
> >>  	if (atomic_inc_return(&tr->data[cpu]->disabled) != 1)
> >>  		goto out;
> >>  
> >> -	event = trace_buffer_lock_reserve(tr, TRACE_HW_BRANCHES,
> >> +	event = trace_buffer_lock_reserve(tr->buffer, TRACE_HW_BRANCHES,
> >>  					  sizeof(*entry), 0, 0);
> >>  	if (!event)
> >>  		goto out;
> >>     
> >
> >   
> 
> 


      reply	other threads:[~2009-10-07 13:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-07  8:19 Zhenwen Xu
2009-10-07  8:53 ` Li Zefan
2009-10-07 11:40   ` Helight.Xu
2009-10-07 13:46     ` Steven Rostedt [this message]

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=1254923180.1696.138.camel@gandalf.stny.rr.com \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=helight.xu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@redhat.com \
    /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®