mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Indan Zupancic" <indan@nul.nu>
To: "Steven Rostedt" <srostedt@redhat.com>
Cc: "Ingo Molnar" <mingo@redhat.com>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix race in ring_buffer_consume(): Replace  ring_buffer_consume and ring_buffer_peek with ring_buffer_get_event
Date: Sun, 11 Jan 2009 10:49:14 +0100 (CET)	[thread overview]
Message-ID: <35454.58.169.129.127.1231667354.squirrel@secure.greenhost.nl> (raw)
In-Reply-To: <1231168176.15476.6.camel@localhost.localdomain>

On Mon, January 5, 2009 16:09, Steven Rostedt wrote:
> I just hate public functions that have flags that can get confusing.
> Looking at code where I see:
>
> 	ring_buffer_get_event(buffer, cpu, ts, 0);
>
> I find it hard to know if the ",0" is correct or should be a ",1"
> instead.

That's what I didn't like about the original patch either.
Sent a new patch against tip doing the above, as well as doing
the same for rb_iter_peek (ignore the first one, see try 2).

Slightly different topic, there are quite a few unused functions,
e.g. ring_buffer_read_page(). Should those be removed until they
are actually used, or are there things in the pipeline that will
use them?

I'm not sure if rb_event_length() is safe as it is, returning -1
for RINGBUF_TYPE_PADDING, for an unsigned return value. That
easily overflows into a low value in e.g. rb_advance_iter().
Wouldn't it be better to return the maximum possible size?

rb_advance_reader() calls rb_get_reader_page() and rb_reader_event(),
but rb_get_event(), which is the only caller of rb_advance_reader,
does that as well, which seems a bit more of the same.

Further, rb_get_reader_page() takes cpu_buffer->lock, but all callers
of rb_get_event() take the cpu_buffer->reader_lock. As rb_get_event()
always calls rb_get_reader_page(), both locks will be taken for each
of those calls. Doesn't that make the cpu_buffer->lock redundant?
Getting rid of it and moving the locking into rb_get_event() would
simplify things (except that ring_buffer_read_page() is a bit funny).

Greetings,

Indan



  parent reply	other threads:[~2009-01-11  9:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-29  3:59 [PATCH] Fix race in ring_buffer_consume() Indan Zupancic
2008-12-29  7:34 ` [PATCH] Fix race in ring_buffer_consume(): Replace ring_buffer_consume and ring_buffer_peek with ring_buffer_get_event Indan Zupancic
2008-12-29 12:24   ` Ingo Molnar
2009-01-01  5:10     ` Indan Zupancic
2009-01-02 22:08       ` Ingo Molnar
2009-01-03 23:55         ` Steven Rostedt
2009-01-05 15:09   ` Steven Rostedt
2009-01-11  8:35     ` [PATCH] Minor cleanups in ring_buffer.c Indan Zupancic
2009-01-11  8:46     ` [PATCH] Minor cleanups in ring_buffer.c, try 2 Indan Zupancic
2009-01-11  9:49     ` Indan Zupancic [this message]
2008-12-29 14:47 ` [PATCH] Fix race in ring_buffer_consume() 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=35454.58.169.129.127.1231667354.squirrel@secure.greenhost.nl \
    --to=indan@nul.nu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=srostedt@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®