From owner-freebsd-hackers@FreeBSD.ORG Sat Aug 7 17:42:04 2010 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2F471106564A for ; Sat, 7 Aug 2010 17:42:04 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id E71C08FC1C for ; Sat, 7 Aug 2010 17:42:03 +0000 (UTC) Received: by iwn10 with SMTP id 10so2992211iwn.13 for ; Sat, 07 Aug 2010 10:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=P3ZbxXnF03FQlFGXe4ciyojZgic/eF14XsXcW1fQZJk=; b=ZLCwe42j38rCXbJLY8JC96j75SfgJ5E/dd2xol0CcaXhA8mDgOK42u4c98IEk3sMiW o/mJxsNLeAfU6/Pb9rjdareyvoOtejrPGkfhuM61HLWamAcgFgmN/Y4aIqyHFPqXQ72h 0TDIOitsy6zHKbdXqr9obOll1XPhjsRmptLuA= 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=nx1ZuBAxLMnpcU8pC0cxp/uQB1UggU0RCAQSqUWEuqjNcwLNA3EqVj001mhxdeiwOM GRBZ7dMmarqYvaYvY0zyx5ug3J/NcpJd+Y/SgxN7SF7ThJkdggSrHp7jehNAekT7C2gi qFqubpM/aky3bM5QXOmM/nNWznWj2EguCkEho= MIME-Version: 1.0 Received: by 10.231.169.10 with SMTP id w10mr16287049iby.106.1281202922801; Sat, 07 Aug 2010 10:42:02 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.173.133 with HTTP; Sat, 7 Aug 2010 10:42:02 -0700 (PDT) In-Reply-To: <86fwyq8rsc.fsf@ds4.des.no> References: <86fwyq8rsc.fsf@ds4.des.no> Date: Sat, 7 Aug 2010 10:42:02 -0700 X-Google-Sender-Auth: 5Pj_Myq0EMTa9jvslKAmuSOwTOQ Message-ID: From: Garrett Cooper To: =?ISO-8859-1?Q?Dag=2DErling_Sm=F8rgrav?= Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: hackers@freebsd.org Subject: Re: Why is TUNABLE_INT discouraged? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 07 Aug 2010 17:42:04 -0000 2010/8/7 Dag-Erling Sm=F8rgrav : > Garrett Cooper writes: >> =A0 =A0I found the commit where it was made (by des@ -- cvs revision >> 1.120), but unfortunately I lack the context as to why that suggestion >> is made; the commit isn't very explicit as to why integers tunables >> should be discouraged > > You're supposed to use TUNABLE_LONG or TUNABLE_ULONG instead. =A0From > digging in the -current archives, it seems that the motivation was a bug > that resulted from using a TUNABLE_INT for a value that was actually an > address. =A0It was doubly broken: first because it was too small on 64-bi= t > systems, and second because it was signed. Thanks for the explanation. I just found it interesting how the interfaces to [PCI BUS] resources, sysctls, and tunables are inconsistent in terms of what data types they support; resources only supports signed integers of various widths, sysctls support everything under the sun, and we know the story on tunables now. It's ok most of the time, but as we all know there are limits to the ranges for integers, and there's something a bit quirky about some of the code in sound(4) that I'm experimenting with to see whether or not it was there's an issue with bad casting, comparison, an uninitialized value, or another random race condition, that's wreaking havoc with my Audigy card every time I attach the driver as a module. Thanks! -Garrett