From: Steven Rostedt <rostedt@goodmis.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Andy Lutomirski <luto@kernel.org>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH] tracing: Choose static tp_printk buffer by explicit nesting count
Date: Wed, 25 May 2016 09:36:04 -0400 [thread overview]
Message-ID: <20160525093604.3dc597a5@gandalf.local.home> (raw)
In-Reply-To: <20160525131640.GG3192@twins.programming.kicks-ass.net>
On Wed, 25 May 2016 15:16:40 +0200
Peter Zijlstra <peterz@infradead.org> wrote:
> > static char *get_trace_buf(void)
> > {
> > + struct trace_buffer_struct *buffer = this_cpu_ptr(trace_percpu_buffer);
> >
> > + if (!buffer || buffer->nesting >= 4)
> > return NULL;
>
> This is buggy fwiw; you need to unconditionally increment
> buffer->nesting to match the unconditional decrement.
>
> Otherwise 5 'increments' and 5 decrements will land you at -1.
As I said, I did a quick look and haven't reviewed it.
Peter, thanks for looking at it.
>
> >
> > + return &buffer->buffer[buffer->nesting++][0];
> > +}
> > +
> > +static void put_trace_buf(void)
> > +{
> > + this_cpu_dec(trace_percpu_buffer->nesting);
> > }
>
> So I don't know about tracing; but for perf this construct would not
> work 'properly'.
>
> The per context counter -- which is lost in this scheme -- guards
> against in-context recursion.
>
> Only if we nest from another context do we allow generation of a new
> event.
The ring buffer itself has a context check, where if you try to record
another event nested in the same context, it will simply return NULL.
But this buffer is only used for trace_printk() to manipulate a printf
format. It writes into here first, and then copies it into the tracing
ring buffer. If it happens at a nested event within the same context,
then trace_buffer_lock_reserve() will return NULL and the event wont be
recorded.
-- Steve
next prev parent reply other threads:[~2016-05-25 13:36 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 22:52 Andy Lutomirski
2016-05-24 23:02 ` Steven Rostedt
2016-05-25 13:16 ` Peter Zijlstra
2016-05-25 13:36 ` Steven Rostedt [this message]
2016-05-25 17:59 ` Peter Zijlstra
2016-05-25 20:17 ` Andy Lutomirski
2016-05-25 13:20 ` Namhyung Kim
2016-05-25 20:18 ` Andy Lutomirski
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=20160525093604.3dc597a5@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
/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®