From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: References: <20180208082455.30383-1-mkl@pengutronix.de> <20180208090333.dex5bcxt73c2dp4b@falbala.home.lespocky.de> <2dd26f58-a7a3-667d-0968-7b835499b629@pengutronix.de> <20180208101903.h6fgxgtidnqqwxou@falbala.home.lespocky.de> From: Marc Kleine-Budde Message-ID: Date: Thu, 8 Feb 2018 11:33:33 +0100 MIME-Version: 1.0 In-Reply-To: <20180208101903.h6fgxgtidnqqwxou@falbala.home.lespocky.de> Subject: Re: [ptxdist] [PATCH] htop: version bump 2.0.2 -> 2.1.0 List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Content-Type: multipart/mixed; boundary="===============1491873763==" Errors-To: ptxdist-bounces@pengutronix.de Sender: "ptxdist" To: ptxdist@pengutronix.de, post@lespocky.de This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --===============1491873763== Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="cOU4CVYCo61RJMOAavKYuvFQalgj7Box1" This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --cOU4CVYCo61RJMOAavKYuvFQalgj7Box1 Content-Type: multipart/mixed; boundary="1GXPjHxT92B2EwiI93fOZlBXWlXDkaK3S"; protected-headers="v1" From: Marc Kleine-Budde To: ptxdist@pengutronix.de, post@lespocky.de Message-ID: Subject: Re: [ptxdist] [PATCH] htop: version bump 2.0.2 -> 2.1.0 References: <20180208082455.30383-1-mkl@pengutronix.de> <20180208090333.dex5bcxt73c2dp4b@falbala.home.lespocky.de> <2dd26f58-a7a3-667d-0968-7b835499b629@pengutronix.de> <20180208101903.h6fgxgtidnqqwxou@falbala.home.lespocky.de> In-Reply-To: <20180208101903.h6fgxgtidnqqwxou@falbala.home.lespocky.de> --1GXPjHxT92B2EwiI93fOZlBXWlXDkaK3S Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: quoted-printable On 02/08/2018 11:19 AM, Alexander Dahl wrote: > On Thu, Feb 08, 2018 at 10:17:31AM +0100, Marc Kleine-Budde wrote: >> Have you enabled CONFIG_TASK_XACCT and CONFIG_TASK_IO_ACCOUNTING? >=20 > Didn't have that before. I get some values now, although I'm not sure > how to interpret those. I should probably look in the htop > documentation again. But thanks for the hint, I guess htop can show > even more interesting things, I did not know it can, yet. :-) Luckily I've recently collected all needed information: > RCHAR - Number of bytes the process has read > WCHAR - Number of bytes the process has written > SYSCR - Number of read(2) syscalls for the process > SYSCW - Number of write(2) syscalls for the process > RBYTES - Bytes of read(2) I/O for the process > WBYTES - Bytes of write(2) I/O for the process > CNCLWB - Bytes of cancelled write(2) I/O >=20 > IO_READ_RATE - The I/O rate of read(2) in bytes per second for the > process > IO_WRITE_RATE - The I/O rate of write(2) in bytes per second for the > process > IO_RATE - Total I/O rate in bytes per second >=20 > However if you want machine readable output, you have two options: >=20 > 1) > Parse /proc/$PID/io directly, which correspond to the absolute numbers > from htop. The *_RATE values are calculated by htop from the absolute > numbers. >=20 > See man-page of proc(5) for more information about /proc/$PID/io: >=20 >> > rchar: characters read >> > The number of bytes which this task has caused= to >> > be read from storage. This is simply the sum = of >> > bytes which this process passed to read(2) = and >> > similar system calls. It includes things such = as >> > terminal I/O and is unaffected by whether or = not >> > actual physical disk I/O was required (the r= ead >> > might have been satisfied from pagecache). >> >=20 >> > wchar: characters written >> > The number of bytes which this task has caused,= or >> > shall cause to be written to disk. Simi= lar >> > caveats apply here as with rchar. >=20 > Counts all read/write done through files (_including_ pseudo files like= > /dev/zero, /dev/null, named pipes). >=20 >> > syscr: read syscalls >> > Attempt to count the number of read I/O ope= ra=E2=80=90 >> > tions=E2=80=94that is, system calls such as r= ead(2) and >> > pread(2). >> >=20 >> > syscw: write syscalls >> > Attempt to count the number of write I/O ope= ra=E2=80=90 >> > tions=E2=80=94that is, system calls such as wr= ite(2) and >> > pwrite(2). >> >=20 >> > read_bytes: bytes read >> > Attempt to count the number of bytes which t= his >> > process really did cause to be fetched from = the >> > storage layer. This is accurate for block-bac= ked >> > filesystems. >> >=20 >> > write_bytes: bytes written >> > Attempt to count the number of bytes which t= his >> > process caused to be sent to the storage layer.= >=20 > Accounting on MTD devices is not accurate for these two. >=20 >> > cancelled_write_bytes: >> > The big inaccuracy here is truncate. If a proc= ess >> > writes 1MB to a file and then deletes the file,= it >> > will in fact perform no writeout. But it w= ill >> > have been accounted as having caused 1MB of wri= te. >> > In other words: this field represents the num= ber >> > of bytes which this process caused to not happ= en, >> > by truncating pagecache. A task can cause "ne= ga=E2=80=90 >> > tive" I/O too. If this task truncates some di= rty >> > pagecache, some I/O which another task has b= een >> > accounted for (in its write_bytes) will not = be >> > happening. >> >=20 >> > Note: In the current implementation, things are a = bit >> > racy on 32-bit systems: if process A reads process = B's >> > /proc/[pid]/io while process B is updating one of th= ese >> > 64-bit counters, process A could see an intermedi= ate >> > result. >> >=20 >> > Permission to access this file is governed by a ptr= ace >> > access mode PTRACE_MODE_READ_FSCREDS check; = see >> > ptrace(2). >=20 > 2) > Use the netlink bases taststats interface, which gives you the same > information, but uses far less system resources. >=20 > See: > http://lxr.bootlin.com/linux/latest/source/Documentation/accounting/tas= kstats.txt > http://lxr.bootlin.com/linux/latest/source/Documentation/accounting/tas= kstats-struct.txt > https://stackoverflow.com/questions/30617368/sending-netlink-taskstats-= message-using-libnl-3 Marc --=20 Pengutronix e.K. | Marc Kleine-Budde | Industrial Linux Solutions | Phone: +49-231-2826-924 | Vertretung West/Dortmund | Fax: +49-5121-206917-5555 | Amtsgericht Hildesheim, HRA 2686 | http://www.pengutronix.de | --1GXPjHxT92B2EwiI93fOZlBXWlXDkaK3S-- --cOU4CVYCo61RJMOAavKYuvFQalgj7Box1 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEENrCndlB/VnAEWuH5k9IU1zQoZfEFAlp8J30ACgkQk9IU1zQo ZfEYOwf/fhH+gC90bAhA3xL3JU75Q48kFDqnElXFLfu46SMkETkAsBTxc7SEGxJW Z3PWgLNlLXyPov+ZW7lNAAT3NRjZvpYLfwzsUrZUkvhnzhIqn04bUD5rzgtT2N1Z 7qaO9xU3iPESHX9OY+9QhpxrF7gjsZfuhNUScANvgZ7PMFM5baLZ5eA57Z+898vv /5hC1yDeaBsQsj9FVQCT2c7UEYz9p6N+o19TGqSoD5kLllA+Mflh0infOptqLR7K JDVa3EhKYOw9OpBD6Uj1QYeWprC8nxXjg0EVNxoaFHwG/Bq3l7Un5lpBXE/UPeL7 0SvSXOfZ4e7ZxjumV4jcXRL4e3EjrQ== =4ljU -----END PGP SIGNATURE----- --cOU4CVYCo61RJMOAavKYuvFQalgj7Box1-- --===============1491873763== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KcHR4ZGlzdCBt YWlsaW5nIGxpc3QKcHR4ZGlzdEBwZW5ndXRyb25peC5kZQ== --===============1491873763==--