Date: Thu, 29 Jun 2006 04:06:24 GMT From: Kip Macy <kmacy@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 100255 for review Message-ID: <200606290406.k5T46OV3000153@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=100255 Change 100255 by kmacy@kmacy_storage:sun4v_work_stable on 2006/06/29 04:05:29 csjp's Giant removal from sysctls work Affected files ... .. //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_descrip.c#3 integrate .. //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_mib.c#2 integrate .. //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_proc.c#2 integrate .. //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_sysctl.c#2 integrate .. //depot/projects/kmacy_sun4v_stable/src/sys/sys/sysctl.h#2 integrate .. //depot/projects/kmacy_sun4v_stable/src/sys/vm/vm_meter.c#2 integrate Differences ... ==== //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_descrip.c#3 (text+ko) ==== @@ -2468,7 +2468,7 @@ return (error); } -SYSCTL_PROC(_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD, +SYSCTL_PROC(_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_file, "S,xfile", "Entire file table"); #ifdef DDB ==== //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_mib.c#2 (text+ko) ==== @@ -146,7 +146,7 @@ SYSCTL_INT(_hw, HW_BYTEORDER, byteorder, CTLFLAG_RD, 0, BYTE_ORDER, "System byte order"); -SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD, +SYSCTL_INT(_hw, HW_PAGESIZE, pagesize, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, PAGE_SIZE, "System memory page size"); static int ==== //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_proc.c#2 (text+ko) ==== @@ -1283,38 +1283,44 @@ static SYSCTL_NODE(_kern, KERN_PROC, proc, CTLFLAG_RD, 0, "Process table"); -SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, CTLFLAG_RD|CTLTYPE_STRUCT, +SYSCTL_PROC(_kern_proc, KERN_PROC_ALL, all, + CTLFLAG_RD|CTLTYPE_STRUCT|CTLFLAG_MPSAFE, 0, 0, sysctl_kern_proc, "S,proc", "Return entire process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_GID, gid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PGRP, pgrp, + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_RGID, rgid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_RGID, rgid, + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_SESSION, sid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_SESSION, sid, + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_TTY, tty, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_UID, uid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_RUID, ruid, + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PID, pid, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); -static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, CTLFLAG_RD, +static SYSCTL_NODE(_kern_proc, KERN_PROC_PROC, proc, + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Return process table, no threads"); static SYSCTL_NODE(_kern_proc, KERN_PROC_ARGS, args, - CTLFLAG_RW | CTLFLAG_ANYBODY, + CTLFLAG_RW | CTLFLAG_ANYBODY | CTLFLAG_MPSAFE, sysctl_kern_proc_args, "Process argument list"); static SYSCTL_NODE(_kern_proc, KERN_PROC_PATHNAME, pathname, CTLFLAG_RD, @@ -1324,28 +1330,29 @@ sysctl_kern_proc_sv_name, "Process syscall vector name (ABI type)"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_GID | KERN_PROC_INC_THREAD), gid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PGRP | KERN_PROC_INC_THREAD), pgrp_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_RGID | KERN_PROC_INC_THREAD), rgid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_SESSION | KERN_PROC_INC_THREAD), - sid_td, CTLFLAG_RD, sysctl_kern_proc, "Process table"); + sid_td, CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_TTY | KERN_PROC_INC_THREAD), tty_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_UID | KERN_PROC_INC_THREAD), uid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_RUID | KERN_PROC_INC_THREAD), ruid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PID | KERN_PROC_INC_THREAD), pid_td, - CTLFLAG_RD, sysctl_kern_proc, "Process table"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, "Process table"); static SYSCTL_NODE(_kern_proc, (KERN_PROC_PROC | KERN_PROC_INC_THREAD), proc_td, - CTLFLAG_RD, sysctl_kern_proc, "Return process table, no threads"); + CTLFLAG_RD|CTLFLAG_MPSAFE, sysctl_kern_proc, + "Return process table, no threads"); ==== //depot/projects/kmacy_sun4v_stable/src/sys/kern/kern_sysctl.c#2 (text+ko) ==== @@ -1229,19 +1229,25 @@ if (error) return (error); + if ((oid->oid_kind & CTLFLAG_MPSAFE) == 0) + mtx_lock(&Giant); if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) { /* * You can't call a sysctl when it's a node, but has * no handler. Inform the user that it's a node. * The indx may or may not be the same as namelen. */ - if (oid->oid_handler == NULL) - return (EISDIR); + if (oid->oid_handler == NULL) { + error = EISDIR; + goto done; + } } /* Is this sysctl writable? */ - if (req->newptr && !(oid->oid_kind & CTLFLAG_WR)) - return (EPERM); + if (req->newptr && !(oid->oid_kind & CTLFLAG_WR)) { + error = EPERM; + goto done; + } KASSERT(req->td != NULL, ("sysctl_root(): req->td == NULL")); @@ -1250,7 +1256,7 @@ lvl = (oid->oid_kind & CTLMASK_SECURE) >> CTLSHIFT_SECURE; error = securelevel_gt(req->td->td_ucred, lvl); if (error) - return (error); + goto done; } /* Is this sysctl writable by only privileged users? */ @@ -1263,11 +1269,13 @@ flags = 0; error = suser_cred(req->td->td_ucred, flags); if (error) - return (error); + goto done; } - if (!oid->oid_handler) - return (EINVAL); + if (!oid->oid_handler) { + error = EINVAL; + goto done; + } if ((oid->oid_kind & CTLTYPE) == CTLTYPE_NODE) { arg1 = (int *)arg1 + indx; @@ -1280,10 +1288,12 @@ error = mac_check_system_sysctl(req->td->td_ucred, oid, arg1, arg2, req); if (error != 0) - return (error); + goto done; #endif error = oid->oid_handler(oid, arg1, arg2, req); - +done: + if ((oid->oid_kind & CTLFLAG_MPSAFE) == 0) + mtx_unlock(&Giant); return (error); } @@ -1314,8 +1324,6 @@ if (error) return (error); - mtx_lock(&Giant); - error = userland_sysctl(td, name, uap->namelen, uap->old, uap->oldlenp, 0, uap->new, uap->newlen, &j, 0); @@ -1327,7 +1335,6 @@ error = i; } done2: - mtx_unlock(&Giant); return (error); } ==== //depot/projects/kmacy_sun4v_stable/src/sys/sys/sysctl.h#2 (text+ko) ==== @@ -84,6 +84,7 @@ #define CTLFLAG_SKIP 0x01000000 /* Skip this sysctl when listing */ #define CTLMASK_SECURE 0x00F00000 /* Secure level */ #define CTLFLAG_TUN 0x00080000 /* Tunable variable */ +#define CTLFLAG_MPSAFE 0x00040000 /* Handler is MP safe */ #define CTLFLAG_RDTUN (CTLFLAG_RD|CTLFLAG_TUN) /* ==== //depot/projects/kmacy_sun4v_stable/src/sys/vm/vm_meter.c#2 (text+ko) ==== @@ -101,7 +101,7 @@ #endif return SYSCTL_OUT(req, &averunnable, sizeof(averunnable)); } -SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD, +SYSCTL_PROC(_vm, VM_LOADAVG, loadavg, CTLTYPE_STRUCT|CTLFLAG_RD | CTLFLAG_MPSAFE, NULL, 0, sysctl_vm_loadavg, "S,loadavg", "Machine loadaverage history"); static int
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200606290406.k5T46OV3000153>