From owner-freebsd-arch@FreeBSD.ORG Wed Apr 3 00:25:25 2013 Return-Path: Delivered-To: arch@FreeBSD.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id C3955EF5; Wed, 3 Apr 2013 00:25:25 +0000 (UTC) (envelope-from gpalmer@freebsd.org) Received: from noop.in-addr.com (mail.in-addr.com [IPv6:2001:470:8:162::1]) by mx1.freebsd.org (Postfix) with ESMTP id 8D71A729; Wed, 3 Apr 2013 00:25:25 +0000 (UTC) Received: from gjp by noop.in-addr.com with local (Exim 4.80.1 (FreeBSD)) (envelope-from ) id 1UNBVz-0002AW-UT; Tue, 02 Apr 2013 20:25:23 -0400 Date: Tue, 2 Apr 2013 20:25:23 -0400 From: Gary Palmer To: Pawel Jakub Dawidek Subject: Re: [CFR][CFT] counter(9): new API for faster and raceless counters Message-ID: <20130403002523.GA96431@in-addr.com> References: <20130401115128.GZ76816@FreeBSD.org> <20130402232606.GC1810@garage.freebsd.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20130402232606.GC1810@garage.freebsd.pl> X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: gpalmer@freebsd.org X-SA-Exim-Scanned: No (on noop.in-addr.com); SAEximRunCond expanded to false Cc: arch@FreeBSD.org, Gleb Smirnoff X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 Apr 2013 00:25:25 -0000 On Wed, Apr 03, 2013 at 01:26:07AM +0200, Pawel Jakub Dawidek wrote: > On Mon, Apr 01, 2013 at 03:51:28PM +0400, Gleb Smirnoff wrote: > > Hi! > > > > Together with Konstantin Belousov (kib@) we developed a new API that is > > initially purposed for (but not limited to) collecting statistical > > data in kernel. > > Is there any plan to implement universal way of exporting those > statistics out of the kernel? > > Solaris has a framework for in-kernel statistics, which are exported via > kstat tool. For ZFS I export them via sysctl. If you have ZFS loaded you > can try 'sysctl kstat'. > > It would be nice for counter_u64_alloc() to take additional argument > 'name' and to create sysctl for the counter automatically. We could then > slowly start migrating userland tools to use sysctls (or some wrapper > userland API), but we immediately make those statistics available for > use in scripts. Sorry for potentially turning this into a bikeshed, but is sysctl the best interface for this? It is great for scripts as the CLI is already there, however it is not a bulk interface so grabbing all the ZFS statistics takes quite a few trips through our system call handler - 438 on my 9.1 box for "sysctl kstat" (found via ktrace and then kdump | grep -c SCTL), which is not ideal when there are only 87 stats there. (5 calls per OID returned and 3 initial calls to get set up) I'm not sure I have a better alternative other than a geom style bulk export via XML or some other format, however I wanted to raise it for consideration. I wouldn't hold up the checkin of the code for this, however if another way of gathering the data is needed/desired then it would be good to get it in before people get too used to the sysctl way. Thanks, Gary