mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: "Petr Mládek" <pmladek@suse.cz>
Cc: linux-kernel@vger.kernel.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Jiri Kosina <jkosina@suse.cz>, Michal Hocko <mhocko@suse.cz>,
	Jan Kara <jack@suse.cz>, Frederic Weisbecker <fweisbec@gmail.com>,
	Dave Anderson <anderson@redhat.com>,
	"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Konstantin Khlebnikov <koct9i@gmail.com>
Subject: Re: [RFC][PATCH 2/5 v2] tracing: Create seq_buf layer in trace_seq
Date: Fri, 27 Jun 2014 10:19:07 -0400	[thread overview]
Message-ID: <20140627101907.3b2ebe5d@gandalf.local.home> (raw)
In-Reply-To: <20140627134538.GB23205@pathway.suse.cz>

On Fri, 27 Jun 2014 15:45:38 +0200
Petr Mládek <pmladek@suse.cz> wrote:

> On Thu 2014-06-26 17:49:03, Steven Rostedt wrote:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > 
> > Create a seq_buf layer that trace_seq sits on. The seq_buf will not
> > be limited to page size. This will allow other usages of seq_buf
> > instead of a hard set PAGE_SIZE one that trace_seq has.
> >
> > Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> > ---
> >  include/linux/seq_buf.h              |  58 ++++++
> >  include/linux/trace_seq.h            |  10 +-
> >  kernel/trace/Makefile                |   1 +
> >  kernel/trace/seq_buf.c               | 348 +++++++++++++++++++++++++++++++++++
> >  kernel/trace/trace.c                 |  39 ++--
> >  kernel/trace/trace_events.c          |   6 +-
> >  kernel/trace/trace_functions_graph.c |   6 +-
> >  kernel/trace/trace_seq.c             | 184 +++++++++---------
> >  8 files changed, 527 insertions(+), 125 deletions(-)
> >  create mode 100644 include/linux/seq_buf.h
> >  create mode 100644 kernel/trace/seq_buf.c
> 
> There is a lot of similar code in the two layers. Do you have any
> plans to transform the trace stuff to seq_buf and get rid of the
> trace_seq layer in long term?
> 
> If I get it correctly, the two layers are needed because:
> 
>    1. seq_buf works with any buffer but
>       trace_seq with static buffer
> 
>    2. seq_buf writes even part of the message until the buffer is full but
>       trace_buf writes only full messages or nothing
> 
>    3. seq_buf returns the number of written characters but
>       trace_seq returns 1 on success and 0 on failure
> 
>    4. seq_buf sets "overflow" flag when an operation failed but
>       trace_seq sets "full" when this happens
> 
> 
> I wounder if we could get a compromise and use only one layer.
> 
> ad 1st:
> 
>    I have checked many locations and it seems that trace_seq_init() is
>    called before the other functions as used. There is the WARN_ON()
>    in the generic seq_buf() functions, so they would not crash. If
>    there is some init missing, we could fix it later.
> 
>    But I haven't really tested it yet.

Actually, there's a few hidden places that initialize a struct with
kzalloc that contains a trace_seq. I started fixing them but there were
more and more to find that I decided to give up and just add the check
to see if it needed to be initialized at each call.

Not that pretty, but not that critical to be worth crashing something
we missed. Maybe in the future this can change, but not now.


> 
> 
> ad 2nd and 3rd:
> 
>    These are connected.
> 
>    On solution is to disable writing part of the text even in the
>    generic seq_buf functions. I think that it is perfectly fine.
>    If we do not print the entire line, we are in troubles anyway.
>    Note that we could not allocate another buffer in NMI, so
>    we will lose part of the message anyway.

This patch uses seq_buf for the NMI code so it will fill to the end of
the buffer and just truncate what can't fit.

trace_pipe depends on the trace_seq behavior.

> 
>    Another solution would be to live with incomplete lines in tracing.
>    I wonder if any of the functions tries to write the line again when the
>    write failed.

This may break trace_pipe. Although there looks to be redundant
behavior in that the pipe code also resets the seq.len on partial line,
so maybe it's not an issue.

> 
>    IMHO, the most important thing is that both functions return 0 on
>    failure.

Note, I'm not sure how tightly these two need to be. I'm actually
trying to get trace_seq to be specific to tracing and nothing more.
Have seq_buf be used for all other instances.



> 
> 
> ad 4th:
> 
>    Both "full" and "overflow" flags seems to have the same meaning.
>    For example, trace_seq_printf() sets "full" on failure even
>    when s->seq.len != s->size.

The difference is that the overflow flag is just used for info letting
the user know that it did not fit. The full flag in trace_seq lets you
know that you can not add anything else, even though the new stuff may
fit.

-- Steve

  reply	other threads:[~2014-06-27 14:19 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 21:49 [RFC][PATCH 0/5 v2] x86/nmi: Print all cpu stacks from NMI safely Steven Rostedt
2014-06-26 21:49 ` [RFC][PATCH 1/5 v2] tracing: Add trace_seq_buffer_ptr() helper function Steven Rostedt
2014-06-27  1:06   ` Steven Rostedt
2014-06-27  3:14     ` James Bottomley
2014-07-03 16:03       ` Steven Rostedt
2014-06-27  7:37     ` Paolo Bonzini
2014-06-26 21:49 ` [RFC][PATCH 2/5 v2] tracing: Create seq_buf layer in trace_seq Steven Rostedt
2014-06-27 13:45   ` Petr Mládek
2014-06-27 14:19     ` Steven Rostedt [this message]
2014-06-27 15:18       ` Petr Mládek
2014-06-27 15:39         ` Steven Rostedt
2014-06-27 16:52           ` Petr Mládek
2014-09-26 15:00             ` Steven Rostedt
2014-09-26 16:28               ` Petr Mladek
2014-06-27 14:21     ` Steven Rostedt
2014-06-27 14:56       ` Petr Mládek
2014-06-26 21:49 ` [RFC][PATCH 3/5 v2] seq_buf: Move the seq_buf code to lib/ Steven Rostedt
2014-06-27 13:48   ` Petr Mládek
2014-06-27 14:27     ` Steven Rostedt
2014-06-27 14:39       ` Petr Mládek
2014-06-27 14:44         ` Steven Rostedt
2014-06-26 21:49 ` [RFC][PATCH 4/5 v2] printk: Add per_cpu printk func to allow printk to be diverted Steven Rostedt
2014-06-27 14:20   ` Petr Mládek
2014-06-27 14:39     ` Steven Rostedt
2014-06-27 14:43       ` Petr Mládek
     [not found] ` <20140626220130.764213722@goodmis.org>
2014-06-26 22:51   ` [RFC][PATCH 5/5 v2] x86/nmi: Perform a safe NMI stack trace on all CPUs Steven Rostedt
2014-06-27 14:32   ` Petr Mládek
2014-06-27 14:40     ` Steven Rostedt
2014-08-07  8:41 ` [RFC][PATCH 0/5 v2] x86/nmi: Print all cpu stacks from NMI safely Jiri Kosina
2014-08-08 18:44   ` Steven Rostedt
2014-08-12 14:17     ` Jiri Kosina
2014-09-10  8:08     ` Jiri Kosina
2014-09-10 10:12       ` Jan Kara

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=20140627101907.3b2ebe5d@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=anderson@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=jack@suse.cz \
    --cc=jkosina@suse.cz \
    --cc=koct9i@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhocko@suse.cz \
    --cc=mingo@kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=pmladek@suse.cz \
    --cc=torvalds@linux-foundation.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®