Re: OOM behavior in constrained memory situations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 7 Feb 2006, Andi Kleen wrote:

> Actually looking at it again "v" should be aligned to 4 bytes anyways, so
> there is a unused 2 byte hole that you can use for this.

Ok. Here is the hack you wanted:

Index: linux-2.6.16-rc2/mm/mempolicy.c
===================================================================
--- linux-2.6.16-rc2.orig/mm/mempolicy.c	2006-02-07 10:14:43.000000000 -0800
+++ linux-2.6.16-rc2/mm/mempolicy.c	2006-02-07 10:17:42.000000000 -0800
@@ -162,9 +162,9 @@ static struct mempolicy *mpol_new(int mo
 		return ERR_PTR(-ENOMEM);
 	atomic_set(&policy->refcnt, 1);
 
-	policy->gfp_flags = 0;
+	policy->gfp_flags_high = 0;
 	if (!nodes_equal(*nodes, node_online_map))
-		policy->gfp_flags |= __GFP_NO_OOM_KILLER;
+		policy->gfp_flags_high |= (__GFP_NO_OOM_KILLER >> 16);
 
 	switch (mode) {
 	case MPOL_INTERLEAVE:
@@ -1224,7 +1224,7 @@ alloc_page_vma(gfp_t gfp, struct vm_area
 
 	cpuset_update_task_memory_state();
 
-	gfp |= pol->gfp_flags;
+	gfp |= (pol->gfp_flags_high << 16);
 	if (unlikely(pol->policy == MPOL_INTERLEAVE)) {
 		unsigned nid;
 
@@ -1261,7 +1261,7 @@ struct page *alloc_pages_current(gfp_t g
 		cpuset_update_task_memory_state();
 	if (!pol || in_interrupt())
 		pol = &default_policy;
-	gfp |= pol->gfp_flags;
+	gfp |= (pol->gfp_flags_high << 16);
 	if (pol->policy == MPOL_INTERLEAVE)
 		return alloc_page_interleave(gfp, order, interleave_nodes(pol));
 	return __alloc_pages(gfp, order, zonelist_policy(gfp, pol));
@@ -1598,7 +1598,7 @@ void mpol_rebind_policy(struct mempolicy
 		return;
 
 	if (!nodes_equal(*newmask, node_online_map))
-		pol->gfp_flags |= __GFP_NO_OOM_KILLER;
+		pol->gfp_flags_high |= (__GFP_NO_OOM_KILLER >> 16);
 
 	switch (pol->policy) {
 	case MPOL_DEFAULT:
Index: linux-2.6.16-rc2/include/linux/mempolicy.h
===================================================================
--- linux-2.6.16-rc2.orig/include/linux/mempolicy.h	2006-02-07 10:14:43.000000000 -0800
+++ linux-2.6.16-rc2/include/linux/mempolicy.h	2006-02-07 10:15:39.000000000 -0800
@@ -62,7 +62,7 @@ struct vm_area_struct;
 struct mempolicy {
 	atomic_t refcnt;
 	short policy; 	/* See MPOL_* above */
-	gfp_t gfp_flags;	/* flags ORed into gfp_flags for each allocation */
+	short gfp_flags_high;	/* bits 16-31 ORed into gfp_flags for each allocation */
 	union {
 		struct zonelist  *zonelist;	/* bind */
 		short 		 preferred_node; /* preferred */
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux