[LTP] [PATCH 2/2] mm/vma01: create a bighole

Caspar Zhang
2012-06-25T07:33:49Z

[-- Attachment #1: Type: text/plain, Size: 573 bytes --]

There are two mmaps in vma01, sometimes first mmap succeeds while
second mmap might fail due to a small hole (3*ps <= hole < 6*ps)
produced by /etc/ld.so.cache and /etc/libc.so.6, I created a big hole
and then munmap it to make sure both allocations can succeed.

|-3*ps-|
|------|------|------| hole
t p
|======|------| top-down alloc
|------|======| bottom-up alloc

Signed-off-by: Caspar Zhang <caspar@casparzhang.com>
---
testcases/kernel/mem/vma/vma01.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-mm-vma01-create-a-bighole.patch --]
[-- Type: text/x-patch; name="0002-mm-vma01-create-a-bighole.patch", Size: 1440 bytes --]

diff --git a/testcases/kernel/mem/vma/vma01.c b/testcases/kernel/mem/vma/vma01.c
index 16ee078..3d00b97 100644
--- a/testcases/kernel/mem/vma/vma01.c
+++ b/testcases/kernel/mem/vma/vma01.c
@@ -59,12 +59,14 @@ char *TCID = "vma01";
int TST_TOTAL = 1;

static void check_vma(void);
+static void create_bighole(void);
static void *get_end_addr(void *addr_s);
static void check_status(int status);
static void setup(void);
static void cleanup(void);

static unsigned long ps;
+static void *p;

int main(int argc, char **argv)
{
@@ -93,7 +95,8 @@ static void check_vma(void)
int topdown;
void *t, *u, *x;

- t = mmap(NULL, 3*ps, PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ create_bighole();
+ t = mmap(p, 3*ps, PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (t == MAP_FAILED)
tst_brkm(TBROK|TERRNO, cleanup, "mmap");
memset(t, 1, ps);
@@ -140,6 +143,26 @@ static void check_vma(void)
}
}

+static void create_bighole(void)
+{
+ void *t;
+
+ /*
+ * |-3*ps-|
+ * |------|------|------| hole
+ * t p
+ * |======|------| top-down alloc
+ * |------|======| bottom-up alloc
+ */
+ t = mmap(NULL, 9*ps, PROT_WRITE, MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
+ if (t == MAP_FAILED)
+ tst_brkm(TBROK|TERRNO, cleanup, "mmap");
+ memset(t, 'a', ps);
+ p = t + 3*ps;
+ if (munmap(t, 9*ps) == -1)
+ tst_brkm(TBROK|TERRNO, cleanup, "munmap");
+}
+
static void *get_end_addr(void *addr_s)
{
FILE *fp;

[-- Attachment #3: Type: text/plain, Size: 395 bytes --]

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

[-- Attachment #4: Type: text/plain, Size: 155 bytes --]