]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lscpu: sort NUMA nodes to keep output human readable
authorKarel Zak <kzak@redhat.com>
Tue, 14 Jan 2014 12:56:27 +0000 (13:56 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Jan 2014 12:59:34 +0000 (13:59 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/lscpu.c

index 0e937e1cd14c107b8b887b6ada50dcbb4b2b7b31..b8840ef90a99a876fb1580a58af8c5cdc056b21f 100644 (file)
@@ -925,6 +925,13 @@ static inline int is_node_dirent(struct dirent *d)
                isdigit_string(d->d_name + 4);
 }
 
+static int
+nodecmp(const void *ap, const void *bp)
+{
+       int *a = (int *) ap, *b = (int *) bp;
+       return *a - *b;
+}
+
 static void
 read_nodes(struct lscpu_desc *desc)
 {
@@ -960,6 +967,7 @@ read_nodes(struct lscpu_desc *desc)
                                                        _("Failed to extract the node number"));
                }
                closedir(dir);
+               qsort(desc->idx2nodenum, desc->nnodes, sizeof(int), nodecmp);
        }
 
        /* information about how nodes share different CPUs */