iotop/SOURCES/iotop-0.6-gitab35334d.patch
2022-05-10 10:31:38 +00:00

61 lines
2.5 KiB
Diff

diff -up iotop-0.6/iotop/data.py.gitab35334d iotop-0.6/iotop/data.py
--- iotop-0.6/iotop/data.py.gitab35334d 2022-02-15 21:51:20.828263067 +0100
+++ iotop-0.6/iotop/data.py 2022-02-15 21:51:20.830263041 +0100
@@ -453,3 +453,11 @@ class ProcessList(DumpableObject):
def clear(self):
self.processes = {}
+
+
+def sysctl_task_delayacct():
+ try:
+ with open('/proc/sys/kernel/task_delayacct') as f:
+ return bool(int(f.read().strip()))
+ except FileNotFoundError:
+ return None
diff -up iotop-0.6/iotop/ui.py.gitab35334d iotop-0.6/iotop/ui.py
--- iotop-0.6/iotop/ui.py.gitab35334d 2022-02-15 21:51:20.828263067 +0100
+++ iotop-0.6/iotop/ui.py 2022-02-15 21:51:56.415788740 +0100
@@ -30,7 +30,7 @@ import signal
import sys
import time
-from iotop.data import find_uids, TaskStatsNetlink, ProcessList, Stats
+from iotop.data import find_uids, TaskStatsNetlink, ProcessList, Stats, sysctl_task_delayacct
from iotop.data import ThreadInfo
from iotop.version import VERSION
from iotop import ioprio
@@ -377,7 +377,7 @@ class IOTopUI(object):
def format(p):
stats = format_stats(self.options, p, self.process_list.duration)
io_delay, swapin_delay, read_bytes, write_bytes = stats
- if Stats.has_blkio_delay_total:
+ if self.has_swapin_io:
delay_stats = '%7s %7s ' % (swapin_delay, io_delay)
else:
delay_stats = ' ?unavailable? '
@@ -431,6 +431,14 @@ class IOTopUI(object):
pid += 'TID'
titles = [pid, ' PRIO', ' USER', ' DISK READ', ' DISK WRITE',
' SWAPIN', ' IO', ' COMMAND']
+ self.has_swapin_io = Stats.has_blkio_delay_total
+ if self.has_swapin_io:
+ # Linux kernels without the sysctl return None and
+ # iotop just uses the heuristic for those versions.
+ # Linux kernels with the sysctl return True or False
+ # and iotop then uses the sysctl value instead.
+ if sysctl_task_delayacct() == False:
+ self.has_swapin_io = False
lines = self.get_data()
if self.options.time:
titles = [' TIME'] + titles
@@ -464,7 +472,7 @@ class IOTopUI(object):
title = title[:remaining_cols]
remaining_cols -= len(title)
self.win.addstr(title, attr)
- if Stats.has_blkio_delay_total:
+ if self.has_swapin_io:
status_msg = None
else:
status_msg = ('CONFIG_TASK_DELAY_ACCT '