Re: [RFC 5/4] mm, page_alloc: fix premature OOM due to vma mempolicy update

From: Vlastimil Babka
Date: Wed Jan 18 2017 - 11:24:43 EST


On 01/18/2017 05:20 PM, Vlastimil Babka wrote:
> By changing the LTP cpuset01 testcase (will post patch as a reply) this was
> confirmed and the problem is also older than the changes in 4.7.

-----8<-----
diff --git a/testcases/kernel/mem/cpuset/cpuset01.c b/testcases/kernel/mem/cpuset/cpuset01.c
index 558420f72f9b..ef673366e15e 100644
--- a/testcases/kernel/mem/cpuset/cpuset01.c
+++ b/testcases/kernel/mem/cpuset/cpuset01.c
@@ -40,6 +40,7 @@
#include <fcntl.h>
#include <math.h>
#if HAVE_NUMAIF_H
+#include <linux/mempolicy.h>
#include <numaif.h>
#endif
#include <signal.h>
@@ -61,6 +62,7 @@ volatile int end;
static int *nodes;
static int nnodes;
static long ncpus;
+static unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };

static void testcpuset(void);
static void sighandler(int signo LTP_ATTRIBUTE_UNUSED);
@@ -89,7 +91,6 @@ static void testcpuset(void)
{
int lc;
int child, i, status;
- unsigned long nmask[MAXNODES / BITS_PER_LONG] = { 0 };
char mems[BUFSIZ], buf[BUFSIZ];

read_cpuset_files(CPATH, "cpus", buf);
@@ -105,6 +106,7 @@ static void testcpuset(void)
for (i = 0; i < nnodes; i++) {
if (nodes[i] >= MAXNODES)
continue;
+ printf("bind to node %d\n", nodes[i]);
set_node(nmask, nodes[i]);
}
if (set_mempolicy(MPOL_BIND, nmask, MAXNODES) == -1)
@@ -163,6 +165,8 @@ static int mem_hog(void)
tst_resm(TFAIL | TERRNO, "mmap");
break;
}
+ if (mbind(addr, pagesize * 10, MPOL_BIND, nmask, MAXNODES, 0) == -1)
+ tst_brkm(TBROK | TERRNO, cleanup, "set_mempolicy");
memset(addr, 0xF7, pagesize * 10);
munmap(addr, pagesize * 10);
}