From owner-freebsd-arch@FreeBSD.ORG Tue Jun 1 11:29:49 2004 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3CBD516A4CE for ; Tue, 1 Jun 2004 11:29:49 -0700 (PDT) Received: from elvis.mu.org (elvis.mu.org [192.203.228.196]) by mx1.FreeBSD.org (Postfix) with ESMTP id 293A243D3F for ; Tue, 1 Jun 2004 11:29:49 -0700 (PDT) (envelope-from mux@freebsd.org) Received: by elvis.mu.org (Postfix, from userid 1920) id 22EFC5C836; Tue, 1 Jun 2004 11:29:49 -0700 (PDT) Date: Tue, 1 Jun 2004 20:29:49 +0200 From: Maxime Henrion To: arch@FreeBSD.org Message-ID: <20040601182949.GC9228@elvis.mu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="xgyAXRrhYN0wYx8y" Content-Disposition: inline User-Agent: Mutt/1.4.2.1i Subject: The new dev sysctl tree X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Jun 2004 18:29:49 -0000 --xgyAXRrhYN0wYx8y Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi all, Dag-Erling recently committed some code that makes it extremely easy and convenient to have per-devices sysctl. I changed the fxp(4) driver to use this new framework for its sysctls, which allows to remove a bit of code from this driver. However, there is a significant drawback. For instance, what used to be "hw.fxp0.int_delay" is now called (on my box) : "dev.root0.nexus0.acpi0.pcib0.pci0.fxp0.int_delay". Obviously, this is really too long to be convenient to use. Furthermore, the name of this sysctl is not unique anymore. This is particularly annoying in some cases. For instance, if someone needs to boot without acpi while he's using it the rest of the time, the sysctl won't be named the same. So I made a patch to flatten this sysctl tree. This doesn't cause any conflict since attached drivers' names are unique. As a consequence, we lose the hierarchy information from the sysctl tree, however I believe this isn't a problem since we can get this information with devinfo(8) already. If for some reason, we really need the hierarchy information in this sysctl tree, I can easily add a .parent sysctl to each device node. I'm attaching the patch that flattens the sysctl tree to this mail. Opinions are of course welcome, but please, this isn't a call for yet another bikeshed of hell, so keep to the point. Cheers, Maxime --xgyAXRrhYN0wYx8y Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="dev_sysctl.patch" Index: subr_bus.c =================================================================== RCS file: /space2/ncvs/src/sys/kern/subr_bus.c,v retrieving revision 1.146 diff -u -p -r1.146 subr_bus.c --- subr_bus.c 26 May 2004 16:36:32 -0000 1.146 +++ subr_bus.c 31 May 2004 23:58:00 -0000 @@ -241,22 +241,13 @@ device_sysctl_handler(SYSCTL_HANDLER_ARG static void device_sysctl_init(device_t dev) { - struct sysctl_oid_list *parent_node; - if (dev->parent) { - if (dev->parent->sysctl_tree == NULL) - device_sysctl_init(dev->parent); - parent_node = SYSCTL_CHILDREN(dev->parent->sysctl_tree); - } else { - parent_node = SYSCTL_STATIC_CHILDREN(_dev); - } - if (dev->sysctl_tree != NULL) { - sysctl_move_oid(dev->sysctl_tree, parent_node); + if (dev->sysctl_tree != NULL) return; - } sysctl_ctx_init(&dev->sysctl_ctx); - dev->sysctl_tree = SYSCTL_ADD_NODE(&dev->sysctl_ctx, parent_node, - OID_AUTO, dev->nameunit, CTLFLAG_RD, 0, ""); + dev->sysctl_tree = SYSCTL_ADD_NODE(&dev->sysctl_ctx, + SYSCTL_STATIC_CHILDREN(_dev), OID_AUTO, dev->nameunit, + CTLFLAG_RD, 0, ""); SYSCTL_ADD_PROC(&dev->sysctl_ctx, SYSCTL_CHILDREN(dev->sysctl_tree), OID_AUTO, "%class", CTLFLAG_RD, dev, DEVICE_SYSCTL_CLASS, device_sysctl_handler, "A", --xgyAXRrhYN0wYx8y--