Bug 1518762 - Avoid error in psutil.disk_io_counters in resourcemonitor. r=ahal, a=jcristau DONTBUILD
authorRob Wu <rob@robwu.nl>
Tue, 22 Jan 2019 16:16:39 +0000
changeset 537283 ceed8b8a562b3cfba72f29a1afc36469ea0c5c77
parent 537282 02d9056ba76c565c57334ae0df1246d52823cc43
child 537284 2265b195d34826337f8d22204862556303ede209
push id2123
push userjcristau@mozilla.com
push dateFri, 09 Aug 2019 14:45:08 +0000
treeherdermozilla-release@ceed8b8a562b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersahal, jcristau
bugs1518762
milestone68.0.2
Bug 1518762 - Avoid error in psutil.disk_io_counters in resourcemonitor. r=ahal, a=jcristau DONTBUILD Imports https://github.com/giampaolo/psutil/commit/8f99f3782663959062ee868bbfdbc336307a3a4d to fix a bug with Linux kernel 4.18+, https://github.com/giampaolo/psutil/issues/1354 (to be included in a future release of psutil, version 5.5.0) Differential Revision: https://phabricator.services.mozilla.com/D16028 [jcristau: re-applying this change which was accidentally reverted in https://hg.mozilla.org/releases/mozilla-release/rev/e2030db2e502]
third_party/python/psutil/psutil/_pslinux.py
--- a/third_party/python/psutil/psutil/_pslinux.py
+++ b/third_party/python/psutil/psutil/_pslinux.py
@@ -1046,28 +1046,30 @@ def disk_io_counters():
         # On Linux 2.4 each line has always 15 fields, e.g.:
         # "3     0   8 hda 8 8 8 8 8 8 8 8 8 8 8"
         # On Linux 2.6+ each line *usually* has 14 fields, and the disk
         # name is in another position, like this:
         # "3    0   hda 8 8 8 8 8 8 8 8 8 8 8"
         # ...unless (Linux 2.6) the line refers to a partition instead
         # of a disk, in which case the line has less fields (7):
         # "3    1   hda1 8 8 8 8"
+        # 4.18+ has 4 fields added:
+        # "3    0   hda 8 8 8 8 8 8 8 8 8 8 8 0 0 0 0"
         # See:
         # https://www.kernel.org/doc/Documentation/iostats.txt
         # https://www.kernel.org/doc/Documentation/ABI/testing/procfs-diskstats
         fields = line.split()
         fields_len = len(fields)
         if fields_len == 15:
             # Linux 2.4
             name = fields[3]
             reads = int(fields[2])
             (reads_merged, rbytes, rtime, writes, writes_merged,
                 wbytes, wtime, _, busy_time, _) = map(int, fields[4:14])
-        elif fields_len == 14:
+        elif fields_len == 14 or fields_len == 18:
             # Linux 2.6+, line referring to a disk
             name = fields[2]
             (reads, reads_merged, rbytes, rtime, writes, writes_merged,
                 wbytes, wtime, _, busy_time, _) = map(int, fields[3:14])
         elif fields_len == 7:
             # Linux 2.6+, line referring to a partition
             name = fields[2]
             reads, rbytes, writes, wbytes = map(int, fields[3:])