Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 2 Feb 2009 13:44:18 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        ia64@freebsd.org
Subject:   Change ia64 mca sysctls to use standard dynamic sysctls
Message-ID:  <200902021344.19249.jhb@freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200902021344.19249.jhb>