From owner-freebsd-hackers Tue Aug 20 11: 8: 7 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 7D32237B400 for ; Tue, 20 Aug 2002 11:08:00 -0700 (PDT) Received: from heaven.gigo.com (heaven.gigo.com [64.57.102.22]) by mx1.FreeBSD.org (Postfix) with ESMTP id D466D43E6A for ; Tue, 20 Aug 2002 11:07:59 -0700 (PDT) (envelope-from lioux@brturbo.com) Received: from 200-193-225-074-bsace7003.dsl.telebrasilia.net.br (200-193-225-074-bsace7003.dsl.telebrasilia.net.br [200.193.225.74]) by heaven.gigo.com (Postfix) with ESMTP id 1D29EB706 for ; Tue, 20 Aug 2002 11:07:44 -0700 (PDT) Received: (qmail 928 invoked by uid 1001); 20 Aug 2002 18:02:22 -0000 Message-ID: <20020820180222.927.qmail@exxodus.fedaykin.here> Date: Tue, 20 Aug 2002 15:02:00 -0300 From: Mario Sergio Fujikawa Ferreira To: FreeBSD-hackers@FreeBSD.org Subject: Creating a sysctl? (mission impossible) Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="IJpNTDwzlM2Ie8A6" Content-Disposition: inline User-Agent: Mutt/1.4i X-Operating-System: FreeBSD 4.6-STABLE X-Disclaimer: I hope you find what you are looking for... in life :) Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi, This is for -STABLE system as of August 15th. $ uname -a FreeBSD Here.here 4.6-STABLE FreeBSD 4.6-STABLE #8: Tue Aug 20 14:42:43 BRT 2002 lioux@Here.here:/usr/src/sys/compile/LIOUX i386 I am trying to create one sysctl so that I can read information from a lottery scheduler that I am trying to write. The sysctl is very very simple. I add a lottery node under kern then add a member global_tickets under kern.lottery. Very simple stuff that is not working. Here follows the sample I am using. I used kern_poll.c as example. 1) Created a file kern_lottery.c which is attached. Then, placed this file under /usr/src/sys/kern/kern_lottery; 2) Then, added a reference for it in both /usr/src/sys/conf/files and /usr/src/sys/conf/options. Check attached patch-lottery; 3) Then, added "options SCHEDULER_LOTTERY" to a kernel config file. Compiled, installed, rebooted. Here follows the results after the reboot: $ nm /kernel | grep -i lotter c0237ee0 d sysctl___kern_lottery c0237f20 d sysctl___kern_lottery_global_tickets c0264238 B sysctl__kern_lottery_children $ sysctl -a | grep -i lot $ sysctl -A | grep -i lot As you can see, sysctl returns nothing even though the relevant symbols are in the kernel. It knows nothing about the lottery node. I can reproduce this "problem" in 2 different boxes with different versions of -STABLE. The relevant sysctl code follows: typedef _BSD_PID_T_ ticket_t; /* ticket type */ static ticket_t global_tickets = 0; /* XXX lottery */ SYSCTL_NODE(_kern, OID_AUTO, lottery, CTLFLAG_RW, 0, "Lottery scheduling parameters"); SYSCTL_UINT(_kern_lottery, OID_AUTO, global_tickets, CTLFLAG_RD, &global_tickets, 0, "Current global tickets") Any ideas why this is not working? Help plz. I hope you guys know what I am doing wrong. IF I add this code to kern_switch.c, everything works but it does not work when I add to kern_lottery.c My 1st thought is that it does not like the fact that I'm trying to create a node inside kern from another file. However, kern_poll.c works like a charm. Regards, ps: please CC: me in your replies since I only receive digests of this list. -- Mario S F Ferreira - DF - Brazil - "I guess this is a signature." Computer Science Undergraduate | FreeBSD Committer | CS Developer flames to beloved devnull@someotherworldbeloworabove.org feature, n: a documented bug | bug, n: an undocumented feature --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=patch-lottery --- sys/conf/files.orig Tue Aug 20 14:48:54 2002 +++ sys/conf/files Tue Aug 20 14:37:49 2002 @@ -572,6 +572,8 @@ kern/kern_ktrace.c standard kern/kern_lock.c standard kern/kern_lockf.c standard +# XXX lottery +kern/kern_lottery.c optional scheduler_lottery kern/kern_malloc.c standard kern/kern_mib.c standard kern/kern_ntptime.c standard --- sys/conf/options.orig Tue Aug 20 14:49:02 2002 +++ sys/conf/options Tue Aug 20 14:38:17 2002 @@ -468,3 +468,7 @@ # Polling device handling DEVICE_POLLING opt_global.h + +# XXX lottery +# Lottery scheduler +SCHEDULER_LOTTERY opt_sched_lottery.h --IJpNTDwzlM2Ie8A6 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="kern_lottery.c" /* * Copyright (c) 2001, 2002 * Mario Sergio Fujikawa Ferreira * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Fedaykin: src/sys/kern/kern_lottery.c,v 1.1.2.10 2002/08/19 19:37:34 lioux Exp $ */ #ifdef SMP #include "opt_lint.h" #ifndef COMPILING_LINT #error SCHEDULER_LOTTERY is not compatible with SMP yet #endif #endif #include #include #include /* the process structure */ #include #include #include #include typedef _BSD_PID_T_ ticket_t; /* ticket type */ static ticket_t global_tickets = 0; /* XXX lottery */ SYSCTL_NODE(_kern, OID_AUTO, lottery, CTLFLAG_RW, 0, "Lottery scheduling parameters"); SYSCTL_UINT(_kern_lottery, OID_AUTO, global_tickets, CTLFLAG_RD, &global_tickets, 0, "Current global tickets"); --IJpNTDwzlM2Ie8A6-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message