do not show DELAY_ACCT error for non-existent pids

This commit is contained in:
Michal Hlavinka 2022-02-09 10:03:14 +01:00
parent fd157b402f
commit a073b72b62
3 changed files with 118 additions and 4 deletions

View File

@ -0,0 +1,43 @@
diff --git a/iotop/data.py b/iotop/data.py
index f5496d0..665397c 100644
--- a/iotop/data.py
+++ b/iotop/data.py
@@ -43,7 +43,6 @@ except (ImportError, RuntimeError):
# Check for requirements:
# o Linux >= 2.6.20 with I/O accounting and VM event counters
#
-
ioaccounting = os.path.exists('/proc/self/io')
try:
@@ -90,7 +89,7 @@ class Stats(DumpableObject):
('cancelled_write_bytes', 264)
]
- has_blkio_delay_total = False
+ has_blkio_delay_total = None
def __init__(self, task_stats_buffer):
sd = self.__dict__
@@ -101,7 +100,7 @@ class Stats(DumpableObject):
# This is a heuristic to detect if CONFIG_TASK_DELAY_ACCT is enabled in
# the kernel.
if not Stats.has_blkio_delay_total:
- Stats.has_blkio_delay_total = self.blkio_delay_total != 0
+ Stats.has_blkio_delay_total = sysctl_task_delayacct()
def accumulate(self, other_stats, destination, coeff=1):
"""Update destination from operator(self, other_stats)"""
diff --git a/iotop/ui.py b/iotop/ui.py
index 77f82c7..d9dc044 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -514,7 +514,7 @@ class IOTopUI(object):
else:
self.win.erase()
- if self.has_swapin_io:
+ if self.has_swapin_io is not False:
status_msg = None
else:
status_msg = ('CONFIG_TASK_DELAY_ACCT '

View File

@ -0,0 +1,64 @@
diff --git a/iotop/ui.py b/iotop/ui.py
index 7ae8bad..77f82c7 100644
--- a/iotop/ui.py
+++ b/iotop/ui.py
@@ -224,6 +224,12 @@ class IOTopUI(object):
new_sorting_key += delta
new_sorting_key = max(0, new_sorting_key)
new_sorting_key = min(len(IOTopUI.sorting_keys) - 1, new_sorting_key)
+ if not self.has_swapin_io:
+ if new_sorting_key in (5, 6):
+ if delta <= 0:
+ new_sorting_key = 4
+ elif delta > 0:
+ new_sorting_key = 7
return new_sorting_key
# I wonder if switching to urwid for the display would be better here
@@ -421,14 +427,22 @@ 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
+ format = '%%%dd' % MAX_PID_WIDTH
+ params = p.pid,
+ format += ' %4s'
+ params += p.get_ioprio(),
+ format += ' %-8s'
+ params += p.get_user()[:8],
+ format += ' %11s %11s'
+ params += read_bytes, write_bytes
if self.has_swapin_io:
- delay_stats = '%7s %7s ' % (swapin_delay, io_delay)
- else:
- delay_stats = ' ?unavailable? '
- pid_format = '%%%dd' % MAX_PID_WIDTH
- line = (pid_format + ' %4s %-8s %11s %11s %s') % (
- p.pid, p.get_ioprio(), p.get_user()[:8], read_bytes,
- write_bytes, delay_stats)
+ format += ' %7s %7s'
+ params += swapin_delay, io_delay
+ elif self.options.batch:
+ format += ' %s '
+ params += '?unavailable?',
+ format += ' '
+ line = format % (params)
cmdline = p.get_cmdline()
if not self.options.batch:
remaining_length = self.width - len(line)
@@ -481,6 +495,7 @@ class IOTopUI(object):
# and iotop then uses the sysctl value instead.
if sysctl_task_delayacct() == False:
self.has_swapin_io = False
+ self.adjust_sorting_key(0)
lines = self.get_data()
if self.options.time:
titles = [' TIME'] + titles
@@ -571,6 +586,8 @@ class IOTopUI(object):
pos = 0
remaining_cols = self.width
for i in range(len(titles)):
+ if not self.has_swapin_io and i in (5, 6):
+ continue
attr = curses.A_REVERSE
title = titles[i]
if i == self.sorting_key:

View File

@ -1,6 +1,6 @@
Name: iotop Name: iotop
Version: 0.6 Version: 0.6
Release: 30%{?dist} Release: 31%{?dist}
Summary: Top like utility for I/O Summary: Top like utility for I/O
License: GPLv2+ License: GPLv2+
URL: http://guichaz.free.fr/iotop/ URL: http://guichaz.free.fr/iotop/
@ -17,6 +17,11 @@ Patch2: iotop-python3build.patch
# sent upstream, iotop <= 0.6, rhbz#1285088 # sent upstream, iotop <= 0.6, rhbz#1285088
Patch3: iotop-0.3.2-batchprintutf8.patch Patch3: iotop-0.3.2-batchprintutf8.patch
# from upstream, iotop <= 0.6
Patch4: iotop-0.6-git9c49d59.patch
# rhbz#1679201
Patch5: iotop-0.6-delayacctmsg.patch
#BuildArch: noarch #BuildArch: noarch
BuildRequires: python3-devel BuildRequires: python3-devel
BuildRequires: gcc BuildRequires: gcc
@ -29,10 +34,9 @@ show of behalf of which process is the I/O going on.
%prep %prep
%setup -n %{name}-%{version} %setup -n %{name}-%{version}
#%patch0 -p1 -b .noendcurses
#%patch1 -p1 -b .python3
#%patch2 -p1
%patch3 -p1 -b .batchprintutf8 %patch3 -p1 -b .batchprintutf8
%patch4 -p1 -b .git9c49d59
%patch5 -p1 -b .delayacctmsg
%build %build
%py3_build %py3_build
@ -48,6 +52,9 @@ show of behalf of which process is the I/O going on.
%{_mandir}/man8/iotop.* %{_mandir}/man8/iotop.*
%changelog %changelog
* Wed Feb 09 2022 Michal Hlavinka <mhlavink@redhat.com> - 0.6-31
- do not show DELAY_ACCT error for non-existent pids
* Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.6-30 * Thu Jan 20 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.6-30
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild