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