public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Tom Zanussi <tzanussi@gmail.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <srostedt@redhat.com>
Subject: Re: [PATCH 3/4] ring-buffer: add ring_buffer_discard_commit
Date: Wed, 1 Apr 2009 22:48:14 -0700	[thread overview]
Message-ID: <20090401224814.a1c533ba.akpm@linux-foundation.org> (raw)
In-Reply-To: <20090402053522.594497414@goodmis.org>

On Thu, 02 Apr 2009 01:27:24 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:

> From: Steven Rostedt <srostedt@redhat.com>
> 
> The ring_buffer_discard_commit is similar to ring_buffer_event_discard
> but it can only be done on an event that has yet to be commited.
> Unpredictable results can happen otherwise.
> 
> The main difference between ring_buffer_discard_commit and
> ring_buffer_event_discard is that ring_buffer_discard_commit will try
> to free the data in the ring buffer if nothing has addded data
> after the reserved event. If something did, then it acts almost the
> same as ring_buffer_event_discard followed by a
> ring_buffer_unlock_commit.
> 
> Note, either ring_buffer_commit_discard and ring_buffer_unlock_commit
> can be called on an event, not both.
> 
> This commit also exports both discard functions to be usable by
> GPL modules.
> 
> ...
>
> +/*
> + * ring_buffer_event_discard can discard any event in the ring buffer.
> + *   it is up to the caller to protect against a reader from
> + *   consuming it or a writer from wrapping and replacing it.
> + *
> + * No external protection is needed if this is called before
> + * the event is commited. But in that case it would be better to
> + * use ring_buffer_discard_commit.
> + *
> + * Note, if an event that has not been committed is discarded
> + * with ring_buffer_event_discard, it must still be committed.
> + */
>  void ring_buffer_event_discard(struct ring_buffer_event *event);
>  
> ...
>
>  /**
> + * ring_buffer_event_discard - discard any event in the ring buffer
> + * @event: the event to discard
> + *
> + * Sometimes a event that is in the ring buffer needs to be ignored.
> + * This function lets the user discard an event in the ring buffer
> + * and then that event will not be read later.
> + *
> + * Note, it is up to the user to be careful with this, and protect
> + * against races. If the user discards an event that has been consumed
> + * it is possible that it could corrupt the ring buffer.
> + */
> +void ring_buffer_event_discard(struct ring_buffer_event *event)
> +{
> +	event->type = RINGBUF_TYPE_PADDING;
> +	/* time delta must be non zero */
> +	if (!event->time_delta)
> +		event->time_delta = 1;
> +}
> +EXPORT_SYMBOL_GPL(ring_buffer_event_discard);

Seems a bit cumbersome to document the interface partly in the .h file
and partly in the .c file?

Doing all of it in the .c file would be typical.

  reply	other threads:[~2009-04-02  5:53 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-02  5:27 [PATCH 0/4] [GIT PULL] for tip/tracing/filters Steven Rostedt
2009-04-02  5:27 ` Steven Rostedt
2009-04-02  5:27 ` [PATCH 1/4] tracing/filters: add run-time field descriptions to TRACE_EVENT_FORMAT events Steven Rostedt
2009-04-02 12:17   ` Frederic Weisbecker
2009-04-02  5:27 ` [PATCH 2/4] tracing/filters: add TRACE_EVENT_FORMAT_NOFILTER event macro Steven Rostedt
2009-04-02  5:27 ` [PATCH 3/4] ring-buffer: add ring_buffer_discard_commit Steven Rostedt
2009-04-02  5:48   ` Andrew Morton [this message]
2009-04-02 13:08     ` Steven Rostedt
2009-04-02  5:27 ` [PATCH 4/4] tracing/filters: use ring_buffer_discard_commit for discarded events Steven Rostedt
2009-04-02  9:06   ` Tom Zanussi
2009-04-02 15:01     ` Steven Rostedt
2009-04-03 11:51       ` Ingo Molnar
2009-04-04  1:11         ` Steven Rostedt
2009-04-07  5:46       ` Tom Zanussi
2009-04-07  9:24         ` Steven Rostedt
2009-04-02  5:37 ` [PATCH 0/4] [GIT PULL] for tip/tracing/filters Steven Rostedt
2009-04-03 12:14 ` Ingo Molnar
2009-04-03 14:36   ` Steven Rostedt
2009-04-04  6:50     ` Tom Zanussi
2009-04-04 15:42       ` Steven Rostedt
2009-04-05  7:52         ` Tom Zanussi
2009-04-05 14:47         ` Ingo Molnar

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=20090401224814.a1c533ba.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=tzanussi@gmail.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