From owner-freebsd-arch@FreeBSD.ORG Thu Apr 9 15:51:52 2015 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 04929868 for ; Thu, 9 Apr 2015 15:51:52 +0000 (UTC) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D201BD0C for ; Thu, 9 Apr 2015 15:51:51 +0000 (UTC) Received: from ralph.baldwin.cx (pool-173-54-116-245.nwrknj.fios.verizon.net [173.54.116.245]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id C2613B926; Thu, 9 Apr 2015 11:51:49 -0400 (EDT) From: John Baldwin To: freebsd-arch@freebsd.org Subject: Re: sysctl output formatting Date: Thu, 09 Apr 2015 11:51:17 -0400 Message-ID: <4560967.0vtmTZXoz1@ralph.baldwin.cx> User-Agent: KMail/4.14.2 (FreeBSD/10.1-STABLE; KDE/4.14.2; amd64; ; ) In-Reply-To: <201504062229.t36MTMlJ024359@elf.torek.net> References: <201504062229.t36MTMlJ024359@elf.torek.net> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Thu, 09 Apr 2015 11:51:49 -0400 (EDT) Cc: Chris Torek X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Apr 2015 15:51:52 -0000 On Monday, April 06, 2015 03:29:22 PM Chris Torek wrote: > We had a side discussion at $work about a private sysctl emulation > (so our side thing doesn't actually affect sysctl itself at all) > where it was suggested that some simple numeric sysctls are "best > displayed in hex". We had this feature for hex and it was removed. 8.x still has SYSCTL_XINT() and friends. It was removed in https://svnweb.freebsd.org/base?view=revision&revision=217586 The argument in that comment is that you should use sysctl -x. However, I think that doesn't really wash. That is fine if you are looking at a single node, but I think SYSCTL_XINT() was useful to set the default format that was used for sysctl -a, etc. You could then have flags to sysctl to override it for individual nodes for use in scripts, etc. > Consider, e.g.: > > $ sysctl kern.timecounter.tc.i8254 > kern.timecounter.tc.i8254.mask: 65535 > kern.timecounter.tc.i8254.counter: 25822 > kern.timecounter.tc.i8254.frequency: 1193182 > kern.timecounter.tc.i8254.quality: 0 > > The "mask" here actually makes more sense displayed in hex. One > can of course use: > > $ sysctl -x kern.timecounter.tc.i8254 > kern.timecounter.tc.i8254.mask: 0x0000ffff > kern.timecounter.tc.i8254.counter: 0x0000786c > kern.timecounter.tc.i8254.frequency: 0x00000000001234de > kern.timecounter.tc.i8254.quality: 0000000000 > > but now the mask is shown in hex (yay) but the others are shown > in hex too (boo). Exactly. I would support bringing the XINT variants back. Note that you would not want to revert the above commit, but you would want to make the XINT variants use a format of "X" and then fix sysctl(8) to handle "X" formats again. -- John Baldwin