From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752768AbYJaOA1 (ORCPT ); Fri, 31 Oct 2008 10:00:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751200AbYJaOAM (ORCPT ); Fri, 31 Oct 2008 10:00:12 -0400 Received: from hrndva-omtalb.mail.rr.com ([71.74.56.123]:51147 "EHLO hrndva-omtalb.mail.rr.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbYJaOAL (ORCPT ); Fri, 31 Oct 2008 10:00:11 -0400 Date: Fri, 31 Oct 2008 10:00:09 -0400 (EDT) From: Steven Rostedt X-X-Sender: rostedt@gandalf.stny.rr.com To: Ingo Molnar cc: LKML , Thomas Gleixner , Peter Zijlstra , Linus Torvalds , Andrew Morton Subject: Re: [PATCH -v2] ring-buffer: add paranoid checks for loops In-Reply-To: <20081031093804.GF30317@elte.hu> Message-ID: References: <20081030184552.GC17822@elte.hu> <20081031093804.GF30317@elte.hu> User-Agent: Alpine 1.10 (DEB 962 2008-03-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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