init_slice_boundary() was meant to find 2 neighbour slices,
which are both free. It's not needed to have 2 completely
free slices as the test needs only couple huge pages around
slice boundary.
As part of search in 32bit version it tried to mmap at 0, which
may trigger selinux avc: denied { mmap_zero }.
This patch simplifies search function, so that it tries mmap 2 huge pages
(from each side) around slice boundary. If successful this slice
boundary is used for the rest of test.
Signed-off-by: Jan Stancek <[email protected]>
---
tests/mremap-expand-slice-collision.c | 38 +++++++++++---------------------
1 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/tests/mremap-expand-slice-collision.c
b/tests/mremap-expand-slice-collision.c
index 853f3c3..78c11f2 100644
--- a/tests/mremap-expand-slice-collision.c
+++ b/tests/mremap-expand-slice-collision.c
@@ -36,8 +36,8 @@ long hpage_size, page_size;
void init_slice_boundary(int fd)
{
unsigned long slice_size;
- void *p1, *p2, *heap;
- int slices_ok, i, rc;
+ void *p, *heap;
+ int i, rc;
#if defined(__LP64__) && !defined(__aarch64__)
/* powerpc: 1TB slices starting at 1 TB */
slice_boundary = 0x10000000000;
@@ -52,37 +52,25 @@ void init_slice_boundary(int fd)
heap = malloc(1);
free(heap);
- /* find 2 neighbour slices, which are both free,
+ /* Find 2 neighbour slices with couple huge pages free
+ * around slice boundary.
* 16 is the maximum number of slices (low/high) */
for (i = 0; i < 16-1; i++) {
- slices_ok = 0;
- p1 = mmap((void *)slice_boundary, hpage_size,
- PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0);
- p2 = mmap((void *)(slice_boundary+slice_size), hpage_size,
+ slice_boundary += slice_size;
+ p = mmap((void *)(slice_boundary-2*hpage_size), 4*hpage_size,
PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0);
-
- if (p1 != MAP_FAILED) {
- slices_ok++;
- rc = munmap(p1, hpage_size);
+ if (p == MAP_FAILED) {
+ verbose_printf("can't use slice_boundary: 0x%lx\n",
+ slice_boundary);
+ } else {
+ rc = munmap(p, 4*hpage_size);
if (rc != 0)
FAIL("munmap(p1): %s", strerror(errno));
- }
- if (p2 != MAP_FAILED) {
- slices_ok++;
- rc = munmap(p2, hpage_size);
- if (rc != 0)
- FAIL("munmap(p2): %s", strerror(errno));
- }
-
- slice_boundary += slice_size;
- if (slices_ok == 2)
break;
- else
- verbose_printf("can't use slice_boundary: 0x%lx\n",
- slice_boundary);
+ }
}
- if (slices_ok != 2)
+ if (p == MAP_FAILED)
FAIL("couldn't find 2 free neighbour slices");
verbose_printf("using slice_boundary: 0x%lx\n", slice_boundary);
}
--
1.7.1
------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel