From owner-freebsd-current@freebsd.org Tue Oct 17 15:51:38 2017 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33302E3DF03 for ; Tue, 17 Oct 2017 15:51:38 +0000 (UTC) (envelope-from ian@freebsd.org) Received: from outbound1a.eu.mailhop.org (outbound1a.eu.mailhop.org [52.58.109.202]) (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 C08CC71BA7 for ; Tue, 17 Oct 2017 15:51:37 +0000 (UTC) (envelope-from ian@freebsd.org) X-MHO-User: 0c389527-b353-11e7-a893-25625093991c X-Report-Abuse-To: https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information X-Originating-IP: 73.78.92.27 X-Mail-Handler: DuoCircle Outbound SMTP Received: from ilsoft.org (unknown [73.78.92.27]) by outbound1.eu.mailhop.org (Halon) with ESMTPSA id 0c389527-b353-11e7-a893-25625093991c; Tue, 17 Oct 2017 15:51:34 +0000 (UTC) Received: from rev (rev [172.22.42.240]) by ilsoft.org (8.15.2/8.15.2) with ESMTP id v9HFpSds003738; Tue, 17 Oct 2017 09:51:28 -0600 (MDT) (envelope-from ian@freebsd.org) Message-ID: <1508255488.74236.29.camel@freebsd.org> Subject: Re: pfind_locked(pid) fails when in a jail? From: Ian Lepore To: Rick Macklem , Mateusz Guzik Cc: "freebsd-current@freebsd.org" , "fabian.freyer@physik.tu-berlin.de" Date: Tue, 17 Oct 2017 09:51:28 -0600 In-Reply-To: References: <1508195986.74236.6.camel@freebsd.org> , <20171016233912.7n6rosak5a5tzcbz@mguzik> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.1 FreeBSD GNOME Team Port Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 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, 17 Oct 2017 15:51:38 -0000 On Tue, 2017-10-17 at 00:08 +0000, Rick Macklem wrote: > [stuff snipped] > > > > > > > > > > > > > > > > pfind* does not do any filtering. > > > > Hmm, well I have no idea why the jailed mounts get looping in here then. > > > > > > > > > The real question though is why are you calling it in the first place. The > > > calls > > > I grepped in nfscl_procdoesntexist are highly suspicious - there is no > > > guarantee > > > the process you found here is the same you had at the time you were saving > > > the pid. > > > > Long long ago (about 2002) this code was written for OpenBSD2.6. I added > a call from the kernel exit() code to do this. When I ported it to FreeBSD > around 2005, I didn't find any way for a process exit notification to be done, > so I created the first version of this code. (This way of doing it was first > coded for Mac OS X 10.3, if I recall correctly.) > > Since it does check that the time of process creation is the same, it doesn't > seem likely that it would find a different process (ie. two processes with the > same pid that were created at the same time within the clock resolution of > that creation time seems highly unlikely in practice?). > > > > > > > > > There is no usable process exit notification right now, but it can be added > > > if necessary. > > > > If there was a way for the NFS client to register to get a notification that a > given process is terminating (exit'ng), that could certainly be used instead > of this code. > > I wouldn't want a call for every exit(), but only the ones that have NFSv4 opens. > > > > > > > > > > > > Does that mean there is something wrong with the existing eventhandler > > > notifications related to proc fork/exec/exit? > > > > > I already noted in the other mail that the current mechanism has > > avoidable global locking, lists traversals etc. But even with these > > issues fixed it calls everything for everyone. > > All of that locking-and-lookup overhead in the event notification system is already happening on every process exit, whether anyone has registered an event handler or not.  If you want to actually avoid the avoidable overheads, the answer is to fix the existing code, not create another new mechanism that adds more overhead without addressing the existing problem.  I suspect the worst of the existing overhead can be eliminated with some fairly small changes, and I hope to find time to look at it later this week. On the issue of filtering the callbacks to just the exits you're interested in... it doesn't seem any better to me to do the filtering at the source unless there are multiple registered handlers at once that all need the same filtering.  How many different things in the kernel would want process-exit filtering based on "have NFSv4 opens"?  That seems like a single-consumer kind of filter. -- Ian > > What's needed is a mechanism to register per-process callbacks. Details > > can be flamed over (e.g. should it require allocating a buffer per > > process or perhaps just one and then point to it from a resizable > > per-proc table when registered), but calling something which has nothing > > to do in almost all cases and from in a super inefficient way at that is > > definitely something we need to start cleaning up. > Yes, I would agree, although it doesn't explain what this CPU hog case is > caused by. > > Thanks for the comments and if you create/commit the above, let me know > and I'll change the NFS client code to use it (if your patch doesn't do that). > > rick > > _______________________________________________ > 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"