From owner-freebsd-hackers@FreeBSD.ORG Sat Mar 16 18:09:28 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 774418E5; Sat, 16 Mar 2013 18:09:28 +0000 (UTC) (envelope-from to.my.trociny@gmail.com) Received: from mail-ee0-f41.google.com (mail-ee0-f41.google.com [74.125.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 44964D09; Sat, 16 Mar 2013 18:09:26 +0000 (UTC) Received: by mail-ee0-f41.google.com with SMTP id c13so2099425eek.0 for ; Sat, 16 Mar 2013 11:09:19 -0700 (PDT) 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=PwujDD0zKOkwj7uc0UKzbM3AeesBDRlfSmVViVZ4Ohc=; b=W/GNl8q69IFJqncDFOIHh8CJ1N6Cb1TxxQCZRdyYTvLXjFnZr00zKsFksmza0YBy9u +2v+Jb1N472oIwTyUkT9ttK7OGyIX9+Ce4CUKqUefEgXieWHaI3mo68L+k3avQonIxg5 kRVykPOYfve9igWtfl1zIwxDlWuF1zM+fktwdzyREPeQaDVeXJSbRMPctP38OJWsy/L4 I/e8A67oDcYd9k+lxlSiiricUZwejdKgIxdaN5G+Klle1+5j/8mnddq+FvgiqRjAXZ2+ 78S5+I1IQHZeBVJfAJojbRDNIKK2bG6TGPxyONwItYV72pbdyx2veCHYgz9ekakSHrQa a9nw== X-Received: by 10.14.211.65 with SMTP id v41mr30699041eeo.33.1363457359798; Sat, 16 Mar 2013 11:09:19 -0700 (PDT) Received: from localhost ([178.150.115.244]) by mx.google.com with ESMTPS id ca4sm17159109eeb.15.2013.03.16.11.09.17 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 16 Mar 2013 11:09:18 -0700 (PDT) Sender: Mikolaj Golub Date: Sat, 16 Mar 2013 20:09:16 +0200 From: Mikolaj Golub To: John Baldwin Subject: Re: libprocstat(3): retrieve process command line args and environment Message-ID: <20130316180915.GA91146@gmail.com> References: <20130119151253.GB88025@gmail.com> <201301251531.43540.jhb@freebsd.org> <20130212215054.GA9839@gmail.com> <201302200904.15324.jhb@freebsd.org> <20130220195801.GA8679@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130220195801.GA8679@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Stanislav Sedov , Kostik Belousov , "Robert N. M. Watson" , Attilio Rao , freebsd-hackers@freebsd.org 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: Sat, 16 Mar 2013 18:09:28 -0000 On Wed, Feb 20, 2013 at 09:58:02PM +0200, Mikolaj Golub wrote: > On Wed, Feb 20, 2013 at 09:04:14AM -0500, John Baldwin wrote: > > > The process should be stopped by the time we dump a core, so running it > > multiple times should be ok in that the sizes should not change. I would > > say that you should try to implement a "determine sizes" pass that doesn't > > allocate anything, but others should comment on that. > > I had a little talk with kib about this recently. Kib's main concern > looked to be that a process with many threads/open files might require > considerable amount of kernel memory if the procstat notes are > prepared in memory before writing. So currently I am working on > another approach, when on the first pass the sizes are found, and on > the second pass procstat notes are written to coredump without > preliminarily storing all notes in memory buffer. Hope, the code won't > look very ugly... Here is an updated patch: http://people.freebsd.org/~trociny/procstat_core.2.patch - The coredump routines are modified to be able to write notes directly to a core file, via sbuf interface, without preliminary preparing them all in a memory buffer. - To write NT_PROCSTAT_* notes, the corresponding sysctl routines are changed to provide kern_proc_filedesc_out(), kern_proc_kstack_out(), kern_proc_out(), and kern_proc_vmmap_out() functions. - libprocstat(3) is extended to extract procstat notes from a process core file. Also new functions (procstat_getvmmap, procstat_kstack) are added. - procstat(1) is changed to use libprocstat(3) where it is possible and to treat non-numeric command line arguments as core files. -- Mikolaj Golub