From owner-freebsd-arch@FreeBSD.ORG Sun Jan 16 05:35:54 2011 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 496641065672; Sun, 16 Jan 2011 05:35:54 +0000 (UTC) (envelope-from mdf356@gmail.com) Received: from mail-iy0-f182.google.com (mail-iy0-f182.google.com [209.85.210.182]) by mx1.freebsd.org (Postfix) with ESMTP id F2D718FC08; Sun, 16 Jan 2011 05:35:53 +0000 (UTC) Received: by iyb26 with SMTP id 26so3807055iyb.13 for ; Sat, 15 Jan 2011 21:35:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=cSbf6Pk9uBZpWF26YXUAvapuiLgsaTIYlppU7eK9U0Q=; b=O4jx+A3PQLo/nn+/sbCo+VNLSu31cii8NbXWumJVYQstL/xhlKC0a9hHQ40A0nw6cV xSLNPGz+t86pil8JFHD1Y9VI4iVXOitlwreOQv1mvO/idAJsmCbZS3IEpakZnlIGW75O X8N2CbP4L2BBh0XPJY288IHwOG8N6LLJK83ZQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=xVJuzttOYKfE+VV4qU+0AO+zw5eenQ3WLy02kamdHzl5flHsQCdV418U5fSSTom0Vx ql10AckjBWJVjXspfeH5mslma3TlNZRe05gpsNci8myvK6ZRSJ6CpMnOWJugk8eJhvJu RfhPo1SvIsJ7IYjx37KqxCMIpqj9PRtqrsh4k= MIME-Version: 1.0 Received: by 10.231.173.67 with SMTP id o3mr2661561ibz.29.1295156153493; Sat, 15 Jan 2011 21:35:53 -0800 (PST) Sender: mdf356@gmail.com Received: by 10.231.160.147 with HTTP; Sat, 15 Jan 2011 21:35:53 -0800 (PST) In-Reply-To: References: Date: Sat, 15 Jan 2011 21:35:53 -0800 X-Google-Sender-Auth: 6WFjP7d0PXKl6vrYMOL3dAnYF9U Message-ID: From: mdf@FreeBSD.org To: Garrett Cooper Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Arch Subject: Re: Automagic SYSCTLs X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 16 Jan 2011 05:35:54 -0000 On Sat, Jan 15, 2011 at 5:10 PM, Garrett Cooper wrote= : > On Sat, Jan 15, 2011 at 4:12 PM, =A0 wrote: >> I started out with a plan to import a patch from Isilon that adds >> type-safety to the existing SYSCTLs for scalar variables in the >> kernel. =A0After the discussion on the svn mailing list here >> (http://lists.freebsd.org/pipermail/svn-src-head/2011-January/024097.htm= l) >> I now have a prototype patch for SYSCTL_ADD_SCALAR that could replace >> most uses of SYSCTL_ADD_{INT, UINT, LONG, ULONG, QUAD} and is suitable >> for the SYSCTL_ADD_FOO that are used on 16 and 8 bit members (without >> type checking) today. >> >> The gist is that the handler knows the sizeof the variable in the >> kernel and uses this to copy out. =A0For the case of a long, there's >> some goop for SCTL_MASK32. =A0For the case of 8 and 16 bit variables, >> they are still copied in and out as 32-bit quantities. >> >> Let me know if this seems like the right or wrong direction in which >> to move. =A0I haven't tackled the static sysctls as the code I have does >> some run-time evaluation because the code is easier to write that way. >> =A0One possibility is to change the sysctl_oid struct or at least add a >> SIGNED flag; this would also have the advantage of making it possible >> to clean up the CTLTYPE_[U]INT issue where there is no real difference >> between the two CTLTYPEs. >> >> http://people.freebsd.org/~mdf/bsd-sysctl-scalar.diff > > Looks interesting, but what are the performance implications of the new l= ogic? I guess I'm not quite sure how to answer this. The add should be about the same, and it's only done once at kernel or driver init. The handler time is essentially meaningless since even reading the value using sysctl(8) will take the SYSCTL lock several times, and doing a write will take it quite a few more. Thanks, matthew