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 <[email protected]>
---
testcases/kernel/mem/vma/vma01.c | 25 ++++++++++++++++++++++++-
1 files changed, 24 insertions(+), 1 deletions(-)
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;
------------------------------------------------------------------------------
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/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list