From owner-freebsd-ia64@FreeBSD.ORG Mon Feb 2 18:44:50 2009 Return-Path: Delivered-To: ia64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0BC4A1065707 for ; Mon, 2 Feb 2009 18:44:50 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id D2B048FC08 for ; Mon, 2 Feb 2009 18:44:49 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 68CFF46B2D for ; Mon, 2 Feb 2009 13:44:49 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n12IiPOk042733 for ; Mon, 2 Feb 2009 13:44:43 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: ia64@freebsd.org Date: Mon, 2 Feb 2009 13:44:18 -0500 User-Agent: KMail/1.9.7 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200902021344.19249.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Mon, 02 Feb 2009 13:44:43 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8941/Mon Feb 2 10:34:46 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Subject: Change ia64 mca sysctls to use standard dynamic sysctls X-BeenThere: freebsd-ia64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the IA-64 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Feb 2009 18:44:50 -0000 While working on the locking for the sysctl tree, I ran into the pseudo-dynamic machine check sysctls in ia64. It is not really a good idea to call sysctl_register_oid() with a spin lock held and once I add locking to sysctl it becomes a bad LOR. This changes the code to use the public API for adding dynamic sysctls outside of the spin lock. Please test this as it is a prerequisite for finishing the locking of the sysctl tree. --- //depot/projects/smpng/sys/ia64/ia64/mca.c 2007/05/19 15:31:43 +++ //depot/user/jhb/lock/ia64/ia64/mca.c 2009/01/28 21:26:22 @@ -80,10 +80,9 @@ { struct ia64_sal_result result; struct mca_record_header *hdr; - struct sysctl_oid *oidp; char *name, *state; uint64_t seqnr; - size_t recsz, totsz; + size_t recsz; /* * Don't try to get the state if we couldn't get the size of @@ -111,9 +110,7 @@ mtx_unlock_spin(&mca_info_block_lock); - totsz = sizeof(struct sysctl_oid) + recsz + 32; - oidp = malloc(totsz, M_MCA, M_NOWAIT|M_ZERO); - state = (char*)(oidp + 1); + state = malloc(recsz + 32, M_MCA, M_WAITOK | M_ZERO); name = state + recsz; sprintf(name, "%lld", (long long)seqnr); @@ -140,18 +137,6 @@ bcopy((char*)mca_info_block, state, recsz); - oidp->oid_parent = &sysctl__hw_mca_children; - oidp->oid_number = OID_AUTO; - oidp->oid_kind = CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_DYN; - oidp->oid_arg1 = state; - oidp->oid_arg2 = recsz; - oidp->oid_name = name; - oidp->oid_handler = mca_sysctl_handler; - oidp->oid_fmt = "S,MCA"; - oidp->oid_descr = "Error record"; - - sysctl_register_oid(oidp); - if (mca_count > 0) { if (seqnr < mca_first) mca_first = seqnr; @@ -170,6 +155,10 @@ 0, 0, 0); mtx_unlock_spin(&mca_info_block_lock); + + (void)SYSCTL_ADD_PROC(NULL, SYSCTL_STATIC_CHILDREN(_hw_mca), + OID_AUTO, name, CTLTYPE_OPAQUE | CTLFLAG_RD, state, recsz, + mca_sysctl_handler, "S,MCA", "Error record"); } } -- John Baldwin