Expose possible page sizes. Expose the page sizes which are available (have pages assigned to them) via --page-sizes. Expose all possible page sizes (supported by the processor) via --page-sizes-all. Page sizes are listed in numerical order. Lists only page sizes which are actually available, which have pages assigned to the pool and which are exposed via a mount point.
Signed-off-by: Andy Whitcroft <[EMAIL PROTECTED]> Acked-by: Mel Gorman <[EMAIL PROTECTED]> --- hugeadm.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 files changed, 40 insertions(+), 0 deletions(-) diff --git a/hugeadm.c b/hugeadm.c index 703e724..85b70f2 100644 --- a/hugeadm.c +++ b/hugeadm.c @@ -54,6 +54,10 @@ void print_usage() OPTION("--pool-pages-max <size>:[+|-]<count>", ""); CONT("Adjust pool 'size' upper bound"); + OPTION("--page-sizes", "Display page sizes that a configured pool"); + OPTION("--page-sizes-all", + "Display page sizes support by the hardware"); + OPTION("--help, -h", "Prints this message"); } @@ -67,6 +71,10 @@ int opt_dry_run = 0; #define LONG_POOL_MIN_ADJ (LONG_POOL|'m') #define LONG_POOL_MAX_ADJ (LONG_POOL|'M') +#define LONG_PAGE ('P' << 8) +#define LONG_PAGE_SIZES (LONG_PAGE|'s') +#define LONG_PAGE_AVAIL (LONG_PAGE|'a') + #define MAX_POOLS 32 static int cmpsizes(const void *p1, const void *p2) @@ -214,6 +222,26 @@ void pool_adjust(char *cmd, unsigned int counter) } } +void page_sizes(int all) +{ + struct hpage_pool pools[MAX_POOLS]; + int pos; + int cnt; + + cnt = __lh_hpool_sizes(pools, MAX_POOLS); + if (cnt < 0) { + ERROR("unable to obtain pools list"); + exit(EXIT_FAILURE); + } + qsort(pools, cnt, sizeof(pools[0]), cmpsizes); + + for (pos = 0; cnt--; pos++) { + if (all || (pools[pos].maximum && + hugetlbfs_find_path_for_size(pools[pos].pagesize))) + printf("%ld\n", pools[pos].pagesize); + } +} + int main(int argc, char** argv) { char opts[] = "+h"; @@ -225,10 +253,14 @@ int main(int argc, char** argv) {"pool-pages-min", required_argument, NULL, LONG_POOL_MIN_ADJ}, {"pool-pages-max", required_argument, NULL, LONG_POOL_MAX_ADJ}, + {"page-sizes", no_argument, NULL, LONG_PAGE_SIZES}, + {"page-sizes-all", no_argument, NULL, LONG_PAGE_AVAIL}, + {0}, }; __lh_hugetlbfs_setup_debug(); + __lh_setup_mounts(); while (ret != -1) { ret = getopt_long(argc, argv, opts, long_opts, &index); @@ -256,6 +288,14 @@ int main(int argc, char** argv) pool_adjust(optarg, POOL_MAX); break; + case LONG_PAGE_SIZES: + page_sizes(0); + break; + + case LONG_PAGE_AVAIL: + page_sizes(1); + break; + default: WARNING("unparsed option %08x\n", ret); ret = -1; -- 1.6.0.1.451.gc8d31 ------------------------------------------------------------------------- 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