public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Philippe Elie <phil.el@wanadoo.fr>
To: John Levon <levon@movementarian.org>
Cc: Andrew Morton <akpm@osdl.org>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] oprofile per-cpu buffer overrun
Date: Mon, 26 Jan 2004 15:52:11 +0000	[thread overview]
Message-ID: <401537AB.60505@wanadoo.fr> (raw)
In-Reply-To: 20040126103237.GA52771@compsoc.man.ac.uk

John Levon wrote:
> On Sun, Jan 25, 2004 at 08:07:01PM -0800, Andrew Morton wrote:
> 
> 
>>When implementing a circular buffer it is better to not constrain the head
>>and tail indices - just let them grow and wrap without bound.  You only need
>>to bring them in-bounds when you actually use them to index the buffer.

neat!

> I'm not sure why that's better.

We win in increment_head/increment_tail:

static void increment_head(struct oprofile_cpu_buffer * b)
{
- 
unsigned long new_head = b->head_pos + 1;
	wmb();
- 
if (new_head < (b->buffer_size))
- 
	b->head_pos = new_head;
- 
else
- 
	b->head_pos = 0;
+ 
b->head_pos++;
}

for this added cost when accessing the buffer:

b->buffer[b->head & b->buffer_size_mask];

Modulo use is not worth but with buffer_size a power of 2
it's probably a win, I'll try and measure this later, not
urgent since the problem is fixed, I added it in our todo.

regards,
Phil


      parent reply	other threads:[~2004-01-26 14:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-26  2:37 [PATCH] oprofile per-cpu buffer overrun Philippe Elie
2004-01-26  4:07 ` Andrew Morton
2004-01-26  5:56   ` Anton Blanchard
2004-01-26 10:32   ` John Levon
2004-01-26 11:07     ` Nick Piggin
2004-01-26 15:52     ` Philippe Elie [this message]

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=401537AB.60505@wanadoo.fr \
    --to=phil.el@wanadoo.fr \
    --cc=akpm@osdl.org \
    --cc=levon@movementarian.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox