Received: by mail.netbsd.org (Postfix, from userid 605) id A811984E43; Tue, 13 Mar 2018 02:24:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id B6D9B84E0A for ; Tue, 13 Mar 2018 02:24:27 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id chlfF07hq-Hl for ; Tue, 13 Mar 2018 02:24:27 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.NetBSD.org [IPv6:2001:470:a085:999:28c:faff:fe03:5984]) by mail.netbsd.org (Postfix) with ESMTP id 0604284C81 for ; Tue, 13 Mar 2018 02:24:27 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 02969FB40; Tue, 13 Mar 2018 02:24:27 +0000 (UTC) Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" MIME-Version: 1.0 Date: Tue, 13 Mar 2018 02:24:26 +0000 From: "Kamil Rytarowski" Subject: CVS commit: src/sys/kern To: source-changes@NetBSD.org X-Mailer: log_accum Message-Id: <20180313022427.02969FB40@cvs.NetBSD.org> Sender: source-changes-owner@NetBSD.org List-Id: source-changes.NetBSD.org Precedence: bulk Reply-To: source-changes-d@NetBSD.org Mail-Reply-To: "Kamil Rytarowski" Mail-Followup-To: source-changes-d@NetBSD.org List-Unsubscribe: Module Name: src Committed By: kamil Date: Tue Mar 13 02:24:26 UTC 2018 Modified Files: src/sys/kern: kern_proc.c Log Message: Make sysctl_doeproc() more predictable Swap the order of looking into zombie and all process lists, start now with the zombie one. This prevents a race observed previously that the same process could be detected on both lists during a single polling call. While there: - Short-circuit break for KERN_PROC_PID, once a pid has been detected. - Removal of redundant "if (kbuf)" and "if (marker)" checks. - Update of comments regarding potential optimization, explaining why we don't want to it as of now. Performance gain from lookup call vs iteration over a list is neglible on a regular system. - Return ESRCH when no results have been found. This allows more easily to implement a retry or abandon algorithm. This corrects races observed in the existing ATF ptrace(2) tests, related to await_zombie(). This function was expecting to check whether a process has been transformed into a zombie, however it was causing occasional crashes as it was overflowing the return buffer, returning the same pid twice: once from allproc list and the second time from zombieproc one. Fix suggested by Short-circuit break suggested by Discussed on tech-kern. Sponsored by To generate a diff of this commit: cvs rdiff -u -r1.210 -r1.211 src/sys/kern/kern_proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.