Re: [PATCH V2 4/4] cpuset,mm: update task's mems_allowed lazily

From: David Rientjes
Date: Wed Mar 31 2010 - 06:34:29 EST


On Wed, 31 Mar 2010, Miao Xie wrote:

> diff --git a/mm/mmzone.c b/mm/mmzone.c
> index f5b7d17..43ac21b 100644
> --- a/mm/mmzone.c
> +++ b/mm/mmzone.c
> @@ -58,6 +58,7 @@ struct zoneref *next_zones_zonelist(struct zoneref *z,
> nodemask_t *nodes,
> struct zone **zone)
> {
> + nodemask_t tmp_nodes;
> /*
> * Find the next suitable zone to use for the allocation.
> * Only filter based on nodemask if it's set
> @@ -65,10 +66,16 @@ struct zoneref *next_zones_zonelist(struct zoneref *z,
> if (likely(nodes == NULL))
> while (zonelist_zone_idx(z) > highest_zoneidx)
> z++;
> - else
> - while (zonelist_zone_idx(z) > highest_zoneidx ||
> - (z->zone && !zref_in_nodemask(z, nodes)))
> - z++;
> + else {
> + tmp_nodes = *nodes;
> + if (nodes_empty(tmp_nodes))
> + while (zonelist_zone_idx(z) > highest_zoneidx)
> + z++;
> + else
> + while (zonelist_zone_idx(z) > highest_zoneidx ||
> + (z->zone && !zref_in_nodemask(z, &tmp_nodes)))
> + z++;
> + }
>
> *zone = zonelist_zone(z);
> return z;

Unfortunately, you can't allocate a nodemask_t on the stack here because
this is used in the iteration for get_page_from_freelist() which can occur
very deep in the stack already and there's a probability of overflow.
Dynamically allocating a nodemask_t simply wouldn't scale here, either,
since it would allocate on every iteration of a zonelist.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/