From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 10 21:15:17 2011 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C0EA106564A; Thu, 10 Nov 2011 21:15:16 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-fx0-f54.google.com (mail-fx0-f54.google.com [209.85.161.54]) by mx1.freebsd.org (Postfix) with ESMTP id 46A958FC12; Thu, 10 Nov 2011 21:15:15 +0000 (UTC) Received: by faar19 with SMTP id r19so4707260faa.13 for ; Thu, 10 Nov 2011 13:15:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:references:x-comment-to:sender:date:in-reply-to :message-id:user-agent:mime-version:content-type; bh=4Dis4gGB2nXGMZW42eLhEpa4zZvxTMXS9kdVMU3134k=; b=FPD1WpComPMsWbNZENQq5p3sgYb5BrG8zGbu1zGGorxQb37f4tHs7Lo65rz2S3YBaC JkaVM+nUwILGuDfMXE0vdalhqL0G6Q3UdhihMBsHC9DFvfUf07gMSohHYakQBHoYRmbU OadlO7aXdC1voxcQn7+iVG4zq7dDZtLzPXgl4= Received: by 10.223.14.197 with SMTP id h5mr14485890faa.2.1320959715092; Thu, 10 Nov 2011 13:15:15 -0800 (PST) Received: from localhost ([95.69.173.122]) by mx.google.com with ESMTPS id k13sm2917531fah.0.2011.11.10.13.15.10 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 10 Nov 2011 13:15:11 -0800 (PST) From: Mikolaj Golub To: Kostik Belousov References: <86vcr21agm.fsf@kopusha.home.net> <20111105135801.GT50300@deviant.kiev.zoral.com.ua> <86ehxmpogp.fsf@kopusha.home.net> <20111105154443.GB50300@deviant.kiev.zoral.com.ua> <86ehxmjsza.fsf@kopusha.home.net> <20111105194553.GK50300@deviant.kiev.zoral.com.ua> <8662iyjof9.fsf@kopusha.home.net> <20111106181041.GH50300@deviant.kiev.zoral.com.ua> <86r51iqoad.fsf@kopusha.home.net> <20111109124455.GW50300@deviant.kiev.zoral.com.ua> <20111109125329.GX50300@deviant.kiev.zoral.com.ua> <86zkg5h175.fsf@in138.ua3> X-Comment-To: Mikolaj Golub Sender: Mikolaj Golub Date: Thu, 10 Nov 2011 23:15:08 +0200 In-Reply-To: <86zkg5h175.fsf@in138.ua3> (Mikolaj Golub's message of "Wed, 09 Nov 2011 15:31:26 +0200") Message-ID: <867h378ysj.fsf@kopusha.home.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: freebsd-hackers@freebsd.org, Robert Watson Subject: Re: "ps -e" without procfs(5) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Nov 2011 21:15:17 -0000 On Wed, 09 Nov 2011 15:31:26 +0200 Mikolaj Golub wrote: MG> On Wed, 9 Nov 2011 14:53:29 +0200 Kostik Belousov wrote: >>> And now you return success and nothing gets copied out for the process >>> in P_INEXEC state. Either you should return an error like EAGAIN, or >>> consider the P_INEXEC state as transitional and wait till process >>> leaves it. Or, ignore the state as it was before, and return whatever >>> error proc_rwmem generated (my preference). KB>> Forgot to say that the check does not change much because you drop KB>> process lock immediately after the check, so the process may enter KB>> the INEXEC state right after the check. I believe you already tried KB>> to do this with P_WEXIT. MG> Good point :-). Although after adding the P_INEXEC I have not seen errors any MG> more, while before they were often (when running 'procstat -ca' in loop and MG> building world simultaneously). Thus it looks like the probability is much MG> smaller. MG> So, it still looks good for me to check for P_INEXEC and return EAGAIN, and MG> add the comment why we do this and that it still racy. But if you still think MG> that ignoring the state is the best option no problems for me to return it MG> back. Realted to this, sysctl_kern_proc_kstack() looks like has the similar issue. But it returns ESRCH instead. /* XXXRW: Not clear ESRCH is the right error during proc execve(). */ if (p->p_flag & P_WEXIT || p->p_flag & P_INEXEC) { PROC_UNLOCK(p); return (ESRCH); } ... _PHOLD(p); PROC_UNLOCK(p); -- Mikolaj Golub