From: Ingo Molnar <mingo@elte.hu>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH -v2] ring-buffer: add paranoid checks for loops
Date: Fri, 31 Oct 2008 10:38:04 +0100 [thread overview]
Message-ID: <20081031093804.GF30317@elte.hu> (raw)
In-Reply-To: <alpine.DEB.1.10.0810302314460.26352@gandalf.stny.rr.com>
* Steven Rostedt <rostedt@goodmis.org> wrote:
> + /*
> + * This should normally only loop twice. But because the
> + * start of the reader inserts an empty page, it causes
> + * a case where we will loop three times. There should be no
> + * reason to loop four times (that I know of).
> + */
> + if (unlikely(paranoid > 2)) {
> + RB_WARN_ON(cpu_buffer, 1);
> + reader = NULL;
> + goto out;
> + }
> + paranoid++;
ok, the explanations look nice now.
A small nit - the above comment suggests that looping 4 times is the
anomaly - still the test is for paranoid > 2 ?
> + int paranoid = 0;
another small nit: i'd suggest to rename 'paranoid' to 'nr_loops' or
'nr_iterations' or so. It is the _condition_ that signals paranoia,
not the variable in itself - making the current patch look a bit
weird.
> again:
> + /*
> + * We repeat when a timestamp is encountered. It is possible
> + * to get multiple timestamps from an interrupt entering just
> + * as one timestamp is about to be written. The max times
> + * that this can happen is the number of nested interrupts we
> + * can have. 10 should be more than enough.
> + */
> + if (unlikely(paranoid > 10)) {
> + RB_WARN_ON(cpu_buffer, 1);
> + return NULL;
s/10 should be more than enough/Nesting higher than 10 is clearly
anomalous/
> + /*
> + * We repeat when a timestamp is encountered. It is possible
> + * to get multiple timestamps from an interrupt entering just
> + * as one timestamp is about to be written. The max times
> + * that this can happen is the number of nested interrupts we
> + * can have. 10 should be more than enough.
> + */
> + if (unlikely(paranoid > 10)) {
> + RB_WARN_ON(cpu_buffer, 1);
> + return NULL;
ditto.
Ingo
next prev parent reply other threads:[~2008-10-31 9:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-29 22:48 [PATCH] ring-buffer: add paranoid checks for loops Steven Rostedt
2008-10-30 18:45 ` Ingo Molnar
2008-10-30 19:00 ` Steven Rostedt
2008-10-31 3:16 ` [PATCH -v2] " Steven Rostedt
2008-10-31 9:38 ` Ingo Molnar [this message]
2008-10-31 13:58 ` [PATCH -v3] " Steven Rostedt
2008-11-03 10:10 ` Ingo Molnar
2008-10-31 14:00 ` [PATCH -v2] " 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=20081031093804.GF30317@elte.hu \
--to=mingo@elte.hu \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.