Allow applications that program to the libhugetlbfs API to specify a page size when requesting a hugetlbfs fd. If the size is invalid or not configured, an error will be returned.
Signed-off-by: Adam Litke <[EMAIL PROTECTED]> --- hugetlbfs.h | 2 ++ hugeutils.c | 35 ++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/hugetlbfs.h b/hugetlbfs.h index 169e55f..d27ba6f 100644 --- a/hugetlbfs.h +++ b/hugetlbfs.h @@ -24,7 +24,9 @@ long gethugepagesize(void); int hugetlbfs_test_path(const char *mount); const char *hugetlbfs_find_path(void); +const char *hugetlbfs_find_path_for_size(long page_size); int hugetlbfs_unlinked_fd(void); +int hugetlbfs_unlinked_fd_for_size(long page_size); /* Diagnoses/debugging only functions */ long __lh_dump_proc_pid_maps(void); diff --git a/hugeutils.c b/hugeutils.c index 8a40640..cf8b83f 100644 --- a/hugeutils.c +++ b/hugeutils.c @@ -378,23 +378,39 @@ int hugetlbfs_test_path(const char *mount) return (sb.f_type == HUGETLBFS_MAGIC); } -const char *hugetlbfs_find_path(void) +const char *hugetlbfs_find_path_for_size(long page_size) { - char *path = hpage_sizes[hpage_sizes_default_idx].mount; + char *path; + int idx; - if (strlen(path)) - return path; + if (page_size == 0) + idx = hpage_sizes_default_idx; else - return NULL; + idx = hpage_size_to_index(page_size); + + if (idx >= 0) { + path = hpage_sizes[idx].mount; + if (strlen(path)) + return path; + } + return NULL; } -int hugetlbfs_unlinked_fd(void) +const char *hugetlbfs_find_path(void) +{ + return hugetlbfs_find_path_for_size(0); +} + +int hugetlbfs_unlinked_fd_for_size(long page_size) { const char *path; char name[PATH_MAX+1]; int fd; - path = hugetlbfs_find_path(); + if (page_size == 0) + page_size = hpage_sizes[hpage_sizes_default_idx].pagesize; + + path = hugetlbfs_find_path_for_size(page_size); if (!path) return -1; @@ -416,6 +432,11 @@ int hugetlbfs_unlinked_fd(void) return fd; } +int hugetlbfs_unlinked_fd(void) +{ + return hugetlbfs_unlinked_fd_for_size(0); +} + #define IOV_LEN 64 int __lh_hugetlbfs_prefault(int fd, void *addr, size_t length) { ------------------------------------------------------------------------- This SF.Net email is sponsored by the Moblin Your Move Developer's challenge Build the coolest Linux based applications with Moblin SDK & win great prizes Grand prize is a trip for two to an Open Source event anywhere in the world http://moblin-contest.org/redirect.php?banner_id=100&url=/ _______________________________________________ Libhugetlbfs-devel mailing list Libhugetlbfs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel