From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 23 16:32:41 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id EF728A7B; Wed, 23 Jan 2013 16:32:41 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id BF751EEC; Wed, 23 Jan 2013 16:32:41 +0000 (UTC) Received: from pakbsde14.localnet (unknown [38.105.238.108]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 20D7CB911; Wed, 23 Jan 2013 11:32:41 -0500 (EST) From: John Baldwin To: Mikolaj Golub Subject: Re: libprocstat(3): retrieve process command line args and environment Date: Wed, 23 Jan 2013 11:31:43 -0500 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p22; KDE/4.5.5; amd64; ; ) References: <20130119151253.GB88025@gmail.com> <9679EEE4-BE52-493E-9188-CAECEE5E63D3@freebsd.org> <20130123072459.GA48402@gmail.com> In-Reply-To: <20130123072459.GA48402@gmail.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201301231131.43972.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 23 Jan 2013 11:32:41 -0500 (EST) Cc: Stanislav Sedov , freebsd-hackers@freebsd.org, Robert Watson X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jan 2013 16:32:42 -0000 On Wednesday, January 23, 2013 2:25:00 am Mikolaj Golub wrote: > On Tue, Jan 22, 2013 at 02:17:39PM -0800, Stanislav Sedov wrote: > > > > On Jan 22, 2013, at 1:48 PM, John Baldwin wrote: > > > > > > Well, you could make procstat open a kvm handle in both cases (open a "live" > > > handle in the procstat_open_sysctl() case). It just seems rather silly to be > > > duplicating code in the two interfaces. > > In this particular case I prefer code duplication to opening a kvm > handle in procstat_open_sysctl(), as it looks a bit confusing. But I > can do this way if the agreement is reached. > > > > More a question for Robert: does > > > libprocstat intentionally duplicate the code in libkvm for other things as > > > well in the live case? (Like fetching the list of processes?) > > > > > It does not actually has a duplicate code, the code for fetching the list of > > processes via sysctl is different from the KVM case. The open file descriptors > > processing is different as well. Because libprocstat implements almost the > > same functionality both for sysctl and mvm backends, it can be used to analyze > > both the live system and the kernel crash dumps. The code Mikolaj proposed > > only implements the sysctl backend currently, so it does not seem to have > > any relation to KVM, so it will be a bit weird to make it open a KVM handle > > though it does not use it. > > IMHO, after adding procstat_getargv and procstat_getargv, the usage of > kvm_getargv() and kvm_getenvv() (at least in the new code) may be > deprecated. As this is stated in the man page, BUGS section, "these > routines do not belong in the kvm interface". I suppose they are part > of libkvm because there was no a better place for them. procstat(1) > prefers direct sysctl to them (so, again, code duplication, which I am > going to remove adding procstat_getargv/envv). Hmm, are you going to rewrite ps(1) to use libprocstat? Or rather, is that a goal someday? That is one current consumer of kvm_getargv/envv. That might be fine if we want to make more tools use libprocstat instead of using libkvm directly. -- John Baldwin