Ubuntu Pastebin

Paste from xnox at Thu, 22 Sep 2016 11:00:59 +0000

Download as text
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
diff -Nru util-linux-2.28.2/debian/changelog util-linux-2.28.2/debian/changelog
--- util-linux-2.28.2/debian/changelog	2016-09-12 22:22:44.000000000 +0100
+++ util-linux-2.28.2/debian/changelog	2016-09-22 12:00:21.000000000 +0100
@@ -1,3 +1,10 @@
+util-linux (2.28.2-1ubuntu2) yakkety; urgency=medium
+
+  * Cherry-pick upstream patches to add s390 drawer support in lscpu for
+    v4.8 kernels LP: #1612224.
+
+ -- Dimitri John Ledkov <xnox@ubuntu.com>  Thu, 22 Sep 2016 11:58:18 +0100
+
 util-linux (2.28.2-1ubuntu1) yakkety; urgency=medium
 
   * Merge from Debian unstable.  Remaining changes:
diff -Nru util-linux-2.28.2/debian/patches/0001-lscpu-add-drawer-support.patch util-linux-2.28.2/debian/patches/0001-lscpu-add-drawer-support.patch
--- util-linux-2.28.2/debian/patches/0001-lscpu-add-drawer-support.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0001-lscpu-add-drawer-support.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,192 @@
+From b3adf6ef6676ca8c10ecdda3e1c92a861df3b885 Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Tue, 14 Jun 2016 09:22:34 +0200
+Subject: [PATCH 1/9] lscpu: add drawer support
+
+The s390 architecture gained another cpu topology level called
+"drawer" which is above the book level.
+
+Add support for this to lscpu.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ sys-utils/lscpu.1 |  5 ++++-
+ sys-utils/lscpu.c | 51 +++++++++++++++++++++++++++++++++++++++++++--------
+ 2 files changed, 47 insertions(+), 9 deletions(-)
+
+diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
+index 35dfe7f..167567f 100644
+--- a/sys-utils/lscpu.1
++++ b/sys-utils/lscpu.1
+@@ -50,8 +50,11 @@ The logical socket number.  A socket can contain several cores.
+ .B BOOK
+ The logical book number.  A book can contain several sockets.
+ .TP
++.B DRAWER
++The logical drawer number.  A drawer can contain several books.
++.TP
+ .B NODE
+-The logical NUMA node number.  A node may contain several books.
++The logical NUMA node number.  A node may contain several drawers.
+ .TP
+ .B CACHE
+ Information about how caches are shared between CPUs.
+diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
+index 267e728..41316cc 100644
+--- a/sys-utils/lscpu.c
++++ b/sys-utils/lscpu.c
+@@ -240,6 +240,11 @@ struct lscpu_desc {
+ 	int		*idx2nodenum;	/* Support for discontinuous nodes */
+ 	cpu_set_t	**nodemaps;	/* array with NUMA nodes */
+ 
++	/* drawers -- based on drawer_siblings (internal kernel map of cpuX's
++	 * hardware threads within the same drawer */
++	int		ndrawers;	/* number of all online drawers */
++	cpu_set_t	**drawermaps;	/* unique drawer_siblings */
++
+ 	/* books -- based on book_siblings (internal kernel map of cpuX's
+ 	 * hardware threads within the same book */
+ 	int		nbooks;		/* number of all online books */
+@@ -303,6 +308,7 @@ enum {
+ 	COL_SOCKET,
+ 	COL_NODE,
+ 	COL_BOOK,
++	COL_DRAWER,
+ 	COL_CACHE,
+ 	COL_POLARIZATION,
+ 	COL_ADDRESS,
+@@ -328,6 +334,7 @@ static struct lscpu_coldesc coldescs[] =
+ 	[COL_SOCKET]       = { "SOCKET", N_("logical socket number") },
+ 	[COL_NODE]         = { "NODE", N_("logical NUMA node number") },
+ 	[COL_BOOK]         = { "BOOK", N_("logical book number") },
++	[COL_DRAWER]       = { "DRAWER", N_("logical drawer number") },
+ 	[COL_CACHE]        = { "CACHE", N_("shows how caches are shared between CPUs") },
+ 	[COL_POLARIZATION] = { "POLARIZATION", N_("CPU dispatching mode on virtual hardware") },
+ 	[COL_ADDRESS]      = { "ADDRESS", N_("physical address of a CPU") },
+@@ -974,7 +981,8 @@ static int add_cpuset_to_array(cpu_set_t **ary, int *items, cpu_set_t *set)
+ static void
+ read_topology(struct lscpu_desc *desc, int idx)
+ {
+-	cpu_set_t *thread_siblings, *core_siblings, *book_siblings;
++	cpu_set_t *thread_siblings, *core_siblings;
++	cpu_set_t *book_siblings, *drawer_siblings;
+ 	int num = real_cpu_num(desc, idx);
+ 
+ 	if (!path_exist(_PATH_SYS_CPU "/cpu%d/topology/thread_siblings", num))
+@@ -988,9 +996,13 @@ read_topology(struct lscpu_desc *desc, int idx)
+ 	if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/book_siblings", num))
+ 		book_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU
+ 					    "/cpu%d/topology/book_siblings", num);
++	drawer_siblings = NULL;
++	if (path_exist(_PATH_SYS_CPU "/cpu%d/topology/drawer_siblings", num))
++		drawer_siblings = path_read_cpuset(maxcpus, _PATH_SYS_CPU
++					    "/cpu%d/topology/drawer_siblings", num);
+ 
+ 	if (!desc->coremaps) {
+-		int nbooks, nsockets, ncores, nthreads;
++		int ndrawers, nbooks, nsockets, ncores, nthreads;
+ 		size_t setsize = CPU_ALLOC_SIZE(maxcpus);
+ 
+ 		/* threads within one core */
+@@ -1016,12 +1028,17 @@ read_topology(struct lscpu_desc *desc, int idx)
+ 		if (!nbooks)
+ 			nbooks = 1;
+ 
++		/* number of drawers */
++		ndrawers = desc->ncpus / nbooks / nthreads / ncores / nsockets;
++		if (!ndrawers)
++			ndrawers = 1;
++
+ 		/* all threads, see also read_basicinfo()
+ 		 * -- fallback for kernels without
+ 		 *    /sys/devices/system/cpu/online.
+ 		 */
+ 		if (!desc->nthreads)
+-			desc->nthreads = nbooks * nsockets * ncores * nthreads;
++			desc->nthreads = ndrawers * nbooks * nsockets * ncores * nthreads;
+ 
+ 		/* For each map we make sure that it can have up to ncpuspos
+ 		 * entries. This is because we cannot reliably calculate the
+@@ -1033,12 +1050,16 @@ read_topology(struct lscpu_desc *desc, int idx)
+ 		desc->socketmaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *));
+ 		if (book_siblings)
+ 			desc->bookmaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *));
++		if (drawer_siblings)
++			desc->drawermaps = xcalloc(desc->ncpuspos, sizeof(cpu_set_t *));
+ 	}
+ 
+ 	add_cpuset_to_array(desc->socketmaps, &desc->nsockets, core_siblings);
+ 	add_cpuset_to_array(desc->coremaps, &desc->ncores, thread_siblings);
+ 	if (book_siblings)
+ 		add_cpuset_to_array(desc->bookmaps, &desc->nbooks, book_siblings);
++	if (drawer_siblings)
++		add_cpuset_to_array(desc->drawermaps, &desc->ndrawers, drawer_siblings);
+ }
+ 
+ static void
+@@ -1289,6 +1310,11 @@ get_cell_data(struct lscpu_desc *desc, int idx, int col,
+ 				     desc->nnodes, setsize, &i) == 0)
+ 			snprintf(buf, bufsz, "%d", desc->idx2nodenum[i]);
+ 		break;
++	case COL_DRAWER:
++		if (cpuset_ary_isset(cpu, desc->drawermaps,
++				     desc->ndrawers, setsize, &i) == 0)
++			snprintf(buf, bufsz, "%zu", i);
++		break;
+ 	case COL_BOOK:
+ 		if (cpuset_ary_isset(cpu, desc->bookmaps,
+ 				     desc->nbooks, setsize, &i) == 0)
+@@ -1635,9 +1661,9 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 	}
+ 
+ 	if (desc->nsockets) {
+-		int cores_per_socket, sockets_per_book, books;
++		int cores_per_socket, sockets_per_book, books_per_drawer, drawers;
+ 
+-		cores_per_socket = sockets_per_book = books = 0;
++		cores_per_socket = sockets_per_book = books_per_drawer = drawers = 0;
+ 		/* s390 detects its cpu topology via /proc/sysinfo, if present.
+ 		 * Using simply the cpu topology masks in sysfs will not give
+ 		 * usable results since everything is virtualized. E.g.
+@@ -1649,11 +1675,12 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		if (path_exist(_PATH_PROC_SYSINFO)) {
+ 			FILE *fd = path_fopen("r", 0, _PATH_PROC_SYSINFO);
+ 			char pbuf[BUFSIZ];
+-			int t0, t1, t2;
++			int t0, t1;
+ 
+ 			while (fd && fgets(pbuf, sizeof(pbuf), fd) != NULL) {
+ 				if (sscanf(pbuf, "CPU Topology SW:%d%d%d%d%d%d",
+-					   &t0, &t1, &t2, &books, &sockets_per_book,
++					   &t0, &t1, &drawers, &books_per_drawer,
++					   &sockets_per_book,
+ 					   &cores_per_socket) == 6)
+ 					break;
+ 			}
+@@ -1666,7 +1693,13 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		if (desc->nbooks) {
+ 			print_n(_("Socket(s) per book:"),
+ 				sockets_per_book ?: desc->nsockets / desc->nbooks);
+-			print_n(_("Book(s):"), books ?: desc->nbooks);
++			if (desc->ndrawers) {
++				print_n(_("Book(s) per drawer:"),
++					books_per_drawer ?: desc->nbooks / desc->ndrawers);
++				print_n(_("Drawers(s):"), drawers ?: desc->ndrawers);
++			} else {
++				print_n(_("Book(s):"), books_per_drawer ?: desc->nbooks);
++			}
+ 		} else {
+ 			print_n(_("Socket(s):"), sockets_per_book ?: desc->nsockets);
+ 		}
+@@ -1899,6 +1932,8 @@ int main(int argc, char *argv[])
+ 			columns[ncolumns++] = COL_CPU;
+ 			if (desc->nodemaps)
+ 				columns[ncolumns++] = COL_NODE;
++			if (desc->drawermaps)
++				columns[ncolumns++] = COL_DRAWER;
+ 			if (desc->bookmaps)
+ 				columns[ncolumns++] = COL_BOOK;
+ 			if (desc->socketmaps)
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0002-lscpu-add-s390-drawer-testcase.patch util-linux-2.28.2/debian/patches/0002-lscpu-add-s390-drawer-testcase.patch
--- util-linux-2.28.2/debian/patches/0002-lscpu-add-s390-drawer-testcase.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0002-lscpu-add-s390-drawer-testcase.patch	2016-09-22 11:49:59.000000000 +0100
@@ -0,0 +1,54 @@
+From 08fb47ad827cf54a57917c1082082c57d8e6425d Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Tue, 14 Jun 2016 12:38:08 +0200
+Subject: [PATCH 2/9] lscpu: add s390 drawer testcase
+
+Add a new s390 testcase so we get some coverage for the new drawer cpu
+topology level.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ tests/expected/lscpu/lscpu-s390-lpar-drawer  |  35 +++++++++++++++++++++++++++
+ tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz | Bin 0 -> 18125 bytes
+ 2 files changed, 35 insertions(+)
+ create mode 100644 tests/expected/lscpu/lscpu-s390-lpar-drawer
+ create mode 100644 tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz
+
+--- /dev/null
++++ b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+@@ -0,0 +1,35 @@
++CPU op-mode(s):        32-bit, 64-bit
++CPU(s):                8
++On-line CPU(s) list:   0-7
++Thread(s) per core:    1
++Core(s) per socket:    8
++Socket(s) per book:    3
++Book(s) per drawer:    2
++Drawers(s):            4
++NUMA node(s):          1
++Vendor ID:             IBM/S390
++Model name:            0
++BogoMIPS:              20325.00
++Hypervisor:            PR/SM
++Hypervisor vendor:     IBM
++Virtualization type:   full
++Dispatching mode:      horizontal
++L1d cache:             128K
++L1i cache:             96K
++L2d cache:             2048K
++L2i cache:             2048K
++NUMA node0 CPU(s):     0-140
++Flags:                 esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx sie
++
++# The following is the parsable format, which can be fed to other
++# programs. Each different item in every column has an unique ID
++# starting from zero.
++# CPU,Core,Socket,Node,,L1d,L1i,L2d,L2i
++0,0,0,0,,0,0,0,0
++1,1,0,0,,1,1,1,1
++2,2,0,0,,2,2,2,2
++3,3,1,0,,3,3,3,3
++4,4,1,0,,4,4,4,4
++5,5,1,0,,5,5,5,5
++6,6,1,0,,6,6,6,6
++7,7,1,0,,7,7,7,7
diff -Nru util-linux-2.28.2/debian/patches/0003-lscpu-fix-typo-in-summary-output.patch util-linux-2.28.2/debian/patches/0003-lscpu-fix-typo-in-summary-output.patch
--- util-linux-2.28.2/debian/patches/0003-lscpu-fix-typo-in-summary-output.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0003-lscpu-fix-typo-in-summary-output.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,43 @@
+From 156740ca3779faf4aa58deb7cde2ffd356a1bd5c Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Wed, 22 Jun 2016 09:25:56 +0200
+Subject: [PATCH 3/9] lscpu: fix typo in summary output
+
+The new drawer support did have a type in the summary output:
+it reported Drawers(s) instead of Drawer(s). Fix this.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ sys-utils/lscpu.c                           | 2 +-
+ tests/expected/lscpu/lscpu-s390-lpar-drawer | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
+index 41316cc..c07b9d0 100644
+--- a/sys-utils/lscpu.c
++++ b/sys-utils/lscpu.c
+@@ -1696,7 +1696,7 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 			if (desc->ndrawers) {
+ 				print_n(_("Book(s) per drawer:"),
+ 					books_per_drawer ?: desc->nbooks / desc->ndrawers);
+-				print_n(_("Drawers(s):"), drawers ?: desc->ndrawers);
++				print_n(_("Drawer(s):"), drawers ?: desc->ndrawers);
+ 			} else {
+ 				print_n(_("Book(s):"), books_per_drawer ?: desc->nbooks);
+ 			}
+diff --git a/tests/expected/lscpu/lscpu-s390-lpar-drawer b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+index 1624e73..accbff8 100644
+--- a/tests/expected/lscpu/lscpu-s390-lpar-drawer
++++ b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+@@ -5,7 +5,7 @@ Thread(s) per core:    1
+ Core(s) per socket:    8
+ Socket(s) per book:    3
+ Book(s) per drawer:    2
+-Drawers(s):            4
++Drawer(s):             4
+ NUMA node(s):          1
+ Vendor ID:             IBM/S390
+ Model name:            0
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0004-lscpu-show-static-and-dynamic-MHz-s390.patch util-linux-2.28.2/debian/patches/0004-lscpu-show-static-and-dynamic-MHz-s390.patch
--- util-linux-2.28.2/debian/patches/0004-lscpu-show-static-and-dynamic-MHz-s390.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0004-lscpu-show-static-and-dynamic-MHz-s390.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,72 @@
+From 4632b28811c9d2d63a90a78f79244ab614bd9033 Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Wed, 22 Jun 2016 09:25:57 +0200
+Subject: [PATCH 4/9] lscpu: show static and dynamic MHz (s390)
+
+s390 machines provide static and dynamic cpu mhz information via
+/proc/cpuinfo. The static cpu mhz is the normal cpu frequency a cpu is
+supposed to run with.
+
+The dynamic cpu mhz is the actual frequency a cpu is running
+with. This is usually the same as the static cpu mhz. Note that this
+values are different to the min/max mhz values available on other
+architecutes. The min/max values are unknown.
+
+This patch adds two new fields to the summary output which display
+these two values.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ sys-utils/lscpu.c                           | 8 ++++++++
+ tests/expected/lscpu/lscpu-s390-lpar-drawer | 2 ++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
+index c07b9d0..9b87e04 100644
+--- a/sys-utils/lscpu.c
++++ b/sys-utils/lscpu.c
+@@ -208,6 +208,8 @@ struct lscpu_desc {
+ 	int	hyper;		/* hypervisor vendor ID */
+ 	int	virtype;	/* VIRT_PARA|FULL|NONE ? */
+ 	char	*mhz;
++	char	*dynamic_mhz;	/* dynamic mega hertz (s390) */
++	char	*static_mhz;	/* static mega hertz (s390) */
+ 	char	**maxmhz;	/* maximum mega hertz */
+ 	char	**minmhz;	/* minimum mega hertz */
+ 	char	*stepping;
+@@ -489,6 +491,8 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		else if (lookup(buf, "model name", &desc->modelname)) ;
+ 		else if (lookup(buf, "stepping", &desc->stepping)) ;
+ 		else if (lookup(buf, "cpu MHz", &desc->mhz)) ;
++		else if (lookup(buf, "cpu MHz dynamic", &desc->dynamic_mhz)) ; /* s390 */
++		else if (lookup(buf, "cpu MHz static", &desc->static_mhz)) ;   /* s390 */
+ 		else if (lookup(buf, "flags", &desc->flags)) ;		/* x86 */
+ 		else if (lookup(buf, "features", &desc->flags)) ;	/* s390 */
+ 		else if (lookup(buf, "type", &desc->flags)) ;		/* sparc64 */
+@@ -1718,6 +1722,10 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		print_s(_("Stepping:"), desc->stepping);
+ 	if (desc->mhz)
+ 		print_s(_("CPU MHz:"), desc->mhz);
++	if (desc->dynamic_mhz)
++		print_s(_("CPU dynamic MHz:"), desc->dynamic_mhz);
++	if (desc->static_mhz)
++		print_s(_("CPU static MHz:"), desc->static_mhz);
+ 	if (desc->maxmhz)
+ 		print_s(_("CPU max MHz:"), desc->maxmhz[0]);
+ 	if (desc->minmhz)
+diff --git a/tests/expected/lscpu/lscpu-s390-lpar-drawer b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+index accbff8..88fe100 100644
+--- a/tests/expected/lscpu/lscpu-s390-lpar-drawer
++++ b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+@@ -9,6 +9,8 @@ Drawer(s):             4
+ NUMA node(s):          1
+ Vendor ID:             IBM/S390
+ Model name:            0
++CPU dynamic MHz:       5000
++CPU static MHz:        5000
+ BogoMIPS:              20325.00
+ Hypervisor:            PR/SM
+ Hypervisor vendor:     IBM
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0005-lscpu-show-machine-type-s390.patch util-linux-2.28.2/debian/patches/0005-lscpu-show-machine-type-s390.patch
--- util-linux-2.28.2/debian/patches/0005-lscpu-show-machine-type-s390.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0005-lscpu-show-machine-type-s390.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,106 @@
+From 0c28f0c8151a8ac41e12b672643a5beda82f09b4 Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Wed, 22 Jun 2016 09:25:58 +0200
+Subject: [PATCH 5/9] lscpu: show machine type (s390)
+
+Show also the machine type within the lscpu output. With the machine
+type it is possible to identify the cpu generation and the supported
+features.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ sys-utils/lscpu.c                           | 12 ++++++++++++
+ tests/expected/lscpu/lscpu-s390-kvm         |  1 +
+ tests/expected/lscpu/lscpu-s390-lpar        |  1 +
+ tests/expected/lscpu/lscpu-s390-lpar-drawer |  1 +
+ tests/expected/lscpu/lscpu-s390-zvm         |  1 +
+ 5 files changed, 16 insertions(+)
+
+diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
+index 9b87e04..883dff6 100644
+--- a/sys-utils/lscpu.c
++++ b/sys-utils/lscpu.c
+@@ -198,6 +198,7 @@ struct polarization_modes polar_modes[] = {
+ struct lscpu_desc {
+ 	char	*arch;
+ 	char	*vendor;
++	char	*machinetype;	/* s390 */
+ 	char	*family;
+ 	char	*model;
+ 	char	*modelname;
+@@ -581,6 +582,15 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 
+ 	if (mod->system == SYSTEM_LIVE)
+ 		read_physical_info_powerpc(desc);
++
++	if (path_exist(_PATH_PROC_SYSINFO)) {
++		FILE *fd = path_fopen("r", 0, _PATH_PROC_SYSINFO);
++
++		while (fd && fgets(buf, sizeof(buf), fd) != NULL && !desc->machinetype)
++			lookup(buf, "Type", &desc->machinetype);
++		if (fd)
++			fclose(fd);
++	}
+ }
+ 
+ static int
+@@ -1712,6 +1722,8 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		print_n(_("NUMA node(s):"), desc->nnodes);
+ 	if (desc->vendor)
+ 		print_s(_("Vendor ID:"), desc->vendor);
++	if (desc->machinetype)
++		print_s(_("Machine type:"), desc->machinetype);
+ 	if (desc->family)
+ 		print_s(_("CPU family:"), desc->family);
+ 	if (desc->model || desc->revision)
+diff --git a/tests/expected/lscpu/lscpu-s390-kvm b/tests/expected/lscpu/lscpu-s390-kvm
+index 9632b05..66d1c04 100644
+--- a/tests/expected/lscpu/lscpu-s390-kvm
++++ b/tests/expected/lscpu/lscpu-s390-kvm
+@@ -6,6 +6,7 @@ Core(s) per socket:    1
+ Socket(s) per book:    1
+ Book(s):               3
+ Vendor ID:             IBM/S390
++Machine type:          2817
+ BogoMIPS:              14367.00
+ Hypervisor:            KVM/Linux
+ Hypervisor vendor:     KVM
+diff --git a/tests/expected/lscpu/lscpu-s390-lpar b/tests/expected/lscpu/lscpu-s390-lpar
+index a426566..9c8ac2c 100644
+--- a/tests/expected/lscpu/lscpu-s390-lpar
++++ b/tests/expected/lscpu/lscpu-s390-lpar
+@@ -7,6 +7,7 @@ Core(s) per socket:    4
+ Socket(s) per book:    6
+ Book(s):               4
+ Vendor ID:             IBM/S390
++Machine type:          2817
+ BogoMIPS:              14367.00
+ Hypervisor:            PR/SM
+ Hypervisor vendor:     IBM
+diff --git a/tests/expected/lscpu/lscpu-s390-lpar-drawer b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+index 88fe100..587e7a6 100644
+--- a/tests/expected/lscpu/lscpu-s390-lpar-drawer
++++ b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+@@ -8,6 +8,7 @@ Book(s) per drawer:    2
+ Drawer(s):             4
+ NUMA node(s):          1
+ Vendor ID:             IBM/S390
++Machine type:          2964
+ Model name:            0
+ CPU dynamic MHz:       5000
+ CPU static MHz:        5000
+diff --git a/tests/expected/lscpu/lscpu-s390-zvm b/tests/expected/lscpu/lscpu-s390-zvm
+index 6cf24bf..4cd6b8f 100644
+--- a/tests/expected/lscpu/lscpu-s390-zvm
++++ b/tests/expected/lscpu/lscpu-s390-zvm
+@@ -6,6 +6,7 @@ Core(s) per socket:    1
+ Socket(s) per book:    1
+ Book(s):               4
+ Vendor ID:             IBM/S390
++Machine type:          2817
+ BogoMIPS:              14367.00
+ Hypervisor:            z/VM 6.1.0
+ Hypervisor vendor:     IBM
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0006-lscpu-show-additional-caches-s390.patch util-linux-2.28.2/debian/patches/0006-lscpu-show-additional-caches-s390.patch
--- util-linux-2.28.2/debian/patches/0006-lscpu-show-additional-caches-s390.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0006-lscpu-show-additional-caches-s390.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,154 @@
+From 28b1658f8b5b3c9fdd971201de6e95abb33526a9 Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Wed, 22 Jun 2016 09:25:59 +0200
+Subject: [PATCH 6/9] lscpu: show additional caches (s390)
+
+The Linux kernel exposes the cache topology via sysfs. However on
+virtualized machines like s390 the cache topology contains only cpu
+private caches.
+
+For shared caches it is not known which cpus share them. The
+hypervisor would have to update this information whenever a virtual
+cpu would be scheduled on a different physical cpu and make the guest
+aware of that change. Given that there is hardly any benefit, if it
+all, this isn't done.
+
+However it is still of interest to know about the non-private
+caches. Therefore this information is available via /proc/cpuinfo at
+least on s390.
+
+This patch adds additional lines to the summary output for all shared
+caches for which information can be found in /proc/cpuinfo, since we
+know these aren't exposed via sysfs.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ sys-utils/lscpu.c                           | 70 +++++++++++++++++++++++++++++
+ tests/expected/lscpu/lscpu-s390-lpar-drawer |  2 +
+ 2 files changed, 72 insertions(+)
+
+diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
+index 883dff6..4bd8e87 100644
+--- a/sys-utils/lscpu.c
++++ b/sys-utils/lscpu.c
+@@ -229,6 +229,9 @@ struct lscpu_desc {
+ 	int		ncaches;
+ 	struct cpu_cache *caches;
+ 
++	int		necaches;	/* extra caches (s390) */
++	struct cpu_cache *ecaches;
++
+ 	/*
+ 	 * All maps are sequentially indexed (0..ncpuspos), the array index
+ 	 * does not have match with cpuX number as presented by kernel. You
+@@ -405,6 +408,58 @@ lookup(char *line, char *pattern, char **value)
+ 	return 1;
+ }
+ 
++/* Parse extra cache lines contained within /proc/cpuinfo but which are not
++ * part of the cache topology information within the sysfs filesystem.
++ * This is true for all shared caches on e.g. s390. When there are layers of
++ * hypervisors in between it is not knows which CPUs share which caches.
++ * Therefore information about shared caches is only available in
++ * /proc/cpuinfo.
++ * Format is:
++ * "cache<nr> : level=<lvl> type=<type> scope=<scope> size=<size> line_size=<lsz> associativity=<as>"
++ */
++static int
++lookup_cache(char *line, struct lscpu_desc *desc)
++{
++	struct cpu_cache *cache;
++	long long size;
++	char *p, type;
++	int level;
++
++	/* Make sure line starts with "cache<nr> :" */
++	if (strncmp(line, "cache", 5))
++		return 0;
++	for (p = line + 5; isdigit(*p); p++);
++	for (; isspace(*p); p++);
++	if (*p != ':')
++		return 0;
++
++	p = strstr(line, "scope=") + 6;
++	/* Skip private caches, also present in sysfs */
++	if (!p || strncmp(p, "Private", 7) == 0)
++		return 0;
++	p = strstr(line, "level=");
++	sscanf(p, "level=%d", &level);
++	p = strstr(line, "type=") + 5;
++	type = 0;
++	if (strncmp(p, "Data", 4) == 0)
++		type = 'd';
++	if (strncmp(p, "Instruction", 11) == 0)
++		type = 'i';
++	p = strstr(line, "size=");
++	sscanf(p, "size=%lld", &size);
++	desc->necaches++;
++	desc->ecaches = xrealloc(desc->ecaches,
++				 desc->necaches * sizeof(struct cpu_cache));
++	cache = &desc->ecaches[desc->necaches - 1];
++	memset(cache, 0 , sizeof(*cache));
++	if (type)
++		xasprintf(&cache->name, "L%d%c", level, type);
++	else
++		xasprintf(&cache->name, "L%d", level);
++	xasprintf(&cache->size, "%lldK", size);
++	return 1;
++}
++
+ /* Don't init the mode for platforms where we are not able to
+  * detect that CPU supports 64-bit mode.
+  */
+@@ -501,6 +556,7 @@ read_basicinfo(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		else if (lookup(buf, "bogomips per cpu", &desc->bogomips)) ; /* s390 */
+ 		else if (lookup(buf, "cpu", &desc->cpu)) ;
+ 		else if (lookup(buf, "revision", &desc->revision)) ;
++		else if (lookup_cache(buf, desc)) ;
+ 		else
+ 			continue;
+ 	}
+@@ -1768,6 +1824,16 @@ print_summary(struct lscpu_desc *desc, struct lscpu_modifier *mod)
+ 		}
+ 	}
+ 
++	if (desc->necaches) {
++		char cbuf[512];
++
++		for (i = desc->necaches - 1; i >= 0; i--) {
++			snprintf(cbuf, sizeof(cbuf),
++					_("%s cache:"), desc->ecaches[i].name);
++			print_s(cbuf, desc->ecaches[i].size);
++		}
++	}
++
+ 	for (i = 0; i < desc->nnodes; i++) {
+ 		snprintf(buf, sizeof(buf), _("NUMA node%d CPU(s):"), desc->idx2nodenum[i]);
+ 		print_cpuset(buf, desc->nodemaps[i], mod->hex);
+@@ -1928,6 +1994,10 @@ int main(int argc, char *argv[])
+ 		qsort(desc->caches, desc->ncaches,
+ 				sizeof(struct cpu_cache), cachecmp);
+ 
++	if (desc->ecaches)
++		qsort(desc->ecaches, desc->necaches,
++				sizeof(struct cpu_cache), cachecmp);
++
+ 	read_nodes(desc);
+ 	read_hypervisor(desc, mod);
+ 
+diff --git a/tests/expected/lscpu/lscpu-s390-lpar-drawer b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+index 587e7a6..75ee33f 100644
+--- a/tests/expected/lscpu/lscpu-s390-lpar-drawer
++++ b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+@@ -21,6 +21,8 @@ L1d cache:             128K
+ L1i cache:             96K
+ L2d cache:             2048K
+ L2i cache:             2048K
++L3 cache:              65536K
++L4 cache:              491520K
+ NUMA node0 CPU(s):     0-140
+ Flags:                 esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs te vx sie
+ 
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0007-lscpu-update-s390-lpar-drawer-testcase.patch util-linux-2.28.2/debian/patches/0007-lscpu-update-s390-lpar-drawer-testcase.patch
--- util-linux-2.28.2/debian/patches/0007-lscpu-update-s390-lpar-drawer-testcase.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0007-lscpu-update-s390-lpar-drawer-testcase.patch	2016-09-22 11:50:34.000000000 +0100
@@ -0,0 +1,48 @@
+From 8eb9604a341871e2c10c57c6b5cd8dba54fab577 Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Wed, 22 Jun 2016 09:26:00 +0200
+Subject: [PATCH 7/9] lscpu: update s390-lpar-drawer testcase
+
+I noticed that the "cpu" line within /proc/cpuinfo has a different
+meaning on powerpc and sparc than on s390.
+
+On s390 it represents the cpu number while on powerpc and sparc it
+represent the model name. Given that the s390 kernel patch which adds
+the "cpu" line to /proc/cpuinfo hasn't been merged into the kernel
+yet, I changed that line to "cpu number" to avoid the unnecessary
+conflict.
+
+Therefore this patch updates the testcase, which mainly changes the
+contents of /proc/cpuinfo.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ tests/expected/lscpu/lscpu-s390-lpar-drawer  |   3 +--
+ tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz | Bin 18125 -> 18131 bytes
+ 2 files changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/tests/expected/lscpu/lscpu-s390-lpar-drawer b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+index 75ee33f..2309f1d 100644
+--- a/tests/expected/lscpu/lscpu-s390-lpar-drawer
++++ b/tests/expected/lscpu/lscpu-s390-lpar-drawer
+@@ -9,7 +9,6 @@ Drawer(s):             4
+ NUMA node(s):          1
+ Vendor ID:             IBM/S390
+ Machine type:          2964
+-Model name:            0
+ CPU dynamic MHz:       5000
+ CPU static MHz:        5000
+ BogoMIPS:              20325.00
+@@ -32,7 +31,7 @@ Flags:                 esan3 zarch stfle msa ldisp eimm dfp edat etf3eh highgprs
+ # CPU,Core,Socket,Node,,L1d,L1i,L2d,L2i
+ 0,0,0,0,,0,0,0,0
+ 1,1,0,0,,1,1,1,1
+-2,2,0,0,,2,2,2,2
++2,2,1,0,,2,2,2,2
+ 3,3,1,0,,3,3,3,3
+ 4,4,1,0,,4,4,4,4
+ 5,5,1,0,,5,5,5,5
+
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0008-lscpu-fix-MMHZ-column-entry-within-man-page.patch util-linux-2.28.2/debian/patches/0008-lscpu-fix-MMHZ-column-entry-within-man-page.patch
--- util-linux-2.28.2/debian/patches/0008-lscpu-fix-MMHZ-column-entry-within-man-page.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0008-lscpu-fix-MMHZ-column-entry-within-man-page.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,42 @@
+From bfbe985eb456c43825454d72ce6f37bf16a2b719 Mon Sep 17 00:00:00 2001
+From: Heiko Carstens <heiko.carstens@de.ibm.com>
+Date: Wed, 22 Jun 2016 09:26:01 +0200
+Subject: [PATCH 8/9] lscpu: fix MMHZ column entry within man page
+
+The indentation for the MMHZ column within the man page is wrong. Also
+there doesn't exist any column with the name MMHZ. The correct names
+would be MAXMHZ and MINMHZ.
+
+Therefore rename MMHZ to MAXMHZ and add the missong MINMHZ entry.
+
+Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
+---
+ sys-utils/lscpu.1 | 9 ++++++---
+ 1 file changed, 6 insertions(+), 3 deletions(-)
+
+diff --git a/sys-utils/lscpu.1 b/sys-utils/lscpu.1
+index 167567f..ffe18db 100644
+--- a/sys-utils/lscpu.1
++++ b/sys-utils/lscpu.1
+@@ -87,12 +87,15 @@ The workload is concentrated on few CPUs.
+ For vertical polarization, the column also shows the degree of concentration,
+ high, medium, or low.  This column contains data only if your hardware system
+ and hypervisor support CPU polarization.
++.RE
+ .TP
+-.B MMHZ
+-Maximum megahertz value for the cpu.  Useful when lscpu is used as hardware
++.B MAXMHZ
++Maximum megahertz value for the CPU.  Useful when lscpu is used as hardware
+ inventory information gathering tool.  Notice that the megahertz value is
+ dynamic, and driven by CPU governor depending on current resource need.
+-.RE
++.TP
++.B MINMHZ
++Minimum megahertz value for the CPU.
+ .SH OPTIONS
+ .TP
+ .BR \-a , " \-\-all"
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/0009-lscpu-make-lookup_cache-more-robust.patch util-linux-2.28.2/debian/patches/0009-lscpu-make-lookup_cache-more-robust.patch
--- util-linux-2.28.2/debian/patches/0009-lscpu-make-lookup_cache-more-robust.patch	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/patches/0009-lscpu-make-lookup_cache-more-robust.patch	2016-09-22 11:45:20.000000000 +0100
@@ -0,0 +1,40 @@
+From 81a307bd4d906815dad7b6b3c355f663907a68c4 Mon Sep 17 00:00:00 2001
+From: Karel Zak <kzak@redhat.com>
+Date: Fri, 24 Jun 2016 11:07:00 +0200
+Subject: [PATCH 9/9] lscpu: make lookup_cache() more robust
+
+Signed-off-by: Karel Zak <kzak@redhat.com>
+---
+ sys-utils/lscpu.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/sys-utils/lscpu.c b/sys-utils/lscpu.c
+index 4bd8e87..b30b003 100644
+--- a/sys-utils/lscpu.c
++++ b/sys-utils/lscpu.c
+@@ -438,15 +438,20 @@ lookup_cache(char *line, struct lscpu_desc *desc)
+ 	if (!p || strncmp(p, "Private", 7) == 0)
+ 		return 0;
+ 	p = strstr(line, "level=");
+-	sscanf(p, "level=%d", &level);
++	if (!p || sscanf(p, "level=%d", &level) != 1)
++		return 0;
+ 	p = strstr(line, "type=") + 5;
++	if (!p || !*p)
++		return 0;
+ 	type = 0;
+ 	if (strncmp(p, "Data", 4) == 0)
+ 		type = 'd';
+ 	if (strncmp(p, "Instruction", 11) == 0)
+ 		type = 'i';
+ 	p = strstr(line, "size=");
+-	sscanf(p, "size=%lld", &size);
++	if (!p || sscanf(p, "size=%lld", &size) != 1)
++	       return 0;
++
+ 	desc->necaches++;
+ 	desc->ecaches = xrealloc(desc->ecaches,
+ 				 desc->necaches * sizeof(struct cpu_cache));
+-- 
+2.7.4
+
diff -Nru util-linux-2.28.2/debian/patches/series util-linux-2.28.2/debian/patches/series
--- util-linux-2.28.2/debian/patches/series	2016-09-12 22:22:12.000000000 +0100
+++ util-linux-2.28.2/debian/patches/series	2016-09-22 11:45:56.000000000 +0100
@@ -4,3 +4,12 @@
 verbose-tests.patch
 sulogin-fallback-static-sh.patch
 sulogin-lockedpwd.patch
+0001-lscpu-add-drawer-support.patch
+0002-lscpu-add-s390-drawer-testcase.patch
+0003-lscpu-fix-typo-in-summary-output.patch
+0004-lscpu-show-static-and-dynamic-MHz-s390.patch
+0005-lscpu-show-machine-type-s390.patch
+0006-lscpu-show-additional-caches-s390.patch
+0007-lscpu-update-s390-lpar-drawer-testcase.patch
+0008-lscpu-fix-MMHZ-column-entry-within-man-page.patch
+0009-lscpu-make-lookup_cache-more-robust.patch
diff -Nru util-linux-2.28.2/debian/source/include-binaries util-linux-2.28.2/debian/source/include-binaries
--- util-linux-2.28.2/debian/source/include-binaries	1970-01-01 01:00:00.000000000 +0100
+++ util-linux-2.28.2/debian/source/include-binaries	2016-09-22 11:59:15.000000000 +0100
@@ -0,0 +1 @@
+tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz
Binary files /tmp/ZCbyXlRCEF/util-linux-2.28.2/tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz and /tmp/Xt9Xsx_byP/util-linux-2.28.2/tests/ts/lscpu/dumps/s390-lpar-drawer.tar.gz differ
Download as text