diff options
author | peter <peter@FreeBSD.org> | 1996-01-25 06:05:38 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1996-01-25 06:05:38 +0000 |
commit | eb3b1f018c6d6dbe6ccea320bcd6905335547ede (patch) | |
tree | abc32c3a526d96eddad04358e37b8b63565e21cb | |
parent | d553122c8948690a76d871ca2eb7390c2c247ed1 (diff) | |
download | FreeBSD-src-eb3b1f018c6d6dbe6ccea320bcd6905335547ede.zip FreeBSD-src-eb3b1f018c6d6dbe6ccea320bcd6905335547ede.tar.gz |
This time, really make the procfs work when reading stuff from the UPAGES.
This is a really ugly bandaid on the problem, but it works well enough for
'ps -u' to start working again. The problem was caused by the user
address space shrinking by a little bit and the UPAGES being "cast off" to
become a seperate entity rather than being at the top of the process's
vmspace. That optimization was part of John's most recent VM speedups.
Now, rather than decoding the VM space, it merely ensures the pages are
in core and accesses them the same way the ptrace(PT_READ_U..) code does,
ie: off the p->p_addr pointer.
-rw-r--r-- | sys/fs/procfs/procfs_mem.c | 49 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_mem.c | 49 |
2 files changed, 68 insertions, 30 deletions
diff --git a/sys/fs/procfs/procfs_mem.c b/sys/fs/procfs/procfs_mem.c index f772c4b..04b3a37 100644 --- a/sys/fs/procfs/procfs_mem.c +++ b/sys/fs/procfs/procfs_mem.c @@ -37,7 +37,7 @@ * * @(#)procfs_mem.c 8.4 (Berkeley) 1/21/94 * - * $Id: procfs_mem.c,v 1.15 1996/01/19 03:58:32 dyson Exp $ + * $Id: procfs_mem.c,v 1.16 1996/01/24 18:41:06 peter Exp $ */ /* @@ -96,20 +96,6 @@ procfs_rwmem(p, uio) int fix_prot; uva = (vm_offset_t) uio->uio_offset; - if (uva >= VM_MAXUSER_ADDRESS) { - - if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { - error = 0; - break; - } - /* we are reading the "U area", fill it in */ - PHOLD(p); - if (p->p_flag & P_INMEM) { - p->p_addr->u_kproc.kp_proc = *p; - fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); - } - PRELE(p); - } /* * Get the page number of this segment. @@ -122,6 +108,39 @@ procfs_rwmem(p, uio) */ len = min(PAGE_SIZE - page_offset, uio->uio_resid); + if (uva >= VM_MAXUSER_ADDRESS) { + if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { + error = 0; + break; + } + + /* we are reading the "U area", force it into core */ + PHOLD(p); + + /* sanity check */ + if (!(p->p_flag & P_INMEM)) { + /* aiee! */ + error = EFAULT; + break; + } + + /* populate the ptrace/procfs area */ + p->p_addr->u_kproc.kp_proc = *p; + fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); + + /* locate the in-core address */ + kva = (u_int)p->p_addr + uva - VM_MAXUSER_ADDRESS; + + /* transfer it */ + error = uiomove((caddr_t)kva, len, uio); + + /* let the pages go */ + PRELE(p); + + continue; + } + + /* * The map we want... */ diff --git a/sys/miscfs/procfs/procfs_mem.c b/sys/miscfs/procfs/procfs_mem.c index f772c4b..04b3a37 100644 --- a/sys/miscfs/procfs/procfs_mem.c +++ b/sys/miscfs/procfs/procfs_mem.c @@ -37,7 +37,7 @@ * * @(#)procfs_mem.c 8.4 (Berkeley) 1/21/94 * - * $Id: procfs_mem.c,v 1.15 1996/01/19 03:58:32 dyson Exp $ + * $Id: procfs_mem.c,v 1.16 1996/01/24 18:41:06 peter Exp $ */ /* @@ -96,20 +96,6 @@ procfs_rwmem(p, uio) int fix_prot; uva = (vm_offset_t) uio->uio_offset; - if (uva >= VM_MAXUSER_ADDRESS) { - - if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { - error = 0; - break; - } - /* we are reading the "U area", fill it in */ - PHOLD(p); - if (p->p_flag & P_INMEM) { - p->p_addr->u_kproc.kp_proc = *p; - fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); - } - PRELE(p); - } /* * Get the page number of this segment. @@ -122,6 +108,39 @@ procfs_rwmem(p, uio) */ len = min(PAGE_SIZE - page_offset, uio->uio_resid); + if (uva >= VM_MAXUSER_ADDRESS) { + if (writing || (uva >= (VM_MAXUSER_ADDRESS + UPAGES * PAGE_SIZE))) { + error = 0; + break; + } + + /* we are reading the "U area", force it into core */ + PHOLD(p); + + /* sanity check */ + if (!(p->p_flag & P_INMEM)) { + /* aiee! */ + error = EFAULT; + break; + } + + /* populate the ptrace/procfs area */ + p->p_addr->u_kproc.kp_proc = *p; + fill_eproc (p, &p->p_addr->u_kproc.kp_eproc); + + /* locate the in-core address */ + kva = (u_int)p->p_addr + uva - VM_MAXUSER_ADDRESS; + + /* transfer it */ + error = uiomove((caddr_t)kva, len, uio); + + /* let the pages go */ + PRELE(p); + + continue; + } + + /* * The map we want... */ |