Merge lp:~xnox/landscape-client/s390x into lp:~landscape/landscape-client/trunk

Proposed by Dimitri John Ledkov
Status: Merged
Merged at revision: 828
Proposed branch: lp:~xnox/landscape-client/s390x
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 113 lines (+92/-1)
2 files modified
landscape/monitor/processorinfo.py (+52/-1)
landscape/monitor/tests/test_processorinfo.py (+40/-0)
To merge this branch: bzr merge lp:~xnox/landscape-client/s390x
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Alberto Donato (community) Approve
Review via email: mp+284960@code.launchpad.net

Description of the change

Add support for s390x CPU architecture

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

Looks good, +1

A few nits inline.

Also, make lint reports a few errors:

landscape/monitor/tests/test_processorinfo.py:370:1: E302 expected 2 blank lines, found 1
landscape/monitor/tests/test_processorinfo.py:379:64: W291 trailing whitespace
landscape/monitor/tests/test_processorinfo.py:380:80: E501 line too long (89 characters)
landscape/monitor/tests/test_processorinfo.py:381:80: E501 line too long (95 characters)
landscape/monitor/tests/test_processorinfo.py:382:80: E501 line too long (90 characters)
landscape/monitor/tests/test_processorinfo.py:383:80: E501 line too long (97 characters)
landscape/monitor/tests/test_processorinfo.py:384:80: E501 line too long (94 characters)
landscape/monitor/tests/test_processorinfo.py:385:80: E501 line too long (95 characters)
landscape/monitor/tests/test_processorinfo.py:393:80: E501 line too long (84 characters)
landscape/monitor/tests/test_processorinfo.py:427:80: E501 line too long (164 characters)
landscape/monitor/tests/test_processorinfo.py:447:80: E501 line too long (164 characters)
landscape/monitor/tests/test_processorinfo.py:474:80: E501 line too long (139 characters)
landscape/monitor/processorinfo.py:278:15: E225 missing whitespace around operator
landscape/monitor/processorinfo.py:291:1: W293 blank line contains whitespace

Some are related to the sample content in the test case. I think you can drop those lines (or just cut out some of the content, since they're not actually considered by the parser.

review: Approve
Revision history for this message
Adam Collard (adam-collard) wrote :

Can we extract an (X86 equivalent) value for cache-size?

review: Needs Information
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

We are targeting these two microprocessors:
https://en.wikipedia.org/wiki/IBM_z13_(microprocessor)
https://en.wikipedia.org/wiki/IBM_zEC12_(microprocessor)

L1,L2 caches are per core, L3 is shared. The L3 shared cache is not reported, but for the below z chip it would have been 64MB.

There is also storage controller per compute drawer with like extra 960MiB of L4 cache, per two chips, thus 480 MiB per core.

The cache-size reported up to landscape for x86_64 for my cpu is the shared L3 cache, for z that kind of matches the shared L3 cache as reported:
cache4 : level=3 type=Unified scope=Shared size=65536K line_size=256 associativity=16

Or do you want the largest one? Cause then it would be L4 cache (non-existant on x86_64) from the co-processing unit:
cache5 : level=4 type=Unified scope=Shared size=491520K line_size=256 associativity=30

I guess i should go for the largest one? Cause i guess ultimately cpuinfo simply reports the largest cache. Then for z13 that would be 480 MiB. I'll add that in, just to show off really how big these things are. =)

lp:~xnox/landscape-client/s390x updated
829. By Dimitri John Ledkov

pep8, review comments, and add largest cache-size.

Revision history for this message
Dimitri John Ledkov (xnox) wrote :

Please re-review and merge. All comments addressed.

Revision history for this message
Adam Collard (adam-collard) :
review: Approve
lp:~xnox/landscape-client/s390x updated
830. By Dimitri John Ledkov

fix copy&paste, and try to hint string with #noqa

831. By Dimitri John Ledkov

use the right noqa

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/monitor/processorinfo.py'
2--- landscape/monitor/processorinfo.py 2014-04-30 15:58:40 +0000
3+++ landscape/monitor/processorinfo.py 2016-02-05 10:14:41 +0000
4@@ -263,7 +263,58 @@
5 return processors
6
7
8+class S390XMessageFactory:
9+ """Factory for s390x-based processors provides processor information.
10+
11+ @param source_filename: The file name of the data source.
12+ """
13+
14+ def __init__(self, source_filename):
15+ self._source_filename = source_filename
16+
17+ def create_message(self):
18+ """Returns a list containing information about each processor."""
19+ processors = []
20+ vendor = None
21+ cache_size = 0
22+ file = open(self._source_filename)
23+
24+ try:
25+ current = None
26+
27+ for line in file:
28+ parts = line.split(":", 1)
29+ key = parts[0].strip()
30+
31+ if key == "vendor_id":
32+ vendor = parts[1].strip()
33+ continue
34+
35+ if key.startswith("cache"):
36+ for word in parts[1].split():
37+ if word.startswith("size="):
38+ cache_size = int(word[5:-1])
39+ continue
40+
41+ if key.startswith("processor "):
42+ id = int(key.split()[1])
43+ model = parts[1].split()[-1]
44+ current = {
45+ "processor-id": id,
46+ "model": model,
47+ "vendor": vendor,
48+ "cache-size": cache_size,
49+ }
50+ processors.append(current)
51+ continue
52+ finally:
53+ file.close()
54+
55+ return processors
56+
57+
58 message_factories = [("(arm*|aarch64)", ARMMessageFactory),
59 ("ppc(64)?", PowerPCMessageFactory),
60 ("sparc[64]", SparcMessageFactory),
61- ("i[3-7]86|x86_64", X86MessageFactory)]
62+ ("i[3-7]86|x86_64", X86MessageFactory),
63+ ("s390x", S390XMessageFactory)]
64
65=== modified file 'landscape/monitor/tests/test_processorinfo.py'
66--- landscape/monitor/tests/test_processorinfo.py 2014-05-01 14:10:46 +0000
67+++ landscape/monitor/tests/test_processorinfo.py 2016-02-05 10:14:41 +0000
68@@ -368,6 +368,46 @@
69 self.assertEqual(processor_1["processor-id"], 1)
70
71
72+class S390XMessageTest(LandscapeTest):
73+ """Tests for s390x message builder."""
74+
75+ helpers = [MonitorHelper]
76+
77+ S390X = """
78+vendor_id : IBM/S390
79+# processors : 4
80+bogomips per cpu: 3033.00
81+features : esan3 zarch stfle msa ldisp eimm dfp etf3eh highgprs
82+cache0 : level=1 type=Data scope=Private size=128K line_size=256 associativity=8
83+cache1 : level=1 type=Instruction scope=Private size=96K line_size=256 associativity=6
84+cache2 : level=2 type=Data scope=Private size=2048K line_size=256 associativity=8
85+cache3 : level=2 type=Instruction scope=Private size=2048K line_size=256 associativity=8
86+cache4 : level=3 type=Unified scope=Shared size=65536K line_size=256 associativity=16
87+cache5 : level=4 type=Unified scope=Shared size=491520K line_size=256 associativity=30
88+processor 0: version = FF, identification = 018F67, machine = 2964
89+processor 1: version = FF, identification = 018F67, machine = 2964
90+processor 2: version = FF, identification = 018F67, machine = 2964
91+processor 3: version = FF, identification = 018F67, machine = 2964
92+""" # noqa
93+
94+ def test_read_sample_s390x_data(self):
95+ """Ensure the plugin can parse /proc/cpuinfo from an IBM zSeries machine."""
96+ filename = self.makeFile(self.S390X)
97+ plugin = ProcessorInfo(machine_name="s390x",
98+ source_filename=filename)
99+ message = plugin.create_message()
100+ self.assertEqual("processor-info", message["type"])
101+ self.assertEqual(4, len(message["processors"]))
102+
103+ for id, processor in enumerate(message["processors"]):
104+ self.assertEqual(
105+ {"vendor": "IBM/S390",
106+ "model": "2964",
107+ "processor-id": id,
108+ "cache-size": 491520,
109+ }, processor)
110+
111+
112 class X86MessageTest(LandscapeTest):
113 """Test for x86-specific message handling."""
114

Subscribers

People subscribed via source and target branches

to all changes: