LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fix mempolicy's check on a system with memory-less-node take4
@ 2007-02-15  7:32 KAMEZAWA Hiroyuki
  2007-02-15  9:53 ` Andi Kleen
  0 siblings, 1 reply; 2+ messages in thread
From: KAMEZAWA Hiroyuki @ 2007-02-15  7:32 UTC (permalink / raw)
  To: LKML; +Cc: AKPM, Andi Kleen, Christoph Lameter


please ack if O.K.....
-Kame
--
bind_zonelist() can create zero-length zonelist if there is a 
memory-less-node. This patch checks the length of zonelist.
If length is 0, returns -EINVAL.

Changelog: v3 -> v4:
- changes a name of a temporal void* variable as "error_code"
Changelog: v2 -> v3
- removed ambiguous void *pointer usage.
- fixed warnings...misuse of PTR_ERR.
Changelog: v1 -> v2
- avoid extra pgdat scanning....it is not necessary.

tested on ia64/NUMA with memory-less-node.

Signed-Off-By: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>


Index: linux-2.6.20/mm/mempolicy.c
===================================================================
--- linux-2.6.20.orig/mm/mempolicy.c	2007-02-13 15:14:13.000000000 +0900
+++ linux-2.6.20/mm/mempolicy.c	2007-02-15 16:11:17.000000000 +0900
@@ -144,7 +144,7 @@
 	max++;			/* space for zlcache_ptr (see mmzone.h) */
 	zl = kmalloc(sizeof(struct zone *) * max, GFP_KERNEL);
 	if (!zl)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 	zl->zlcache_ptr = NULL;
 	num = 0;
 	/* First put in the highest zones from all nodes, then all the next 
@@ -162,6 +162,10 @@
 			break;
 		k--;
 	}
+	if (num == 0) {
+		kfree(zl);
+		return ERR_PTR(-EINVAL);
+	}
 	zl->zones[num] = NULL;
 	return zl;
 }
@@ -193,9 +197,10 @@
 		break;
 	case MPOL_BIND:
 		policy->v.zonelist = bind_zonelist(nodes);
-		if (policy->v.zonelist == NULL) {
+		if (IS_ERR(policy->v.zonelist)) {
+			void *error_code = policy->v.zonelist;
 			kmem_cache_free(policy_cache, policy);
-			return ERR_PTR(-ENOMEM);
+			return error_code;
 		}
 		break;
 	}
@@ -1667,7 +1672,7 @@
 		 * then zonelist_policy() will "FALL THROUGH" to MPOL_DEFAULT.
 		 */
 
-		if (zonelist) {
+		if (!IS_ERR(zonelist)) {
 			/* Good - got mem - substitute new zonelist */
 			kfree(pol->v.zonelist);
 			pol->v.zonelist = zonelist;


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] fix mempolicy's check on a system with memory-less-node take4
  2007-02-15  7:32 [PATCH] fix mempolicy's check on a system with memory-less-node take4 KAMEZAWA Hiroyuki
@ 2007-02-15  9:53 ` Andi Kleen
  0 siblings, 0 replies; 2+ messages in thread
From: Andi Kleen @ 2007-02-15  9:53 UTC (permalink / raw)
  To: KAMEZAWA Hiroyuki; +Cc: LKML, AKPM, Christoph Lameter

On Thursday 15 February 2007 08:32, KAMEZAWA Hiroyuki wrote:
> 
> please ack if O.K.....

Ok for me

-Andi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-02-15  9:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-15  7:32 [PATCH] fix mempolicy's check on a system with memory-less-node take4 KAMEZAWA Hiroyuki
2007-02-15  9:53 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).