From owner-freebsd-current@freebsd.org Tue Dec 25 15:44:35 2018 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 609E4135572D for ; Tue, 25 Dec 2018 15:44:35 +0000 (UTC) (envelope-from yuripv@yuripv.net) Received: from mailman.ysv.freebsd.org (mailman.ysv.freebsd.org [IPv6:2001:1900:2254:206a::50:5]) by mx1.freebsd.org (Postfix) with ESMTP id B69298174C for ; Tue, 25 Dec 2018 15:44:34 +0000 (UTC) (envelope-from yuripv@yuripv.net) Received: by mailman.ysv.freebsd.org (Postfix) id 70DFD135572C; Tue, 25 Dec 2018 15:44:34 +0000 (UTC) Delivered-To: current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 354A3135572B for ; Tue, 25 Dec 2018 15:44:34 +0000 (UTC) (envelope-from yuripv@yuripv.net) Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 31CB88174B for ; Tue, 25 Dec 2018 15:44:33 +0000 (UTC) (envelope-from yuripv@yuripv.net) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 2974221C1B for ; Tue, 25 Dec 2018 10:44:32 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 25 Dec 2018 10:44:32 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yuripv.net; h= subject:from:to:references:message-id:date:mime-version :in-reply-to:content-type; s=fm3; bh=eU++II+tJb5q7Vx3sCUNcaB8dcd 8FcDjCP2Ka1VXU70=; b=aslMDmZnZAJ5LBM0Drr0qKDxNTIWlfxD3Hq5wQNUeAl bd93FsPkPa2EXEzUVnAtPLWkFt1DVTL5Gd8/QjsZv0uFqAmBJMM/AxFwo6QBssQH RaRd+B5TZXaSCvCEG54hvtlhcSrciQjN8b7hvJe9TYtP9JgKTpPApRrhLiKYDrYT Xf+f0rcEKKEhTZUHDbKNJ4DUu1reCykwgduLD1LPNWHxzxdVeGcP+ihsOwYlEdGN K8rS2cUIfA4kMnFI0Pulau3xkyQCNGjkTij7scvZqLqLhyrWPoMpRxVkFrN1bGpB 8uNDrg9x3Kxd7VNBPwAC/koKRxuezU6pCYp9WSRbxFQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=eU++II +tJb5q7Vx3sCUNcaB8dcd8FcDjCP2Ka1VXU70=; b=CjPvOlRPwIShQNfxXkPQtp RAjlX+yn+aEEmnDjEtT5aakd6zVXJxfPXTVNwBcrH/1kSmYst5OLtESiObSUWGUu oBzdmDvAHocKIsN0MWSotQA8LZ1taSGvQkiptMNvsavieTGSi/O0N9liKzY2v+ub hInR+Ndj/L/b3iTT+b9QuwKghWaNgHSgJhVX1PYOQArs0XpgjC9H5xFpfu3l/e+f IxXFuJmclpBfLlAwTDm+xTBxGpyQqPL5vNR78YAZHJACm/fVG30sw5hoaKxwPT1c 3kwOVoCH+aHjpJec02CSBxy/ES+lNaFkkZshy9ch+WXR8vWhuMq30CqQIgr0+t+Q == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedtkedrudekfedgkedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfquhhtnecuuegrihhlohhuthemucef tddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefuhffvfhfkff gfgggjtgesghdtrefotdefjeenucfhrhhomhepjghurhhiucfrrghnkhhovhcuoeihuhhr ihhpvheshihurhhiphhvrdhnvghtqeenucffohhmrghinhepfhhrvggvsghsugdrohhrgh dphihurhhiphhvrdhnvghtnecukfhppeelgedrvdeffedrvdefuddrleejnecurfgrrhgr mhepmhgrihhlfhhrohhmpeihuhhrihhpvheshihurhhiphhvrdhnvghtnecuvehluhhsth gvrhfuihiivgeptd X-ME-Proxy: Received: from [192.168.1.2] (unknown [94.233.231.97]) by mail.messagingengine.com (Postfix) with ESMTPA id 2364AE4147 for ; Tue, 25 Dec 2018 10:44:29 -0500 (EST) Subject: Re: head -r3418363: top -opid process list order is rather odd (top -Saopid example shown) From: Yuri Pankov To: freebsd-current References: <6C9BDD8A-7889-4819-86E3-CE13AC3323AC@yahoo.com> Openpgp: preference=signencrypt Autocrypt: addr=yuripv@yuripv.net; keydata= mQENBFu8u6IBCADB11gP0QwnorrHjqAtKLHKHNHskhy0s7jqJKfx0YqXgVBKGLJ9/mjLAz0F CBNvemHSDDTs0mEZ9cBKKi6cmsav6+UQgr//yai6hvXLBJqKchSFO4MhmdvBtsGFq1yKz5Zi uhjmimKyIpgBgvMdbgGbGq6cnSB2uEPmZuJr419SVRODOkXukU+F5WHgaHzDdHAIu1asCt2B +6msxqIqlFWcXyZyTGicTGGvC/PFIsVRUtD1dIJANTC876g7DTb7LZXWiWwJpSJ4GKMXMHVX Ct9BoQ4i3nhKbOxb6Io1wsy+NFyWsTJ9KYrxKKPJP3oG8BWb/cqlFqnE4eNSsiq2q7krABEB AAG0H1l1cmkgUGFua292IDx5dXJpcHZAeXVyaXB2Lm5ldD6JAVcEEwEIAEECGwMFCQWjmoAF CwkIBwMFFQoJCAsFFgMCAQACHgECF4AWIQT4arc+w94tPi0v/3CTi+B/sSrhbAUCW708wAIZ AQAKCRCTi+B/sSrhbPxBB/961alcU091O+yKT5/oReHVc/PX0Tz4sW3V44AcgLfYlrZavCro EFz90qmCrl0xqEwuAKcC4bjmL8SjPWAhSN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Tue, 25 Dec 2018 18:44:20 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="HRMgdYOP3rRLTMZVyTuTaNXwQWs0E4K2l" X-Rspamd-Queue-Id: 31CB88174B X-Spamd-Bar: --------- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=yuripv.net header.s=fm3 header.b=aslMDmZn; dkim=pass header.d=messagingengine.com header.s=fm1 header.b=CjPvOlRP; spf=pass (mx1.freebsd.org: domain of yuripv@yuripv.net designates 66.111.4.25 as permitted sender) smtp.mailfrom=yuripv@yuripv.net X-Spamd-Result: default: False [-9.30 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ip4:66.111.4.25]; HAS_ATTACHMENT(0.00)[]; RCVD_COUNT_THREE(0.00)[4]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yuripv.net:+,messagingengine.com:+]; MX_GOOD(-0.01)[cached: in2-smtp.messagingengine.com]; NEURAL_HAM_SHORT(-1.00)[-0.999,0]; SIGNED_PGP(-2.00)[]; FROM_EQ_ENVFROM(0.00)[]; IP_SCORE(-3.59)[ip: (-9.43), ipnet: 66.111.4.0/24(-4.65), asn: 11403(-3.77), country: US(-0.08)]; MIME_TRACE(0.00)[0:+,1:+,2:+]; ASN(0.00)[asn:11403, ipnet:66.111.4.0/24, country:US]; RCVD_TLS_LAST(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; RCVD_IN_DNSWL_LOW(-0.10)[25.4.111.66.list.dnswl.org : 127.0.5.1]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[yuripv.net:s=fm3,messagingengine.com:s=fm1]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.20)[multipart/signed,multipart/mixed,text/plain]; PREVIOUSLY_DELIVERED(0.00)[current@freebsd.org]; DMARC_NA(0.00)[yuripv.net]; RCPT_COUNT_ONE(0.00)[1] X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Dec 2018 15:44:35 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --HRMgdYOP3rRLTMZVyTuTaNXwQWs0E4K2l Content-Type: multipart/mixed; boundary="n0jpmzwOh53uIpnukZnOVrJwtuImdTLBr"; protected-headers="v1" From: Yuri Pankov To: freebsd-current Message-ID: Subject: Re: head -r3418363: top -opid process list order is rather odd (top -Saopid example shown) References: <6C9BDD8A-7889-4819-86E3-CE13AC3323AC@yahoo.com> In-Reply-To: --n0jpmzwOh53uIpnukZnOVrJwtuImdTLBr Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Yuri Pankov wrote: > Mark Millard wrote: >> >> >> On 2018-Dec-24, at 13:49, Yuri Pankov wrote: >> >>> Mark Millard wrote: >>>> From my from=3Dsource head -r3418363 context, top with -opid does no= t >>>> seem to sort in a coherent order, not time of process creation order= >>>> (either direction) and not in just-PID numeric order (either >>>> direction). For example: >>>> >>>> PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCP= U COMMAND >>>> 0 root 24 -16 - 0 368K swapin 1 0:00 0.00= % [kernel] >>>> 16 root 1 -16 - 0 16K - 3 0:00 0.00= % [soaiod2] >>>> 752 root 1 20 0 18M 18M select 1 0:07 0.01= % /usr/sbin/ntpd -p /var/db/ntp/ntpd.pid -c /etc/ntp.conf -g >>>> 800 root 1 20 0 11M 908K nanslp 1 0:01 0.00= % /usr/sbin/cron -s >>>> 1 root 1 20 0 9900K 132K wait 3 0:00 0.00= % [init] >>>> 17 root 1 -16 - 0 16K - 0 0:00 0.00= % [soaiod3] >>>> 2 root 1 -16 - 0 16K crypto 0 0:00 0.00= % [crypto] >>>> 18 root 1 -16 - 0 16K - 0 0:00 0.00= % [soaiod4] >>>> 850 root 1 20 0 13M 2756K wait 3 0:00 0.00= % login [pam] (login) >>>> 3 root 1 -16 - 0 16K crypto 0 0:00 0.00= % [crypto returns 0] >>>> 19 root 1 -16 - 0 16K mmcsd 0 0:25 0.00= % [mmcsd0: mmc/sd card] >>>> 643 root 1 20 0 11M 1124K select 2 0:01 0.00= % /usr/sbin/syslogd -s >>>> 4 root 1 -16 - 0 16K crypto 0 0:00 0.00= % [crypto returns 1] >>>> 20 root 1 -16 - 0 16K mmcsd 0 0:00 0.00= % [mmcsd0boot0: mmc/sd] >>>> 5 root 1 -16 - 0 16K crypto 0 0:00 0.00= % [crypto returns 2] >>>> 21 root 1 -16 - 0 16K mmcsd 0 0:00 0.00= % [mmcsd0boot1: mmc/sd] >>>> 6 root 1 -16 - 0 16K crypto 0 0:00 0.00= % [crypto returns 3] >>>> 22 root 3 -16 - 0 48K psleep 3 0:12 0.00= % [pagedaemon] >>>> 5270 root 1 20 0 14M 3780K CPU2 2 0:00 0.14= % top -Saopid >>>> 662 root 1 20 0 11M 680K select 0 0:00 0.00= % /usr/sbin/rpcbind >>>> 7 root 2 -16 - 0 32K - 0 0:00 0.00= % [cam] >>>> 23 root 1 -16 - 0 16K psleep 2 0:00 0.00= % [vmdaemon] >>>> 5255 root 1 20 0 12M 3092K wait 0 0:00 0.00= % -sh (sh) >>>> 8 root 1 -16 - 0 16K waitin 0 0:00 0.00= % [sctp_iterator] >>>> 24 root 3 -16 - 0 48K qsleep 3 0:12 0.01= % [bufdaemon] >>>> 712 root 1 52 0 12M 616K select 0 0:00 0.00= % /usr/sbin/mountd -r >>>> 9 root 1 -16 - 0 16K - 1 0:04 0.00= % [rand_harvestq] >>>> 25 root 1 20 - 0 16K vlruwt 0 0:04 0.00= % [vnlru] >>>> 10 root 1 -16 - 0 16K audit_ 0 0:00 0.00= % [audit] >>>> 26 root 1 16 - 0 16K syncer 0 1:45 0.00= % [syncer] >>>> 714 root 1 52 0 12M 728K select 3 0:00 0.00= % nfsd: master (nfsd) >>>> 11 root 4 155 ki31 0 64K CPU0 0 144.6H 397.09= % [idle] >>>> 235 root 1 20 0 11M 564K select 3 0:00 0.00= % dhclient: system.syslog (dhclient) >>>> 715 root 32 52 0 11M 1120K rpcsvc 3 0:00 0.00= % nfsd: server (nfsd) >>>> 12 root 18 -52 - 0 288K WAIT 2 2:29 1.43= % [intr] >>>> 412 root 1 20 0 10M 72K select 2 0:00 0.00= % /sbin/devd >>>> 796 root 1 52 0 20M 672K select 0 0:00 0.00= % /usr/sbin/sshd >>>> 13 root 3 -8 - 0 48K - 1 0:11 0.00= % [geom] >>>> 14 root 20 -68 - 0 320K - 0 0:02 0.00= % [usb] >>>> 238 root 1 52 0 12M 416K select 1 0:00 0.00= % dhclient: awg0 [priv] (dhclient) >>>> 15 root 1 -16 - 0 16K - 0 0:00 0.00= % [soaiod1] >>>> 239 _dhcp 1 20 0 12M 484K select 1 0:00 0.00= % dhclient: awg0 (dhclient) >>>> >>>> (Basically the Pine64+ 2GB [aarch64] above was idle after boot other= than >>>> some runs of top.) >>>> >>>> I see this oddity across architectures, for example amd64, powerpc64= , >>>> aarch64, armv7. >>> >>> No wonder, it doesn't seem to have worked ever (?) as the compare_pid= is >>> simply not defined in compares list. Try attached patch. >>> >> >> I'm a long term top user and it used to work. For example, when I was = running >> head -r340287 it worked as I remember. (I recreated such a vintage rec= ently >> for a test of something else. The -opid ordering was coherent as I rem= ember, >> unlike the above.) >> >> It historically seemed to track the time order of process creation, ev= en around the PID >> number wrapping around. (So not a strict PID sort, at least for the PI= D shown.) This >> was handy for monitoring buildworld buidkernel and port builds (all pa= rallel). >> >> I'll probably try the patch when I have a chance, even if it does stri= ct PID number >> order. Thanks. >=20 > OK, so top never did sort for '-opid' by itself, and rather relied on > the process list to be sorted by birth time internally (as returned by > kvm_getprocs()) and it doesn't seem to be really sorting by PID, more s= o > when PID numbers wrap. Quick bisect shows that this behavior was > changed by r340742 ("proc: implement pid hash locks and an iterator"), > so I guess we now just need to implement real sorting by PID. >=20 > I have attached another patch version adding pid comparison function > done like the other ones. And there's a differential adding both explicit PID sorting, as well as sorting by birth time for those who'd like to have the previous behavior:= https://reviews.freebsd.org/D18658 --n0jpmzwOh53uIpnukZnOVrJwtuImdTLBr-- --HRMgdYOP3rRLTMZVyTuTaNXwQWs0E4K2l Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEE+Gq3PsPeLT4tL/9wk4vgf7Eq4WwFAlwiUFQACgkQk4vgf7Eq 4WzuuggApS3BfoKF2Ykiy0n+QTLAiXXJd7xO47yzs/9EEx+cyqPJe0n4BfA9YMAJ DXj0RC2FuL7rur/lkqQdxfm/PjuwufId8adirGZg4T/z9DfRk0X+xxP0rZpUnj4w LZrRplOH2amWqp0R0YLLfR0T2gzoUpneoBJmAS/bphnoAhp0k4GBLDPuNX2vYDNL l5fw4zy1i/qXJNxPI1IY+1gK4TEs9IEjCBu19EyV6YVfv3sXB9cuZqMqOxZxYyTh o0eUzRrQqIrFHV0pN5PxvNdrfOh17tzoa9zvxzyqp+STLkfm2lh+YYQXxgG9plTZ zteD5I71WcxSNOt3psOi+rb1hCzsGg== =He/l -----END PGP SIGNATURE----- --HRMgdYOP3rRLTMZVyTuTaNXwQWs0E4K2l--