Closed sanderjo closed 7 years ago
I've put some debug printing into
sander@Stream-13:~/git/s-tui$ sudo s_tui/s_tui.py
('SJ: file_path', '/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj')
('SJ: file_path', '/sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw')
Traceback (most recent call last):
File "s_tui/s_tui.py", line 791, in <module>
main()
File "s_tui/s_tui.py", line 767, in main
graph_controller = GraphController(args)
File "s_tui/s_tui.py", line 617, in __init__
self.data = GraphData(is_admin=is_admin)
File "/home/sander/git/s-tui/s_tui/GraphData.py", line 60, in __init__
self.rapl_power_reader = RaplPower()
File "/home/sander/git/s-tui/s_tui/RaplPower.py", line 24, in __init__
self.max_power = self.read_max_power_file() / self.MICRO_JAUL_IN_JAUL
File "/home/sander/git/s-tui/s_tui/RaplPower.py", line 36, in read_max_power_file
return float(self.read_measurement(self.intel_rapl_package_max_energy_file))
File "/home/sander/git/s-tui/s_tui/RaplPower.py", line 29, in read_measurement
value = file.read()
IOError: [Errno 61] No data available
OK, so:
('SJ: file_path', '/sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj')
('SJ: file_path', '/sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw')
Let's check them:
sander@Stream-13:~/git/s-tui$ ll /sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj
-r--r--r-- 1 root root 4096 aug 30 20:59 /sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj
sander@Stream-13:~/git/s-tui$ cat /sys/class/powercap/intel-rapl/intel-rapl:0/energy_uj
106163220448
and:
sander@Stream-13:~/git/s-tui$ ll /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw
-r--r--r-- 1 root root 4096 aug 30 20:59 /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw
sander@Stream-13:~/git/s-tui$ cat /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw
cat: '/sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw': No data available
... No data available
doesn't look good, does it?
I checked on my Ubuntu 14.04 VPS ( Xeon E5335, ... from 2007, so 10 years old ):
s-tui does run: no error, and ASCII art output. Good.
/sys/class/powercap/ is empty ... so apparently s-tui can work without that information. So maybe just except/pass the error?
sander@haring:~$ ll /sys/class/powercap/
total 0
drwxr-xr-x 2 root root 0 Aug 31 06:59 ./
drwxr-xr-x 49 root root 0 Aug 31 06:59 ../
sander@haring:~$
Thank you for the detailed information. It really helps.
I'll add a try catch for this case so it will not crash in case information is not available.
Also I'll try to see how getting the information is possible on 17.04
Also I'll try to see how getting the information is possible on 17.04
What does /sys/class/powercap/intel-rapl/intel-rapl:0/constraint_0_max_power_uw provide?
RAPL = Running Average Power Limit
... but what is constraint_0_max_power_uw
?
Theoretically, this should be the highest power draw. But in the next version I'll just use the maximum recorded power draw per session.
With a try/except in read_max_power_file() I got s-tui working:
With -1
def read_max_power_file(self):
if not self.is_available:
return -1
try:
return float(self.read_measurement(self.intel_rapl_package_max_energy_file))
except:
return -1
it is working, but without a powerline:
With the value 2.000.000 micro-Joule (not "JAUL" ...) = 2 J/s = 2 Watt (about 25% of the Celeron's TDP), I get a useable powerline:
def read_max_power_file(self):
if not self.is_available:
return -1
try:
return float(self.read_measurement(self.intel_rapl_package_max_energy_file))
except:
return 2 * 1E6 # micro-Joule
Thanks.It will be fixed in the upcoming version. Among many other things. The max_power will be dynamic according the the highest recorded power reading.
Please update whether the new version has fixed this issue.
Yes, works on Ubuntu 17.04. Nice!
About "Power":
Shall I close this issue? Do you want a separate ticket for the high Wattage?
Update
Power is now at 57000 Watt ... is it adding up?
Seems like a scale problem. 18w / 57w could make sense. Leave this open for now.
This laptop is tablet-style: Celeron (TDP 7W), eMMC (no disk), screen, no fan. So: low power consumption. The tool powertop "The battery reports a discharge rate of 4.58 W" ... that seems about right.
18 or 57 Watt seems unlikely to me.
This is my hypothesis by looking at the behaviour, not at the code:
s-tui measures the power. If it is higher than before, it adds that power to the highest power. Reason for my hypothesis: the power on the y-axis goes up at each new high power. See screen shot: 4 "highs" (sample 1, 2, 3 and around 20) ... adding up to 19(000) (4 times my 4.5 W) Solution: replace the highest power.
Could you show the result of cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj
Certainly:
sander@Stream-13:~$ cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj
131675646336
sander@Stream-13:~$
sander@Stream-13:~$
sander@Stream-13:~$ cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj
10664333056
sander@Stream-13:~$
sander@Stream-13:~$
sander@Stream-13:~$ cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj
21649881856
sander@Stream-13:~$
sander@Stream-13:~$ cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj
30872604544
sander@Stream-13:~$
and
sander@Stream-13:~$ while true; do cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj; sleep 1; done
70776118784
74222052832
78350678208
82280579104
85594083136
89157451712
92464998400
95798505536
100182033664
104386319040
107929126912
111649581632
114968659200
119037658688
122375253344
126126616864
129893506592
^C
sander@Stream-13:~$ while true; do cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj; sleep 1; done
134905985312
741851264
4615478400
8544396032
11221446784
15208889280
19242829344
^C
sander@Stream-13:~$
741851264
4615478400
8544396032
11221446784
15208889280
19242829344
These readings are very strange, energy_uj should hold the energy in micro-joules. They shouldn't be changing so dramatically. I don't have an idea why is this so sporadic.
Ah, "uj" = micro-Joule?
I tried again: value goes up and up, and then a rollover after 134258672512 = 1F4270C380 and after 132652438176 = 1EE2B392A0. So safe to say: value grows to 1FFFFFFFF (=137438953471 = 2^37-1) That is 37 bits
I'll update if I have more ideas.
sander@Stream-13:~$ while true; do cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj; sleep 1; done
71742470720
76885335520
80078047008
84503022368
89489333312
93804347328
100096093248
104374493792
108375847296
113604115296
117854383776
123638434432
126362131328
129743774848
134258672512
582493184
3892650848
8079320960
10567535552
13249817056
16887961312
19145489856
21722489376
24851344512
27078493568
31714767008
37248148320
41905850528
45147435168
49677220608
53394730240
56726185280
61558896160
65259616960
68739833088
73521948576
77626130240
80836133952
87490628384
91879771904
97222755328
103772152384
109235596640
114689206112
122660332640
127452004352
132652438176
1006201152
6640314336
12222023744
19994104160
25916703424
31845432384
38156132384
If I get the delta between 1-sec-samples, and divide by 1 million (because; micro-Joules), I get something steady & reasonable:
sander@Stream-13:~$ while true; do BLA=`cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj`; expr `expr $BLA - $OLD` / 1000111 ; OLD=$BLA; sleep 1; done
-30327
4124
3409
3294
3051
3820
4869
4161
5084
4213
4131
4244
5013
5296
4550
4041
As my system is a Celeron laptop, with TDP of 7 Watt, ... divide by 1000 once again:
sander@Stream-13:~$ while true; do BLA=`cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj`; expr `expr $BLA - $OLD` / 1000111222 ; OLD=$BLA; sleep 1; done
-54
4
3
3
3
3
2
2
2
3
5
5
4
4
4
4
4
4
4
... that looks rights: around 4 Watt.
If correct, I don't have micro-Joules, but nano-Joules ?
So it would seem.
If it differs between systems there should probably be a scaling factor somewhere.
It seems Linux kernel dependent :-1:
I rebooted my Celeron laptop into Linux 4.10 (instead of 4.13), I now I get other results: the values grow less fast:
$ uname -a ; while true; do cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj; sleep 1; done
Linux Stream-13 4.10.0-32-generic #36-Ubuntu SMP Tue Aug 8 12:10:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
251549504
251835424
252140480
252445280
252726752
252983040
253236000
253483776
253731392
254029440
254309056
254549792
254787968
255056480
if I get the delta, and divide by 1 million, it's always 0 or 1 (1 when running 'stress'):
$ uname -a; OLD=0; while true; do BLA=`cat /sys/class/powercap/intel-rapl/intel-rapl\:0/energy_uj`; expr `expr $BLA - $OLD` / 1000111 ; OLD=$BLA; sleep 1; done
Linux Stream-13 4.10.0-32-generic #36-Ubuntu SMP Tue Aug 8 12:10:06 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
582
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
0
0
0
And s-tui is now at 0 or 1 or 2 Watt:
Linux 4.11 and 4.12 behave like 4.10.
So something changed in Linux 4.13.
$ ./sj_get_energy_uh.sh
Linux Stream-13 4.11.0-041100-generic #201705041534 SMP Thu May 4 19:36:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
76413280
76
76720224
0
77024544
0
77342304
0
77627552
0
77893504
0
78212896
0
78514464
0
78925920
0
79678720
and
$ ./sj_get_energy_uh.sh
Linux Stream-13 4.12.0-041200-generic #201707022031 SMP Mon Jul 3 00:32:52 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
53331552
53
53551872
0
53777216
0
54012640
0
54234176
0
54461184
0
54736160
0
Its worth testing 4.13 on other devices to see if perhaps only low power Celerons are effected.
I am also considering implementing a different method of getting the power by directly reading the MSRs, but this requires root.
Ouch, it's something else: not kernel related, but suspend related ...
This is too strange. Let's not try to solve it.
After fresh start into Linux 4.13, the output was correct:
$ ./sj_get_energy_uh.sh
Linux Stream-13 4.13.0-041300-generic #201709031731 SMP Sun Sep 3 21:33:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
195996128
195
196356512
0
196674976
0
197004704
0
197298336
0
197734528
0
198408960
0
199031200
0
199661792
0
On a second try also:
$ ./sj_get_energy_uh.sh
Linux Stream-13 4.13.0-041300-generic #201709031731 SMP Sun Sep 3 21:33:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
205099680
205
205389824
0
205726080
0
But after a suspend (of only 10 seconds), I get the wrong output
$ ./sj_get_energy_uh.sh
Linux Stream-13 4.13.0-041300-generic #201709031731 SMP Sun Sep 3 21:33:09 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
64985279808
64978
67683254784
2697
70513451872
2829
79373755584
8859
82126833024
2752
84931378592
2804
Thank you for the help with this issue.
I have pushed a small update to get the power read in the debug log. If it's not too much trouble, could you run it for a few seconds and print the log. w/ and w/o stress.
I am interested to see why in the correct case only 1/2 watts are shown.
This is on my laptop which has suspended after reboot ... so big numbers.
BRB with a fresh boot
Thanks,
I meant the output of _s-tui.log when running with the debug flag python -m s_tui.s_tui -d
(After git pull)
(All on a fresh git clone
)
sander@Stream-13:~/git/s-tui-16sept2017$ pwd
/home/sander/git/s-tui-16sept2017
sander@Stream-13:~/git/s-tui-16sept2017$ python -m s_tui.s_tui -d
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/sander/git/s-tui-16sept2017/s_tui/s_tui.py", line 668, in <module>
main()
File "/home/sander/git/s-tui-16sept2017/s_tui/s_tui.py", line 628, in main
graph_controller.main()
File "/home/sander/git/s-tui-16sept2017/s_tui/s_tui.py", line 496, in main
self.loop.run()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 278, in run
self._run()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 376, in _run
self.event_loop.run()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 682, in run
self._loop()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 710, in _loop
self._entering_idle()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 671, in _entering_idle
callback()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 564, in entering_idle
self.draw_screen()
File "/usr/local/lib/python2.7/dist-packages/urwid/main_loop.py", line 578, in draw_screen
canvas = self._topmost_widget.render(self.screen_size, focus=True)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 1751, in render
canv = get_delegate(self).render(size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/decoration.py", line 225, in render
canv = self._original_widget.render(size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 1751, in render
canv = get_delegate(self).render(size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 1526, in render
canv = w.render((maxcol, rows), focus=focus and item_focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 2085, in render
focus = focus and self.focus_position == i)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/decoration.py", line 225, in render
canv = self._original_widget.render(size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/decoration.py", line 566, in render
canv = self._original_widget.render((maxcol,)+size[1:], focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 2085, in render
focus = focus and self.focus_position == i)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 1751, in render
canv = get_delegate(self).render(size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 1526, in render
canv = w.render((maxcol, rows), focus=focus and item_focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 1526, in render
canv = w.render((maxcol, rows), focus=focus and item_focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 1751, in render
canv = get_delegate(self).render(size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/container.py", line 2085, in render
focus = focus and self.focus_position == i)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "s_tui/ComplexBarGraphs.py", line 35, in render
canvas = super(ScalableBarGraph, self).render(size, focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/widget.py", line 141, in cached_render
canv = fn(self, size, focus=focus)
File "/usr/local/lib/python2.7/dist-packages/urwid/graphics.py", line 547, in render
disp = self.calculate_display((maxcol, maxrow))
File "/usr/local/lib/python2.7/dist-packages/urwid/graphics.py", line 390, in calculate_display
maxrow)
File "/usr/local/lib/python2.7/dist-packages/urwid/graphics.py", line 633, in calculate_bargraph_display
segments = scale_bar_values(bar, top, maxrow)
File "/usr/local/lib/python2.7/dist-packages/urwid/graphics.py", line 794, in scale_bar_values
return [maxrow - int(float(v) * maxrow / top + 0.5) for v in bar]
ZeroDivisionError: float division by zero
On 7th try, it started normally
I had to rename _s-tui.log to _s-tui.txt to let github me upload it:
Thanks.
Looks like the reason for the crash is values between 0 and 1 read for power consumption (This might be correct for a low power cpu, my 35W TDP cpu idles at ~3w).
Max power values should be rounded up to prevent the crash. I'll open a new issue to track this.
FWIW: output of sudo powerstat -d 2
shows (total?) power of 6-8 Watt.
Yes. It shows total power based on battery drain. Makes sense that the CPU wiil ne ~1w
On my Ubuntu 17.04 (a Celeron laptop), I get a Traceback, with
IOError: [Errno 61] No data available
. This happens for the pip and the github version. A--help
works.Any help / tips?
and
and
and