From owner-freebsd-current@freebsd.org Thu Dec 27 18:36:27 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 63823141F3A1 for ; Thu, 27 Dec 2018 18:36:27 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 5FE0786A47 for ; Thu, 27 Dec 2018 18:36:26 +0000 (UTC) (envelope-from mjguzik@gmail.com) Received: by mail-wm1-x342.google.com with SMTP id g67so18125683wmd.2 for ; Thu, 27 Dec 2018 10:36:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=qaGUzWANz7h2IgxtIOm2zK+LtvPt+eZMpUwiFxduo1E=; b=ejJKkkEfpe+LCCNSN2i/fcgtuomr+x2rk+sKnu27D05XM79q8jtyJP275K2io7op+q m/vPH2ACoJyaFFPzBFz45CMhwpjPmdUtsYNVtzpYQbairXi2tPXjWIwqxB4hUTGTgg3r 0Bzyauz1dhqcbm7UiVCTZWnlCx9jMb2GBtMx0hwV6X+RzthavVNrGVF7co3+aZmjJs+4 KUcV6OobLf4+7t7quq8HUF5PAcbL4Wu4ndX7KnF0Fwm3rY2fOnfn3dcRWQUdoVzt/JKv 9tfXjZV4nqeDqZvIY1tyxgJ6jwMNY5BZGkXabmvezBh9Fy9uGYy3n055Rwt9A55Hn0di 6E5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=qaGUzWANz7h2IgxtIOm2zK+LtvPt+eZMpUwiFxduo1E=; b=KLBVSjVCDxwRWfYGINPTCJx5BR5jhLboLpvsrkg/lw8/fAj8Y93Qzbd/94EKAb2Yb4 e3s5Ne81pyDGDTm9mVbvn8e6ts4qSYQpKGP8NsNiQUQNU7lFfyJZ040xaWbxLyCkI6Tw jpFBSVyAXdF4HCAYDNqNDD+DxFRrdLSO16I70tXBFFY6W+OnAEDMvO1EHEbMi3HreDAw oEsfSijDU+8PC0vFvWCC5BzaohjPIbsjztuhueNDaOQatHD9q72VFKxUtsJ5Wlp1t3mc s3Dhfc4y7yt8Jmp5kwlUlFemsOge4uNKJQUhaAmGJ2lE0G36fcvuZfx3bLBA2C3t5yoG xCcQ== X-Gm-Message-State: AA+aEWb+VrCTvzYtn4YhgLizs6hd8F/1ZMYzA56spWBIThC1PwpARoDO o68bxhRkzarr1qfd7b7pK9YCfdnXmTJvskQl76Y= X-Google-Smtp-Source: AFSGD/WlTDDMtvi0z6y005TL+tU1wSwMXnLJuBIS6i1o09Xlljh30jt3qmrfISudfuugDH0XjZt2HJrLLU3sRtmeIME= X-Received: by 2002:a1c:d082:: with SMTP id h124mr20816277wmg.21.1545935785010; Thu, 27 Dec 2018 10:36:25 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a5d:4602:0:0:0:0:0 with HTTP; Thu, 27 Dec 2018 10:36:24 -0800 (PST) In-Reply-To: References: <6C9BDD8A-7889-4819-86E3-CE13AC3323AC@yahoo.com> From: Mateusz Guzik Date: Thu, 27 Dec 2018 19:36:24 +0100 Message-ID: Subject: Re: head -r3418363: top -opid process list order is rather odd (top -Saopid example shown) To: Mark Millard Cc: Yuri Pankov , FreeBSD Current Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 5FE0786A47 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=ejJKkkEf; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of mjguzik@gmail.com designates 2a00:1450:4864:20::342 as permitted sender) smtp.mailfrom=mjguzik@gmail.com X-Spamd-Result: default: False [-4.28 / 15.00]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; MX_GOOD(-0.01)[cached: alt3.gmail-smtp-in.l.google.com]; FREEMAIL_TO(0.00)[yahoo.com]; FROM_EQ_ENVFROM(0.00)[]; IP_SCORE(-0.43)[ip: (1.18), ipnet: 2a00:1450::/32(-1.73), asn: 15169(-1.51), country: US(-0.08)]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_HAM_SHORT(-0.84)[-0.840,0]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; MIME_GOOD(-0.10)[text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-current@freebsd.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[2.4.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.5.4.1.0.0.a.2.list.dnswl.org : 127.0.5.0]; RCVD_TLS_LAST(0.00)[] 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: Thu, 27 Dec 2018 18:36:27 -0000 I suspect this is a side-effect of r340742 ("proc: implement pid hash locks and an iterator"). Prior to the change exporting code would just iterate allproc, which will appear sorted for *most* processes and most importantly kernel ones. Note the allproc list is most definitely not sorted in general and a closer look would reveal that. On 12/25/18, Mark Millard wrote: > > > On 2018-Dec-24, at 13:49, Yuri Pankov wrote: > >> Mark Millard wrote: >>> From my from=source head -r3418363 context, top with -opid does not >>> 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 WCPU >>> 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 recently > for a test of something else. The -opid ordering was coherent as I > remember, > unlike the above.) > > It historically seemed to track the time order of process creation, even > around the PID > number wrapping around. (So not a strict PID sort, at least for the PID > shown.) This > was handy for monitoring buildworld buidkernel and port builds (all > parallel). > > I'll probably try the patch when I have a chance, even if it does strict PID > number > order. Thanks. > > === > Mark Millard > marklmi at yahoo.com > ( dsl-only.net went > away in early 2018-Mar) > > _______________________________________________ > freebsd-current@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org" > -- Mateusz Guzik