On 21.03.2007 [15:39:52 -0700], Nishanth Aravamudan wrote:
> Here are the patches I'm going to ask Adam to pull tomorrow:
> 
> + 08279399b7361d12180edca95144187f521ddbea tests/Makefile: don't use 'new' 
> make syntax
> + b95c3ddfe2f7e311e86004d60b0db39a0a2bce6b Revert "elflink: drop hugepage 
> cached pages for writable segments"
> + 58e9a9e4f70967f9d88d621eecd34346d92b936e hugeutils: one missed 
> gethugepagesize() conversion
> + d4f48941f56749642ba1ee9d1764f628f6433671 morecore: mlock() failure is 
> non-fatal
> + a06e6114ac1ab180393fcb40e4f131a38d19a5f4 Revert ae76f97ae76f97... 
> hugeutils: remove hugetlbfs_vaddr_granularity in favor of slice functions
> + 3a43f5d351e0ee694a7b66565b89b81ad961d7a1 hugeutils: move 
> hugetlbfs_vaddr_granularity
> 
> The first through fourth patches have been posted before.
> 
> The last two will be posted in response to this, with explanations.

Revert ae76f97ae76f97... hugeutils: remove hugetlbfs_vaddr_granularity in favor 
of slice functions

After several rounds of discussion with David Gibson, I believe the
semantics of the slice functions is too hard to get right (esp. on ia64)
to make it an exported and useful interface. morecore and brk_near_huge
are fine with using either the granularity function, or their own custom
version, respectively.

The real consumer of these new interfaces will be the partial_remap
code, but in that case, we'll put all the functions local to elflink.c.

This reverts commit ae76f97ba81aad38e7a2064bfe63e919232c7053.

diff --git a/hugetlbfs.h b/hugetlbfs.h
index be5a352..966e57c 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);
+long hugetlbfs_vaddr_granularity(void);
 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 0e452dd..1c30bb0 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -114,45 +114,14 @@ 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);
-#else
-       return ALIGN_DOWN(addr, gethugepagesize());
-#endif
-}
-
-unsigned long hugetlbfs_slice_end(unsigned long addr) {
+long hugetlbfs_vaddr_granularity(void)
+{
 #if defined(__powerpc64__)
-       if (addr < SLICE_LOW_TOP)
-               return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
-       else
-               return ALIGN_UP(addr, SLICE_HIGH_SIZE) - 1;
+       return (1L << 40);
 #elif defined(__powerpc__)
-       return ALIGN_UP(addr, SLICE_LOW_SIZE) - 1;
+       return (1L << 28);
 #else
-       return ALIGN_UP(addr, gethugepagesize()) - 1;
+       return gethugepagesize();
 #endif
 }
 
diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
index beaa35a..bbe7a6b 100644
--- a/libhugetlbfs_internal.h
+++ b/libhugetlbfs_internal.h
@@ -26,9 +26,7 @@
 #define stringify_1(x) #x
 #define stringify(x)   stringify_1(x)
 
-#define ALIGN_UP(x, a)         (((x) + (a) - 1) & ~((a) - 1))
-#define ALIGN_DOWN(x, a)       ((x) & ~((a) - 1))
-#define ALIGN(x,a)             ALIGN_UP(x,a)
+#define ALIGN(x, a)    (((x) + (a) - 1) & ~((a) - 1))
 
 extern int __hugetlbfs_verbose;
 
diff --git a/morecore.c b/morecore.c
index 95169c1..0c16e01 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 = ALIGN(heapaddr, hugetlbfs_vaddr_granularity());
        }
 
        DEBUG("setup_morecore(): heapaddr = 0x%lx\n", heapaddr);

-- 
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

Reply via email to