36 lines
1.3 KiB
Diff
36 lines
1.3 KiB
Diff
diff -up util-linux-2.21.2/sys-utils/lscpu.c.kzak util-linux-2.21.2/sys-utils/lscpu.c
|
|
--- util-linux-2.21.2/sys-utils/lscpu.c.kzak 2012-05-25 11:44:59.041195655 +0200
|
|
+++ util-linux-2.21.2/sys-utils/lscpu.c 2012-11-16 11:50:59.350150439 +0100
|
|
@@ -605,16 +605,26 @@ read_topology(struct lscpu_desc *desc, i
|
|
|
|
/* threads within one core */
|
|
nthreads = CPU_COUNT_S(setsize, thread_siblings);
|
|
+ if (!nthreads)
|
|
+ nthreads = 1;
|
|
+
|
|
/* cores within one socket */
|
|
ncores = CPU_COUNT_S(setsize, core_siblings) / nthreads;
|
|
- /* number of sockets within one book.
|
|
- * Because of odd / non-present cpu maps and to keep
|
|
- * calculation easy we make sure that nsockets and
|
|
- * nbooks is at least 1.
|
|
+ if (!ncores)
|
|
+ ncores = 1;
|
|
+
|
|
+ /* number of sockets within one book. Because of odd /
|
|
+ * non-present cpu maps and to keep calculation easy we make
|
|
+ * sure that nsockets and nbooks is at least 1.
|
|
*/
|
|
- nsockets = desc->ncpus / nthreads / ncores ?: 1;
|
|
+ nsockets = desc->ncpus / nthreads / ncores;
|
|
+ if (!nsockets)
|
|
+ nsockets = 1;
|
|
+
|
|
/* number of books */
|
|
- nbooks = desc->ncpus / nthreads / ncores / nsockets ?: 1;
|
|
+ nbooks = desc->ncpus / nthreads / ncores / nsockets;
|
|
+ if (!nbooks)
|
|
+ nbooks = 1;
|
|
|
|
/* all threads, see also read_basicinfo()
|
|
* -- fallback for kernels without
|