All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Thomas <bthomas@virtualiron.com>
To: xen-devel@lists.xensource.com
Subject: page_alloc query
Date: Tue, 06 Mar 2007 17:10:32 -0500	[thread overview]
Message-ID: <45EDE6D8.2040505@virtualiron.com> (raw)

Hi,

The following code is causing some questions.  Perhaps someone could
help explain it...  (xen/common/page_alloc.c)

Why are the zones unsigned ints when they are used as indices ?
The ASSERTS do checks to keep you out of some amount of
trouble, but the loop appears to be able to get you quickly
into trouble by driving the index negative and with a check
that doesn't appear to be effective.

static struct page_info *alloc_heap_pages(
     unsigned int zone_lo, unsigned zone_hi,
     unsigned int cpu, unsigned int order)
{
.
.
.
     ASSERT(zone_lo <= zone_hi);
     ASSERT(zone_hi < NR_ZONES);
.
.
.

         for ( zone = zone_hi; zone >= zone_lo; --zone )
         {
             /* check if target node can support the allocation */
             if ( avail[node] && (avail[node][zone] >= request) )

Has it just been a long day and I'm not reading this correctly ?
The older version of this code didn't appear to operate in this
fashion.  Is a simple change of unsigned -> signed sufficient here ?
(While it has been a long day, and it could be failing neurons,
this code has just crashed recently due to a bad index, so....)

I have to run, and can't fix this right now, so I'll settle for this
query.

Thanks,
-b


-- 
------------------------------------------------------------------------
Ben Thomas                                         Virtual Iron Software
bthomas@virtualiron.com                            Tower 1, Floor 2
978-849-1214                                       900 Chelmsford Street
                                                    Lowell, MA 01851

             reply	other threads:[~2007-03-06 22:10 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-06 22:10 Ben Thomas [this message]
2007-03-07  8:27 ` page_alloc query Keir Fraser
2007-03-07  9:09   ` Jan Beulich
2007-03-07  9:18     ` Jan Beulich
2007-03-07  9:40       ` Keir Fraser

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=45EDE6D8.2040505@virtualiron.com \
    --to=bthomas@virtualiron.com \
    --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.