Sort the output of the pool configuration listing --pool-list, and now
that the default size will not be first mark it in a new Default column.

Signed-off-by: Andy Whitcroft <[EMAIL PROTECTED]>
Acked-by: Adam Litke <[EMAIL PROTECTED]>
---
 hugeadm.c               |   15 ++++++++++++---
 hugeutils.c             |    5 ++++-
 libhugetlbfs_internal.h |    1 +
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/hugeadm.c b/hugeadm.c
index cff5cb8..89f30d9 100644
--- a/hugeadm.c
+++ b/hugeadm.c
@@ -61,6 +61,13 @@ int opt_dry_run = 0;
 #define LONG_POOL_LIST (LONG_POOL|'l')
 
 #define MAX_POOLS      32
+
+static int cmpsizes(const void *p1, const void *p2)
+{
+       return ((struct hpage_pool *)p1)->pagesize >
+                       ((struct hpage_pool *)p2)->pagesize;
+}
+
 void pool_list(void)
 {
        struct hpage_pool pools[MAX_POOLS];
@@ -72,12 +79,14 @@ void pool_list(void)
                ERROR("unable to obtain pools list");
                exit(EXIT_FAILURE);
        }
+       qsort(pools, cnt, sizeof(pools[0]), cmpsizes);
 
-       printf("%10s %8s %8s %8s\n", "Size", "Minimum", "Current", "Maximum");
+       printf("%10s %8s %8s %8s %8s\n",
+               "Size", "Minimum", "Current", "Maximum", "Default");
        for (pos = 0; cnt--; pos++) {
-               printf("%10ld %8ld %8ld %8ld\n", pools[pos].pagesize,
+               printf("%10ld %8ld %8ld %8ld %8s\n", pools[pos].pagesize,
                        pools[pos].minimum, pools[pos].size,
-                       pools[pos].maximum);
+                       pools[pos].maximum, (pools[pos].is_default) ? "*" : "");
        }
 }
 
diff --git a/hugeutils.c b/hugeutils.c
index 973934b..222f06a 100644
--- a/hugeutils.c
+++ b/hugeutils.c
@@ -496,6 +496,7 @@ static int get_pool_size(long size, struct hpage_pool *pool)
                pool->minimum = nr_static;
                pool->maximum = nr_static + nr_over;
                pool->size = nr_used + nr_resv;
+               pool->is_default = 0;
 
                return 1;
        }
@@ -513,8 +514,10 @@ int __lh_hpool_sizes(struct hpage_pool *pools, int pcnt)
        default_size = size_to_smaller_unit(file_read_ulong(MEMINFO,
                                                        "Hugepagesize:"));
        if (default_size >= 0 && which < pcnt)
-               if (get_pool_size(default_size, &pools[which]))
+               if (get_pool_size(default_size, &pools[which])) {
+                       pools[which].is_default = 1;
                        which++;
+               }
 
        dir = opendir(SYSFS_HUGEPAGES_DIR);
        if (dir) {
diff --git a/libhugetlbfs_internal.h b/libhugetlbfs_internal.h
index 308aed8..5c1e788 100644
--- a/libhugetlbfs_internal.h
+++ b/libhugetlbfs_internal.h
@@ -94,6 +94,7 @@ struct hpage_pool {
        unsigned long minimum;
        unsigned long maximum;
        unsigned long size;
+       int is_default;
 };
 
 extern int __lh_hpool_sizes(struct hpage_pool *, int);
-- 
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

Reply via email to