From owner-svn-src-all@FreeBSD.ORG Wed Mar 25 11:27:06 2015 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4702546F; Wed, 25 Mar 2015 11:27:06 +0000 (UTC) Received: from mail.turbocat.net (mail.turbocat.net [IPv6:2a01:4f8:d16:4514::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06D49FF2; Wed, 25 Mar 2015 11:27:06 +0000 (UTC) Received: from laptop015.home.selasky.org (cm-176.74.213.204.customer.telag.net [176.74.213.204]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 8CCEA1FE022; Wed, 25 Mar 2015 12:27:02 +0100 (CET) Message-ID: <55129BB5.4000502@selasky.org> Date: Wed, 25 Mar 2015 12:27:49 +0100 From: Hans Petter Selasky User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Gleb Smirnoff Subject: Re: svn commit: r280495 - head/sys/kern References: <201503250855.t2P8tZFp038467@svn.freebsd.org> <20150325105409.GS64665@FreeBSD.org> <551296C6.9070402@selasky.org> <20150325111433.GT64665@FreeBSD.org> In-Reply-To: <20150325111433.GT64665@FreeBSD.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2015 11:27:06 -0000 On 03/25/15 12:14, Gleb Smirnoff wrote: > On Wed, Mar 25, 2015 at 12:06:46PM +0100, Hans Petter Selasky wrote: > H> On 03/25/15 11:54, Gleb Smirnoff wrote: > H> > On Wed, Mar 25, 2015 at 08:55:35AM +0000, Hans Petter Selasky wrote: > H> > H> Author: hselasky > H> > H> Date: Wed Mar 25 08:55:34 2015 > H> > H> New Revision: 280495 > H> > H> URL: https://svnweb.freebsd.org/changeset/base/280495 > H> > H> > H> > H> Log: > H> > H> Implement a simple OID number garbage collector. Given the increasing > H> > H> number of dynamically created and destroyed SYSCTLs during runtime it > H> > H> is very likely that the current new OID number limit of 0x7fffffff can > H> > H> be reached. Especially if dynamic OID creation and destruction results > H> > H> from automatic tests. Additional changes: > H> > H> > H> > H> - Optimize the typical use case by decrementing the next automatic OID > H> > H> sequence number instead of incrementing it. This saves searching time > H> > H> when inserting new OIDs into a fresh parent OID node. > H> > H> > H> > H> - Add simple check for duplicate non-automatic OID numbers. > H> > > H> > Why didn't you use alloc_unr(9) for that? > H> > > H> > H> Hi Gleb, > H> > H> I thought about using alloc_unr(). The problem is that sysctls have no > H> clear concept of freeing. For example in some existing code sysctl are > H> unregistered and registered again assuming that the oid_number will be > H> preserved. I didn't want touch those parts. Also, hence we are already > H> traversing a list to insert an SYSCTL object in an ordered fashion, the > H> benefit of alloc_unr() is not that big. What do you think? > > Is it possible to split the space into two halves: one for static OIDs and > other for dynamic ones? The latter allocated via alloc_unr? > Yes, it is possible to do. One issue though is that the OID numbers shouldn't be recycled right away to preserve the old behaviour. It is not written anywhere, but I think there is some cleverness into the fact that the newoid value does not repeat instantly, as would happen using alloc_unr() to avoid races accessing OIDs from userspace? Does alloc_unr() support a sort of rotating allocation number mode within the defined range? The OID numbers are only required to be unique per directory level from what I can see. --HPS