All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Harris <greg.harris@metacarta.com>
To: Jens Axboe <jens.axboe@oracle.com>
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	xen-devel <xen-devel@lists.xensource.com>
Subject: Re: Kernel Panic in xen-blkfront.c:blkif_queue_request under 2.6.28
Date: Mon, 2 Feb 2009 09:53:24 -0500 (EST)	[thread overview]
Message-ID: <33412370.8060681233586404023.JavaMail.root@ouachita> (raw)
In-Reply-To: <11750686.8060601233586380769.JavaMail.root@ouachita>

----- "Jens Axboe" <jens.axboe@oracle.com> wrote:

Here is what I'm thinking is happening rewritten for clarity:

#define BLKIF_MAX_SEGMENTS_PER_REQUEST 11 
int array[BLKIF_MAX_SEGMENTS_PER_REQUEST]; 

void write_segments( int number_of_segments )
  int nr_segments = 0;
  for( int x = 0; x < number_of_segments; x++ )
  {
    BUG_ON( nr_segments == BLKIF_MAX_SEGMENTS_PER_REQUEST );
    array[nr_segments] = get_segment_value(nr_segments);
    nr_segments ++ ;
  }
}

The BUG_ON is firing because the index into the number of segments is equal to BLKIF_MAX_SEGMENTS_PER_REQUEST which would require an array size of BLKIF_MAX_SEGMENTS_PER_REQUEST + 1 (more than has actually been allocated).

The kernel is being told that it should happily map up to BLKIF_MAX_SEGMENTS_PER_REQUEST segments which will fit in our array as allocated.  The BUG_ON is correctly firing because in the iteration over the number of segments our index has been incremented to a value that now points outside the boundary of our array.

-- Greg

> 
> > It sounds to me like the kernel itself may not be obeying the
> > requested segment limits here?
> 
> It's quite simple - if you tell the kernel that your segment limit is
> 8,
> then it will happily map up to 8 segments for you. So the mixture of
> setting a limit to foo and check calling BUG() if that limit is
> reached
> is crap, of obvious reasons. If you ask for 8 segments but can only
> hold
> 7, well...
> -- 
> Jens Axboe

       reply	other threads:[~2009-02-02 14:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <11750686.8060601233586380769.JavaMail.root@ouachita>
2009-02-02 14:53 ` Greg Harris [this message]
     [not found]   ` <20090202161425.GK30821@kernel.dk>
2009-02-02 23:30     ` Kernel Panic in xen-blkfront.c:blkif_queue_request under 2.6.28 Jeremy Fitzhardinge
2009-02-03 20:37       ` Greg Harris
2009-02-04 16:50         ` Jeremy Fitzhardinge
     [not found] <24523950.8056631233583862811.JavaMail.root@ouachita>
2009-02-02 14:11 ` Greg Harris
2009-01-30 14:50 Greg Harris
2009-02-02  6:19 ` Jeremy Fitzhardinge

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=33412370.8060681233586404023.JavaMail.root@ouachita \
    --to=greg.harris@metacarta.com \
    --cc=jens.axboe@oracle.com \
    --cc=jeremy@goop.org \
    --cc=xen-devel@lists.xensource.com \
    /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.