Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit c9d197e

Browse files
tebrandtrafaeljw
authored andcommitted
pm-graph: v5.12, fixes
- fix S3 suspend fail double run by using fp.flush to /sys/power/state - when running turbostat print the return value - handle case where html files have binary data - max issues in summary-issues is now 100 (in case there are thousands) - add backup to dmidecode, use /sys/class/dmi/id/ in case /dev/mem fails - update summary page to use full mode (disk-platform instead of disk) Signed-off-by: Todd Brandt <todd.e.brandt@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent 64c6a36 commit c9d197e

File tree

1 file changed

+65
-37
lines changed

1 file changed

+65
-37
lines changed

tools/power/pm-graph/sleepgraph.py

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def ascii(text):
8686
# store system values and test parameters
8787
class SystemValues:
8888
title = 'SleepGraph'
89-
version = '5.11'
89+
version = '5.12'
9090
ansi = False
9191
rs = 0
9292
display = ''
@@ -1181,8 +1181,8 @@ def turbostat(self, s0ixready):
11811181
cmd = self.getExec('turbostat')
11821182
rawout = keyline = valline = ''
11831183
fullcmd = '%s -q -S echo freeze > %s' % (cmd, self.powerfile)
1184-
fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE).stderr
1185-
for line in fp:
1184+
fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE)
1185+
for line in fp.stderr:
11861186
line = ascii(line)
11871187
rawout += line
11881188
if keyline and valline:
@@ -1191,13 +1191,13 @@ def turbostat(self, s0ixready):
11911191
keyline = line.strip().split()
11921192
elif keyline:
11931193
valline = line.strip().split()
1194-
fp.close()
1194+
fp.wait()
11951195
if not keyline or not valline or len(keyline) != len(valline):
11961196
errmsg = 'unrecognized turbostat output:\n'+rawout.strip()
11971197
self.vprint(errmsg)
11981198
if not self.verbose:
11991199
pprint(errmsg)
1200-
return ''
1200+
return (fp.returncode, '')
12011201
if self.verbose:
12021202
pprint(rawout.strip())
12031203
out = []
@@ -1207,7 +1207,7 @@ def turbostat(self, s0ixready):
12071207
if key == 'SYS%LPI' and not s0ixready and re.match('^[0\.]*$', val):
12081208
continue
12091209
out.append('%s=%s' % (key, val))
1210-
return '|'.join(out)
1210+
return (fp.returncode, '|'.join(out))
12111211
def netfixon(self, net='both'):
12121212
cmd = self.getExec('netfix')
12131213
if not cmd:
@@ -4343,7 +4343,8 @@ def createHTMLSummarySimple(testruns, htmlfile, title):
43434343
list[mode]['data'].append([data['host'], data['kernel'],
43444344
data['time'], tVal[0], tVal[1], data['url'], res,
43454345
data['issues'], data['sus_worst'], data['sus_worsttime'],
4346-
data['res_worst'], data['res_worsttime'], pkgpc10, syslpi, wifi])
4346+
data['res_worst'], data['res_worsttime'], pkgpc10, syslpi, wifi,
4347+
(data['fullmode'] if 'fullmode' in data else mode)])
43474348
idx = len(list[mode]['data']) - 1
43484349
if res.startswith('fail in'):
43494350
res = 'fail'
@@ -4449,7 +4450,7 @@ def createHTMLSummarySimple(testruns, htmlfile, title):
44494450
elif idx == iMed[i]:
44504451
tHigh[i] = ' id="%smed" class=medval title="Median"' % tag
44514452
html += td.format("%d" % (list[mode]['data'].index(d) + 1)) # row
4452-
html += td.format(mode) # mode
4453+
html += td.format(d[15]) # mode
44534454
html += td.format(d[0]) # host
44544455
html += td.format(d[1]) # kernel
44554456
html += td.format(d[2]) # time
@@ -5524,14 +5525,17 @@ def executeSuspend(quiet=False):
55245525
if ((mode == 'freeze') or (sv.memmode == 's2idle')) \
55255526
and sv.haveTurbostat():
55265527
# execution will pause here
5527-
turbo = sv.turbostat(s0ixready)
5528+
retval, turbo = sv.turbostat(s0ixready)
5529+
if retval != 0:
5530+
tdata['error'] ='turbostat returned %d' % retval
55285531
if turbo:
55295532
tdata['turbo'] = turbo
55305533
else:
55315534
pf = open(sv.powerfile, 'w')
55325535
pf.write(mode)
55335536
# execution will pause here
55345537
try:
5538+
pf.flush()
55355539
pf.close()
55365540
except Exception as e:
55375541
tdata['error'] = str(e)
@@ -5702,6 +5706,40 @@ def getModes():
57025706
fp.close()
57035707
return modes
57045708

5709+
def dmidecode_backup(out, fatal=False):
5710+
cpath, spath, info = '/proc/cpuinfo', '/sys/class/dmi/id', {
5711+
'bios-vendor': 'bios_vendor',
5712+
'bios-version': 'bios_version',
5713+
'bios-release-date': 'bios_date',
5714+
'system-manufacturer': 'sys_vendor',
5715+
'system-product-name': 'product_name',
5716+
'system-version': 'product_version',
5717+
'system-serial-number': 'product_serial',
5718+
'baseboard-manufacturer': 'board_vendor',
5719+
'baseboard-product-name': 'board_name',
5720+
'baseboard-version': 'board_version',
5721+
'baseboard-serial-number': 'board_serial',
5722+
'chassis-manufacturer': 'chassis_vendor',
5723+
'chassis-version': 'chassis_version',
5724+
'chassis-serial-number': 'chassis_serial',
5725+
}
5726+
for key in info:
5727+
if key not in out:
5728+
val = sysvals.getVal(os.path.join(spath, info[key])).strip()
5729+
if val and val.lower() != 'to be filled by o.e.m.':
5730+
out[key] = val
5731+
if 'processor-version' not in out and os.path.exists(cpath):
5732+
with open(cpath, 'r') as fp:
5733+
for line in fp:
5734+
m = re.match('^model\s*name\s*\:\s*(?P<c>.*)', line)
5735+
if m:
5736+
out['processor-version'] = m.group('c').strip()
5737+
break
5738+
if fatal and len(out) < 1:
5739+
doError('dmidecode failed to get info from %s or %s' % \
5740+
(sysvals.mempath, spath))
5741+
return out
5742+
57055743
# Function: dmidecode
57065744
# Description:
57075745
# Read the bios tables and pull out system info
@@ -5712,6 +5750,8 @@ def getModes():
57125750
# A dict object with all available key/values
57135751
def dmidecode(mempath, fatal=False):
57145752
out = dict()
5753+
if(not (os.path.exists(mempath) and os.access(mempath, os.R_OK))):
5754+
return dmidecode_backup(out, fatal)
57155755

57165756
# the list of values to retrieve, with hardcoded (type, idx)
57175757
info = {
@@ -5727,24 +5767,14 @@ def dmidecode(mempath, fatal=False):
57275767
'baseboard-version': (2, 6),
57285768
'baseboard-serial-number': (2, 7),
57295769
'chassis-manufacturer': (3, 4),
5730-
'chassis-type': (3, 5),
57315770
'chassis-version': (3, 6),
57325771
'chassis-serial-number': (3, 7),
57335772
'processor-manufacturer': (4, 7),
57345773
'processor-version': (4, 16),
57355774
}
5736-
if(not os.path.exists(mempath)):
5737-
if(fatal):
5738-
doError('file does not exist: %s' % mempath)
5739-
return out
5740-
if(not os.access(mempath, os.R_OK)):
5741-
if(fatal):
5742-
doError('file is not readable: %s' % mempath)
5743-
return out
57445775

57455776
# by default use legacy scan, but try to use EFI first
5746-
memaddr = 0xf0000
5747-
memsize = 0x10000
5777+
memaddr, memsize = 0xf0000, 0x10000
57485778
for ep in ['/sys/firmware/efi/systab', '/proc/efi/systab']:
57495779
if not os.path.exists(ep) or not os.access(ep, os.R_OK):
57505780
continue
@@ -5765,11 +5795,7 @@ def dmidecode(mempath, fatal=False):
57655795
fp.seek(memaddr)
57665796
buf = fp.read(memsize)
57675797
except:
5768-
if(fatal):
5769-
doError('DMI table is unreachable, sorry')
5770-
else:
5771-
pprint('WARNING: /dev/mem is not readable, ignoring DMI data')
5772-
return out
5798+
return dmidecode_backup(out, fatal)
57735799
fp.close()
57745800

57755801
# search for either an SM table or DMI table
@@ -5785,22 +5811,15 @@ def dmidecode(mempath, fatal=False):
57855811
break
57865812
i += 16
57875813
if base == 0 and length == 0 and num == 0:
5788-
if(fatal):
5789-
doError('Neither SMBIOS nor DMI were found')
5790-
else:
5791-
return out
5814+
return dmidecode_backup(out, fatal)
57925815

57935816
# read in the SM or DMI table
57945817
try:
57955818
fp = open(mempath, 'rb')
57965819
fp.seek(base)
57975820
buf = fp.read(length)
57985821
except:
5799-
if(fatal):
5800-
doError('DMI table is unreachable, sorry')
5801-
else:
5802-
pprint('WARNING: /dev/mem is not readable, ignoring DMI data')
5803-
return out
5822+
return dmidecode_backup(out, fatal)
58045823
fp.close()
58055824

58065825
# scan the table for the values we want
@@ -6272,7 +6291,10 @@ def find_in_html(html, start, end, firstonly=True):
62726291
return out
62736292

62746293
def data_from_html(file, outpath, issues, fulldetail=False):
6275-
html = open(file, 'r').read()
6294+
try:
6295+
html = open(file, 'r').read()
6296+
except:
6297+
html = ascii(open(file, 'rb').read())
62766298
sysvals.htmlfile = os.path.relpath(file, outpath)
62776299
# extract general info
62786300
suspend = find_in_html(html, 'Kernel Suspend', 'ms')
@@ -6307,8 +6329,9 @@ def data_from_html(file, outpath, issues, fulldetail=False):
63076329
d.end = 999999999
63086330
d.dmesgtext = log.split('\n')
63096331
tp = d.extractErrorInfo()
6310-
for msg in tp.msglist:
6311-
sysvals.errorSummary(issues, msg)
6332+
if len(issues) < 100:
6333+
for msg in tp.msglist:
6334+
sysvals.errorSummary(issues, msg)
63126335
if stmp[2] == 'freeze':
63136336
extra = d.turbostatInfo()
63146337
elist = dict()
@@ -6325,6 +6348,11 @@ def data_from_html(file, outpath, issues, fulldetail=False):
63256348
line = find_in_html(log, '# netfix ', '\n')
63266349
if line:
63276350
extra['netfix'] = line
6351+
line = find_in_html(log, '# command ', '\n')
6352+
if line:
6353+
m = re.match('.* -m (?P<m>\S*).*', line)
6354+
if m:
6355+
extra['fullmode'] = m.group('m')
63286356
low = find_in_html(html, 'freeze time: <b>', ' ms</b>')
63296357
for lowstr in ['waking', '+']:
63306358
if not low:

0 commit comments

Comments
 (0)