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.
Signed-off-by: Andy Whitcroft <[EMAIL PROTECTED]> --- hpoolcfg.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 files changed, 38 insertions(+), 2 deletions(-) diff --git a/hpoolcfg.c b/hpoolcfg.c index 46e8de4..e9ac665 100644 --- a/hpoolcfg.c +++ b/hpoolcfg.c @@ -50,6 +50,9 @@ void print_usage() OPTION("--pool-list", "List all pools"); + OPTION("--page-sizes", "List all available page sizes"); + OPTION("--page-sizes-all", "List all supported page sizes"); + OPTION("--help, -h", "Prints this message"); } @@ -61,6 +64,10 @@ int opt_dry_run = 0; #define LONG_POOL ('p' << 8) #define LONG_POOL_LIST (LONG_POOL|'l') +#define LONG_PAGE ('P' << 8) +#define LONG_PAGE_SIZES (LONG_PAGE|'s') +#define LONG_PAGE_AVAIL (LONG_PAGE|'a') + #define MAX_POOLS 32 void pool_list(void) { @@ -74,14 +81,32 @@ void pool_list(void) exit(EXIT_FAILURE); } - printf("%10s %8s %8s %8s\n", "Size", "Minimum", "Current", "Maximum"); + printf("%10s %8s %8s %8s\n", "Size", "Minimum", "Current", "Maximum"); for (pos = 0; cnt--; pos++) { - printf("%10ldkB %8ld %8ld %8ld\n", pools[pos].pagesize_kb, + printf("%10ld %8ld %8ld %8ld\n", pools[pos].pagesize_kb, pools[pos].minimum, pools[pos].size, pools[pos].maximum); } } +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); + } + + for (pos = 0; cnt--; pos++) { + if (all || pools[pos].maximum) + printf("%ld\n", pools[pos].pagesize_kb); + } +} + int main(int argc, char** argv) { char opts[] = "+h"; @@ -91,6 +116,9 @@ int main(int argc, char** argv) {"pool-list", no_argument, NULL, LONG_POOL_LIST}, + {"page-sizes", no_argument, NULL, LONG_PAGE_SIZES}, + {"page-sizes-all", no_argument, NULL, LONG_PAGE_AVAIL}, + {0}, }; @@ -114,6 +142,14 @@ int main(int argc, char** argv) pool_list(); 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