lkml.org 
[lkml]   [2008]   [Oct]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH -v2] ring-buffer: add paranoid checks for loops

On Fri, 31 Oct 2008, Ingo Molnar 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 ?

Yes, that's because the variable started at 0. So > 2 really means the
loop iterated more than 3.

My last patch changed it to be a bit easier to understand...

if (unlikely(++nr_loops > 3)) {

-- Steve



\
 
 \ /
  Last update: 2008-10-31 15:03    [W:0.048 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site