From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754149AbYJaJif (ORCPT ); Fri, 31 Oct 2008 05:38:35 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753495AbYJaJiX (ORCPT ); Fri, 31 Oct 2008 05:38:23 -0400 Received: from mx2.mail.elte.hu ([157.181.151.9]:51864 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752028AbYJaJiW (ORCPT ); Fri, 31 Oct 2008 05:38:22 -0400 Date: Fri, 31 Oct 2008 10:38:04 +0100 From: Ingo Molnar To: Steven Rostedt Cc: LKML , Thomas Gleixner , Peter Zijlstra , Linus Torvalds , Andrew Morton Subject: Re: [PATCH -v2] ring-buffer: add paranoid checks for loops Message-ID: <20081031093804.GF30317@elte.hu> References: <20081030184552.GC17822@elte.hu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.18 (2008-05-17) X-ELTE-VirusStatus: clean X-ELTE-SpamScore: -1.5 X-ELTE-SpamLevel: X-ELTE-SpamCheck: no X-ELTE-SpamVersion: ELTE 2.0 X-ELTE-SpamCheck-Details: score=-1.5 required=5.9 tests=BAYES_00,DNS_FROM_SECURITYSAGE autolearn=no SpamAssassin version=3.2.3 -1.5 BAYES_00 BODY: Bayesian spam probability is 0 to 1% [score: 0.0000] 0.0 DNS_FROM_SECURITYSAGE RBL: Envelope sender in blackholes.securitysage.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org * Steven Rostedt 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