The semantics of hugetlb_slice_{start,end} are ... difficult to say the
least. IA64's virtual address limitation makes it difficult to say what
the "correct" behavior is for valid addresses. It is virtually (no pun
intended) impossible to indicate a passed in address is not valid for
hugepage mappings, period, without breaking some other semantics.
The two users of this functionality, currently, morecore and
brk_near_huge, don't even want to know this level of detail. They want
to simply know the next valid hint address for a hugepage mmap(), given
a particular address. This is distinct from where the next slice starts,
as well, so that's not a good fit. Instead, give them exactly what they
want. IA64 is almost the same as all the other archs, then, in that
addresses in the hugepage region are aligned up to the hugepage size.
But if the address is below the hugepage region, we simply return the
start of the region.
Signed-off-by: Nishanth Aravamudan <[EMAIL PROTECTED]>
diff --git a/hugetlbfs.h b/hugetlbfs.h
index be5a352..75d9a82 100644
--- a/hugetlbfs.h
+++ b/hugetlbfs.h
@@ -22,8 +22,7 @@
#define HUGETLBFS_MAGIC 0x958458f6
long gethugepagesize(void);
-unsigned long hugetlbfs_slice_start(unsigned long);
-unsigned long hugetlbfs_slice_end(unsigned long);
+unsigned long next_valid_hugetlb_addr(unsigned long);
int hugetlbfs_test_path(const char *mount);
const char *hugetlbfs_find_path(void);
int hugetlbfs_unlinked_fd(void);
diff --git a/hugeutils.c b/hugeutils.c
index fc220ee..02aa303 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -114,49 +114,15 @@ long gethugepagesize(void)
return hpage_size;
}
-#if defined(__powerpc64__) || defined (__powerpc__)
-#define SLICE_LOW_SHIFT 28
-#define SLICE_HIGH_SHIFT 40
-
-#define SLICE_LOW_TOP (0x100000000UL)
-#define SLICE_LOW_SIZE (1UL << SLICE_LOW_SHIFT)
-#define SLICE_HIGH_SIZE (1UL << SLICE_HIGH_SHIFT)
-#endif
-
-/*
- * Return the address of the start and end of the hugetlb slice
- * containing @addr. A slice is a range of addresses, start inclusive
- * and end exclusive.
- */
-unsigned long hugetlbfs_slice_start(unsigned long addr) {
-#if defined(__powerpc64__)
- if (addr < SLICE_LOW_TOP)
- return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
- else if (addr < SLICE_HIGH_SIZE)
- return SLICE_LOW_TOP;
- else
- return ALIGN_DOWN(addr, SLICE_HIGH_SIZE);
-#elif defined(__powerpc__)
- return ALIGN_DOWN(addr, SLICE_LOW_SIZE);
-#elif defined(__ia64__)
- return 0x8000000000000000UL;
-#else
- return ALIGN_DOWN(addr, gethugepagesize());
-#endif
-}
-
-unsigned long hugetlbfs_slice_end(unsigned long addr) {
-#if defined(__powerpc64__)
- if (addr < SLICE_LOW_TOP)
- return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
+unsigned long next_valid_hugetlb_addr(unsigned long addr)
+{
+#if defined(__ia64__)
+ if (addr < 0x8000000000000000UL)
+ return 0x8000000000000000UL;
else
- return ALIGN_UP(addr, SLICE_HIGH_SIZE) - 1;
-#elif defined(__powerpc__)
- return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
-#elif defined(__ia64__)
- return 0xFFFFFFFFFFFFFFFFUL;
+ ALIGN_UP(addr, gethugepagesize());
#else
- return ALIGN_UP(addr, gethugepagesize()) - 1;
+ return ALIGN_UP(addr, gethugepagesize());
#endif
}
diff --git a/morecore.c b/morecore.c
index 95169c1..255e93d 100644
--- a/morecore.c
+++ b/morecore.c
@@ -165,7 +165,7 @@ static void __attribute__((constructor))
setup_morecore(void)
}
} else {
heapaddr = (unsigned long)sbrk(0);
- heapaddr = hugetlbfs_slice_end(heapaddr) + 1;
+ heapaddr = next_valid_hugetlb_addr(heapaddr);
}
DEBUG("setup_morecore(): heapaddr = 0x%lx\n", heapaddr);
diff --git a/tests/brk_near_huge.c b/tests/brk_near_huge.c
index 6e75e8c..2e570b3 100644
--- a/tests/brk_near_huge.c
+++ b/tests/brk_near_huge.c
@@ -38,12 +38,7 @@
void *next_chunk(void *addr)
{
- if ((unsigned long)addr ==
- hugetlbfs_slice_start((unsigned long)addr)) {
- return addr;
- } else {
- return (void *)hugetlbfs_slice_end((unsigned long)addr) + 1UL;
- }
+ return (void *)next_valid_hugetlb_addr((unsigned long)addr);
}
int main(int argc, char *argv[])
diff --git a/version.lds b/version.lds
index 0acdd28..4b33ecc 100644
--- a/version.lds
+++ b/version.lds
@@ -10,6 +10,5 @@ VERS_1.0 {
VERS_1.2 {
global:
- hugetlbfs_slice_start;
- hugetlbfs_slice_end;
+ next_valid_hugetlb_addr;
} VERS_1.0;
--
Nishanth Aravamudan <[EMAIL PROTECTED]>
IBM Linux Technology Center
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Libhugetlbfs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel