Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/sys Update from trunk:
details: https://anonhg.NetBSD.org/src/rev/5e9110f3cc0d
branches: netbsd-1-5
changeset: 488522:5e9110f3cc0d
user: thorpej <thorpej%NetBSD.org@localhost>
date: Fri Jul 14 18:10:49 2000 +0000
description:
Update from trunk:
- Fix the likely cause of the "ps(1) hangs machine" problem. Always
vslock the user pages for the data being copied out to userspace,
so that we won't sleep while holding a lock in case we need to
fault the pages in.
- Sprinkle some const and ANSI'ify some things while here.
diffstat:
sys/compat/netbsd32/netbsd32_netbsd.c | 62 ++++++++---------------
sys/kern/init_main.c | 45 ++++++++--------
sys/kern/kern_sysctl.c | 92 ++++++++++++++++------------------
sys/sys/sysctl.h | 14 +++-
sys/sys/systm.h | 10 +-
5 files changed, 103 insertions(+), 120 deletions(-)
diffs (truncated from 516 to 300 lines):
diff -r f6ab48e8b7f6 -r 5e9110f3cc0d sys/compat/netbsd32/netbsd32_netbsd.c
--- a/sys/compat/netbsd32/netbsd32_netbsd.c Fri Jul 14 18:04:45 2000 +0000
+++ b/sys/compat/netbsd32/netbsd32_netbsd.c Fri Jul 14 18:10:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_netbsd.c,v 1.28.2.1 2000/07/13 20:20:27 thorpej Exp $ */
+/* $NetBSD: netbsd32_netbsd.c,v 1.28.2.2 2000/07/14 18:10:49 thorpej Exp $ */
/*
* Copyright (c) 1998 Matthew R. Green
@@ -81,6 +81,7 @@
#include <sys/proc.h>
#include <sys/acct.h>
#include <sys/exec.h>
+#define __SYSCTL_PRIVATE
#include <sys/sysctl.h>
#include <net/if.h>
@@ -4083,7 +4084,7 @@
syscallarg(netbsd32_voidp) new;
syscallarg(netbsd32_size_t) newlen;
} */ *uap = v;
- int error, dolock = 1;
+ int error;
netbsd32_size_t savelen = 0;
size_t oldlen = 0;
sysctlfn *fn;
@@ -4111,8 +4112,6 @@
switch (name[0]) {
case CTL_KERN:
fn = kern_sysctl;
- if (name[2] != KERN_VNODE) /* XXX */
- dolock = 0;
break;
case CTL_HW:
fn = hw_sysctl;
@@ -4139,40 +4138,29 @@
fn = ddb_sysctl;
break;
#endif
+ case CTL_PROC:
+ fn = proc_sysctl;
+ break;
default:
return (EOPNOTSUPP);
}
+ /*
+ * XXX Hey, we wire `old', but what about `new'?
+ */
+
if (SCARG(uap, oldlenp) &&
- (error = copyin((caddr_t)(u_long)SCARG(uap, oldlenp), &savelen, sizeof(savelen))))
+ (error = copyin((caddr_t)(u_long)SCARG(uap, oldlenp), &savelen,
+ sizeof(savelen))))
return (error);
if (SCARG(uap, old) != NULL) {
- if (!uvm_useracc((caddr_t)(u_long)SCARG(uap, old), savelen, B_WRITE))
+ error = lockmgr(&sysctl_memlock, LK_EXCLUSIVE, NULL);
+ if (error)
+ return (error);
+ if (uvm_vslock(p, (void *)(u_long)SCARG(uap, old), savelen,
+ VM_PROT_READ|VM_PROT_WRITE) != KERN_SUCCESS) {
+ (void) lockmgr(&sysctl_memlock, LK_RELEASE, NULL);
return (EFAULT);
-#if 0 /* XXXXXXXX */
- while (memlock.sl_lock) {
- memlock.sl_want = 1;
- (void) tsleep(&memlock, PRIBIO+1, "memlock", 0);
- memlock.sl_locked++;
- }
- memlock.sl_lock = 1;
-#endif /* XXXXXXXX */
- if (dolock) {
- /*
- * XXX Um, this is kind of evil. What should
- * XXX we be passing here?
- */
- if (uvm_vslock(p, (void *)(u_long)SCARG(uap, old), savelen,
- VM_PROT_NONE) != KERN_SUCCESS) {
-#if 0 /* XXXXXXXX */
- memlock.sl_lock = 0;
- if (memlock.sl_want) {
- memlock.sl_want = 0;
- wakeup((caddr_t)&memlock);
- }
-#endif /* XXXXXXXX */
- return (EFAULT);
- }
}
oldlen = savelen;
}
@@ -4180,21 +4168,15 @@
(void *)(u_long)SCARG(uap, old), &oldlen,
(void *)(u_long)SCARG(uap, new), SCARG(uap, newlen), p);
if (SCARG(uap, old) != NULL) {
- if (dolock)
- uvm_vsunlock(p, (void *)(u_long)SCARG(uap, old), savelen);
-#if 0 /* XXXXXXXXXXX */
- memlock.sl_lock = 0;
- if (memlock.sl_want) {
- memlock.sl_want = 0;
- wakeup((caddr_t)&memlock);
- }
-#endif /* XXXXXXXXX */
+ uvm_vsunlock(p, (void *)(u_long)SCARG(uap, old), savelen);
+ (void) lockmgr(&sysctl_memlock, LK_RELEASE, NULL);
}
savelen = oldlen;
if (error)
return (error);
if (SCARG(uap, oldlenp))
- error = copyout(&savelen, (caddr_t)(u_long)SCARG(uap, oldlenp), sizeof(savelen));
+ error = copyout(&savelen,
+ (caddr_t)(u_long)SCARG(uap, oldlenp), sizeof(savelen));
return (error);
}
diff -r f6ab48e8b7f6 -r 5e9110f3cc0d sys/kern/init_main.c
--- a/sys/kern/init_main.c Fri Jul 14 18:04:45 2000 +0000
+++ b/sys/kern/init_main.c Fri Jul 14 18:10:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_main.c,v 1.172 2000/06/06 18:26:35 soren Exp $ */
+/* $NetBSD: init_main.c,v 1.172.2.1 2000/07/14 18:10:50 thorpej Exp $ */
/*
* Copyright (c) 1995 Christopher G. Demetriou. All rights reserved.
@@ -75,6 +75,7 @@
#include <sys/protosw.h>
#include <sys/reboot.h>
#include <sys/user.h>
+#include <sys/sysctl.h>
#ifdef SYSVSHM
#include <sys/shm.h>
#endif
@@ -109,7 +110,7 @@
#include <net/if.h>
#include <net/raw_cb.h>
-char copyright[] = "\
+const char copyright[] = "\
Copyright (c) 1996, 1997, 1998, 1999, 2000
The NetBSD Foundation, Inc. All rights reserved.
Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -142,11 +143,11 @@
__volatile int start_init_exec; /* semaphore for start_init() */
-static void check_console __P((struct proc *p));
-static void start_init __P((void *));
-static void start_pagedaemon __P((void *));
-static void start_reaper __P((void *));
-void main __P((void));
+static void check_console(struct proc *p);
+static void start_init(void *);
+static void start_pagedaemon(void *);
+static void start_reaper(void *);
+void main(void);
extern char sigcode[], esigcode[];
#ifdef SYSCALL_DEBUG
@@ -179,17 +180,17 @@
* startup(), which does memory initialization and autoconfiguration.
*/
void
-main()
+main(void)
{
struct proc *p;
struct pdevinit *pdev;
int i, s, error;
extern struct pdevinit pdevinit[];
- extern void roundrobin __P((void *));
- extern void schedcpu __P((void *));
- extern void disk_init __P((void));
+ extern void roundrobin(void *);
+ extern void schedcpu(void *);
+ extern void disk_init(void);
#if defined(NFSSERVER) || defined(NFS)
- extern void nfs_init __P((void));
+ extern void nfs_init(void);
#endif
/*
@@ -232,6 +233,9 @@
rnd_init(); /* initialize RNG */
#endif
+ /* Initialize the sysctl subsystem. */
+ sysctl_init();
+
/*
* Initialize process and pgrp structures.
*/
@@ -506,8 +510,7 @@
}
static void
-check_console(p)
- struct proc *p;
+check_console(struct proc *p)
{
struct nameidata nd;
int error;
@@ -525,7 +528,7 @@
/*
* List of paths to try when searching for "init".
*/
-static char *initpaths[] = {
+static const char *initpaths[] = {
"/sbin/init",
"/sbin/oinit",
"/sbin/init.bak",
@@ -537,8 +540,7 @@
* The program is invoked with one argument containing the boot flags.
*/
static void
-start_init(arg)
- void *arg;
+start_init(void *arg)
{
struct proc *p = arg;
vaddr_t addr;
@@ -550,7 +552,8 @@
int options, i, error;
register_t retval[2];
char flags[4], *flagsp;
- char **pathp, *path, *slash, *ucp, **uap, *arg0, *arg1 = NULL;
+ const char **pathp, *path, *slash;
+ char *ucp, **uap, *arg0, *arg1 = NULL;
/*
* Now in process 1.
@@ -665,8 +668,7 @@
/* ARGSUSED */
static void
-start_pagedaemon(arg)
- void *arg;
+start_pagedaemon(void *arg)
{
uvm_pageout();
@@ -675,8 +677,7 @@
/* ARGSUSED */
static void
-start_reaper(arg)
- void *arg;
+start_reaper(void *arg)
{
reaper();
diff -r f6ab48e8b7f6 -r 5e9110f3cc0d sys/kern/kern_sysctl.c
--- a/sys/kern/kern_sysctl.c Fri Jul 14 18:04:45 2000 +0000
+++ b/sys/kern/kern_sysctl.c Fri Jul 14 18:10:49 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_sysctl.c,v 1.73 2000/06/16 00:57:04 simonb Exp $ */
+/* $NetBSD: kern_sysctl.c,v 1.73.2.1 2000/07/14 18:10:51 thorpej Exp $ */
/*-
* Copyright (c) 1982, 1986, 1989, 1993
@@ -68,7 +68,9 @@
#include <sys/tty.h>
#include <sys/unistd.h>
#include <sys/vnode.h>
+#define __SYSCTL_PRIVATE
#include <sys/sysctl.h>
+#include <sys/lock.h>
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
#include <sys/ipc.h>
@@ -89,15 +91,6 @@
#define PTRTOINT64(foo) ((u_int64_t)(uintptr_t)(foo))
-/*
- * Locking and stats
- */
-static struct sysctl_lock {
- int sl_lock;
- int sl_want;
- int sl_locked;
-} memlock;
-
static int sysctl_file __P((void *, size_t *));
#if defined(SYSVMSG) || defined(SYSVSEM) || defined(SYSVSHM)
static int sysctl_sysvipc __P((int *, u_int, void *, size_t *));
@@ -107,6 +100,21 @@
static void fill_kproc2 __P((struct proc *, struct kinfo_proc2 *));
static int sysctl_procargs __P((int *, u_int, void *, size_t *, struct proc *));
+/*
+ * The `sysctl_memlock' is intended to keep too many processes from
+ * locking down memory by doing sysctls at once. Whether or not this
+ * is really a good idea to worry about it probably a subject of some
+ * debate.
+ */
+struct lock sysctl_memlock;
+
+void
Home |
Main Index |
Thread Index |
Old Index