From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 23 07:25:07 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 674D9EAC; Wed, 23 Jan 2013 07:25:07 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com [209.85.217.175]) by mx1.freebsd.org (Postfix) with ESMTP id 3A585E43; Wed, 23 Jan 2013 07:25:06 +0000 (UTC) Received: by mail-lb0-f175.google.com with SMTP id n3so5540581lbo.20 for ; Tue, 22 Jan 2013 23:25:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=ybyZzFGuaKPOBID0PX9vedcH4wYQTytvtYxmmxEFCsY=; b=fxhbVM090Te9RwD6uXu43Md2UBMIy7GWWeKiWaBUh2TN8mimCBsHaXl4QzE83ge++q LWJGc+twzuiMQyNPXvdIgFqfHozTc3HJR/daXWDRGEan6zVaM2jKb7K7c4N65BWXE1gJ 94NHlyQzkgujNkBD3UnAPybzJC8FKlGoT7VajPj1lK1ENCUPrXoXdEubika/k+a1WcDV +eRij7cjyNfr22ceEFaoibiVHifq3KoH6wFWAfKY5tCqSqZqdPKuT8MV7hDyX6eZ5W+E tVYtf2Tav+Ssz97ee9xHOvCGOXzXxYWtfYm4RCL34OxfPkfXRE4ua+GReOydLOJ579s6 fvHQ== X-Received: by 10.112.13.133 with SMTP id h5mr280205lbc.99.1358925905135; Tue, 22 Jan 2013 23:25:05 -0800 (PST) Received: from localhost ([188.230.122.226]) by mx.google.com with ESMTPS id ox6sm7821781lab.16.2013.01.22.23.25.03 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Jan 2013 23:25:04 -0800 (PST) Sender: Mikolaj Golub Date: Wed, 23 Jan 2013 09:25:00 +0200 From: Mikolaj Golub To: Stanislav Sedov Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <20130123072459.GA48402@gmail.com> References: <20130119151253.GB88025@gmail.com> <201301221201.06290.jhb@freebsd.org> <20130122211743.GA4490@gmail.com> <201301221648.50747.jhb@freebsd.org> <9679EEE4-BE52-493E-9188-CAECEE5E63D3@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <9679EEE4-BE52-493E-9188-CAECEE5E63D3@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: 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 07:25:07 -0000 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). -- Mikolaj Golub