linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <haveblue@us.ibm.com>
To: Chandra Seetharaman <sekharan@us.ibm.com>
Cc: ckrm-tech@lists.sourceforge.net, linux-mm <linux-mm@kvack.org>
Subject: Re: [ckrm-tech] [PATCH 2/6] CKRM: Core framework support
Date: Thu, 07 Apr 2005 17:39:22 -0700	[thread overview]
Message-ID: <1112920762.21749.78.camel@localhost> (raw)
In-Reply-To: <20050402031249.GC23284@chandralinux.beaverton.ibm.com>

xOn Fri, 2005-04-01 at 19:12 -0800, Chandra Seetharaman wrote:
> +struct ckrm_mem_res {
...
> +       struct ckrm_zone ckrm_zone[MAX_NR_ZONES];

 static void
 mem_res_initcls_one(struct ckrm_mem_res *res)
 {
...
+       for_each_zone(zone) {
...
+               res->ckrm_zone[zindex].memcls = res;
+               zindex++;
+       }

MAX_NR_ZONES is actually the max number of *kinds* of zones.  It's the
maximum number of 'struct zones' that a single pg_data_t can have in its
node_zones[] array.  However, each DISCONTIG or NUMA node has one of
these arrays, and that's what for_each_zone() loops over: _all_ of the
system's zones, not just a single node's. See:

#define for_each_zone(zone) \
        for (zone = pgdat_list->node_zones; zone; zone = next_zone(zone))

Thus, the first call to mem_res_initcls_one() on a DISCONTIG or NUMA
system which has a non-node-zero node will overflow that array.

I saw some of this code before, and that's when I asked about the memory
controller's NUMA interaction.  I thought something was wrong, but I
couldn't put my finger on it.

I addition to these overflows, the same issue exists with results from
the page_zonenum() macro.  This badly named macro returns a "unique
identifier" for a node, not its index in its parent pg_data_t's
node_zones[] array (like the code expects).  So, on i386, a page on
node0[ZONE_NORMAL] will have a page_zonenum() of 1, node0[ZONE_HIGHMEM]
will be 2, node1[ZONE_DMA] will be 3, node100[ZONE_NORMAL] will be 301,
etc...

Indexing any array declared array[MAX_NR_ZONES=1] as array[301] is
likely to cause problems pretty fast.

-- Dave

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

  reply	other threads:[~2005-04-08  0:39 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-02  3:12 Chandra Seetharaman
2005-04-08  0:39 ` Dave Hansen [this message]
2005-04-08  1:34   ` [ckrm-tech] " Chandra Seetharaman
2005-05-19  0:32 Chandra Seetharaman
2005-05-20  2:27 ` [ckrm-tech] " KUROSAWA Takahiro
2005-05-20 17:06   ` Chandra Seetharaman
2005-06-24 22:22 Chandra Seetharaman
2005-06-25  7:49 ` [ckrm-tech] " YAMAMOTO Takashi
2005-06-27 20:50   ` Chandra Seetharaman
2005-06-29  1:22     ` YAMAMOTO Takashi
2005-06-30 18:08       ` Chandra Seetharaman
2005-06-30 18:55         ` Dave Hansen
2005-06-30 19:02           ` Chandra Seetharaman

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=1112920762.21749.78.camel@localhost \
    --to=haveblue@us.ibm.com \
    --cc=ckrm-tech@lists.sourceforge.net \
    --cc=linux-mm@kvack.org \
    --cc=sekharan@us.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox