2005-01-07 02:29:27 +00:00
|
|
|
/*-
|
1994-05-24 10:09:53 +00:00
|
|
|
* Copyright (c) 1988 University of Utah.
|
|
|
|
* Copyright (c) 1991, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the Systems Programming Group of the University of Utah Computer
|
|
|
|
* Science Department.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* from: Utah $Hdr: vm_mmap.c 1.6 91/10/21$
|
|
|
|
*
|
|
|
|
* @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Mapped file (mmap) interface to VM
|
|
|
|
*/
|
|
|
|
|
2003-06-11 23:50:51 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1997-12-16 17:40:42 +00:00
|
|
|
#include "opt_compat.h"
|
2002-10-22 15:56:44 +00:00
|
|
|
#include "opt_mac.h"
|
1996-12-22 23:17:09 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
2001-05-01 08:13:21 +00:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/lock.h>
|
2001-05-19 01:28:09 +00:00
|
|
|
#include <sys/mutex.h>
|
1995-11-12 06:43:28 +00:00
|
|
|
#include <sys/sysproto.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/filedesc.h>
|
|
|
|
#include <sys/proc.h>
|
2002-06-26 00:29:28 +00:00
|
|
|
#include <sys/resource.h>
|
|
|
|
#include <sys/resourcevar.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/vnode.h>
|
1997-03-23 03:37:54 +00:00
|
|
|
#include <sys/fcntl.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/file.h>
|
2002-10-22 15:56:44 +00:00
|
|
|
#include <sys/mac.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/mman.h>
|
2004-03-18 20:58:51 +00:00
|
|
|
#include <sys/mount.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <sys/conf.h>
|
1998-05-19 07:13:21 +00:00
|
|
|
#include <sys/stat.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <sys/vmmeter.h>
|
2000-02-16 21:11:33 +00:00
|
|
|
#include <sys/sysctl.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
#include <vm/vm.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_map.h>
|
|
|
|
#include <vm/vm_object.h>
|
1999-01-21 08:29:12 +00:00
|
|
|
#include <vm/vm_page.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
#include <vm/vm_pager.h>
|
1995-03-16 18:17:34 +00:00
|
|
|
#include <vm/vm_pageout.h>
|
1995-12-07 12:48:31 +00:00
|
|
|
#include <vm/vm_extern.h>
|
1996-05-19 07:36:50 +00:00
|
|
|
#include <vm/vm_page.h>
|
2000-02-16 21:11:33 +00:00
|
|
|
#include <vm/vm_kern.h>
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct sbrk_args {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int incr;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
2000-02-16 21:11:33 +00:00
|
|
|
static int max_proc_mmap;
|
|
|
|
SYSCTL_INT(_vm, OID_AUTO, max_proc_mmap, CTLFLAG_RW, &max_proc_mmap, 0, "");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the maximum number of vm_map_entry structures per process. Roughly
|
|
|
|
* speaking vm_map_entry structures are tiny, so allowing them to eat 1/100
|
2003-12-08 02:45:45 +00:00
|
|
|
* of our KVM malloc space still results in generous limits. We want a
|
2000-02-16 21:11:33 +00:00
|
|
|
* default that is good enough to prevent the kernel running out of resources
|
|
|
|
* if attacked from compromised user account but generous enough such that
|
|
|
|
* multi-threaded processes are not unduly inconvenienced.
|
|
|
|
*/
|
2002-03-19 22:20:14 +00:00
|
|
|
static void vmmapentry_rsrc_init(void *);
|
2000-02-16 21:11:33 +00:00
|
|
|
SYSINIT(vmmersrc, SI_SUB_KVM_RSRC, SI_ORDER_FIRST, vmmapentry_rsrc_init, NULL)
|
|
|
|
|
|
|
|
static void
|
|
|
|
vmmapentry_rsrc_init(dummy)
|
|
|
|
void *dummy;
|
|
|
|
{
|
|
|
|
max_proc_mmap = vm_kmem_size / sizeof(struct vm_map_entry);
|
|
|
|
max_proc_mmap /= 100;
|
|
|
|
}
|
|
|
|
|
2004-02-27 22:02:15 +00:00
|
|
|
static int vm_mmap_vnode(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *,
|
|
|
|
int *, struct vnode *, vm_ooffset_t, vm_object_t *);
|
2005-04-01 20:00:11 +00:00
|
|
|
static int vm_mmap_cdev(struct thread *, vm_size_t, vm_prot_t, vm_prot_t *,
|
|
|
|
int *, struct cdev *, vm_ooffset_t, vm_object_t *);
|
2004-02-27 22:02:15 +00:00
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
sbrk(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct sbrk_args *uap;
|
|
|
|
{
|
|
|
|
/* Not yet implemented */
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct sstk_args {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int incr;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
sstk(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct sstk_args *uap;
|
|
|
|
{
|
|
|
|
/* Not yet implemented */
|
|
|
|
return (EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
2004-06-11 11:16:26 +00:00
|
|
|
#if defined(COMPAT_43)
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct getpagesize_args {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int dummy;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
ogetpagesize(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct getpagesize_args *uap;
|
|
|
|
{
|
2001-07-04 16:20:28 +00:00
|
|
|
/* MP SAFE */
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] = PAGE_SIZE;
|
1994-05-24 10:09:53 +00:00
|
|
|
return (0);
|
|
|
|
}
|
2004-06-11 11:16:26 +00:00
|
|
|
#endif /* COMPAT_43 */
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-08-30 18:50:06 +00:00
|
|
|
|
2003-12-08 02:45:45 +00:00
|
|
|
/*
|
1997-08-30 18:50:06 +00:00
|
|
|
* Memory Map (mmap) system call. Note that the file offset
|
|
|
|
* and address are allowed to be NOT page aligned, though if
|
|
|
|
* the MAP_FIXED flag it set, both must have the same remainder
|
|
|
|
* modulo the PAGE_SIZE (POSIX 1003.1b). If the address is not
|
|
|
|
* page-aligned, the actual mapping starts at trunc_page(addr)
|
|
|
|
* and the return value is adjusted up by the page offset.
|
1999-09-21 05:00:48 +00:00
|
|
|
*
|
|
|
|
* Generally speaking, only character devices which are themselves
|
|
|
|
* memory-based, such as a video framebuffer, can be mmap'd. Otherwise
|
|
|
|
* there would be no cache coherency between a descriptor and a VM mapping
|
|
|
|
* both to the same character device.
|
|
|
|
*
|
|
|
|
* Block devices can be mmap'd no matter what they represent. Cache coherency
|
|
|
|
* is maintained as long as you do not write directly to the underlying
|
|
|
|
* character device.
|
1997-08-30 18:50:06 +00:00
|
|
|
*/
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mmap_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
void *addr;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
size_t len;
|
|
|
|
int prot;
|
|
|
|
int flags;
|
|
|
|
int fd;
|
|
|
|
long pad;
|
|
|
|
off_t pos;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
mmap(td, uap)
|
|
|
|
struct thread *td;
|
2001-07-04 19:00:13 +00:00
|
|
|
struct mmap_args *uap;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
2004-02-27 22:02:15 +00:00
|
|
|
struct file *fp;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct vnode *vp;
|
|
|
|
vm_offset_t addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
vm_size_t size, pageoff;
|
1994-05-24 10:09:53 +00:00
|
|
|
vm_prot_t prot, maxprot;
|
1997-12-31 02:35:29 +00:00
|
|
|
void *handle;
|
2005-04-01 20:00:11 +00:00
|
|
|
objtype_t handle_type;
|
1994-05-24 10:09:53 +00:00
|
|
|
int flags, error;
|
1997-08-30 18:50:06 +00:00
|
|
|
off_t pos;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct vmspace *vms = td->td_proc->p_vmspace;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1997-08-30 18:50:06 +00:00
|
|
|
addr = (vm_offset_t) uap->addr;
|
|
|
|
size = uap->len;
|
1994-05-24 10:09:53 +00:00
|
|
|
prot = uap->prot & VM_PROT_ALL;
|
|
|
|
flags = uap->flags;
|
1997-08-30 18:50:06 +00:00
|
|
|
pos = uap->pos;
|
|
|
|
|
2002-01-13 11:58:06 +00:00
|
|
|
fp = NULL;
|
1997-08-30 18:50:06 +00:00
|
|
|
/* make sure mapping fits into numeric range etc */
|
1998-12-09 20:22:21 +00:00
|
|
|
if ((ssize_t) uap->len < 0 ||
|
1997-08-30 18:50:06 +00:00
|
|
|
((flags & MAP_ANON) && uap->fd != -1))
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EINVAL);
|
1996-03-02 17:14:09 +00:00
|
|
|
|
1999-01-06 23:05:42 +00:00
|
|
|
if (flags & MAP_STACK) {
|
|
|
|
if ((uap->fd != -1) ||
|
|
|
|
((prot & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE)))
|
|
|
|
return (EINVAL);
|
|
|
|
flags |= MAP_ANON;
|
|
|
|
pos = 0;
|
1999-01-26 02:49:52 +00:00
|
|
|
}
|
|
|
|
|
1996-03-02 17:14:09 +00:00
|
|
|
/*
|
1997-08-30 18:50:06 +00:00
|
|
|
* Align the file position to a page boundary,
|
|
|
|
* and save its page offset component.
|
1996-03-02 17:14:09 +00:00
|
|
|
*/
|
1997-08-30 18:50:06 +00:00
|
|
|
pageoff = (pos & PAGE_MASK);
|
|
|
|
pos -= pageoff;
|
|
|
|
|
|
|
|
/* Adjust size for rounding (on both ends). */
|
|
|
|
size += pageoff; /* low end... */
|
|
|
|
size = (vm_size_t) round_page(size); /* hi end */
|
1996-03-02 17:14:09 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* Check for illegal addresses. Watch out for address wrap... Note
|
|
|
|
* that VM_*_ADDRESS are not constants due to casts (argh).
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
if (flags & MAP_FIXED) {
|
1997-08-30 18:50:06 +00:00
|
|
|
/*
|
|
|
|
* The specified address must have the same remainder
|
|
|
|
* as the file offset taken modulo PAGE_SIZE, so it
|
|
|
|
* should be aligned after adjustment by pageoff.
|
|
|
|
*/
|
|
|
|
addr -= pageoff;
|
|
|
|
if (addr & PAGE_MASK)
|
|
|
|
return (EINVAL);
|
|
|
|
/* Address range must be all in user VM space. */
|
2002-09-21 22:07:17 +00:00
|
|
|
if (addr < vm_map_min(&vms->vm_map) ||
|
|
|
|
addr + size > vm_map_max(&vms->vm_map))
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EINVAL);
|
1994-08-04 03:06:48 +00:00
|
|
|
if (addr + size < addr)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EINVAL);
|
2004-02-04 21:52:57 +00:00
|
|
|
} else {
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
1997-08-30 18:50:06 +00:00
|
|
|
* XXX for non-fixed mappings where no hint is provided or
|
|
|
|
* the hint would fall in the potential heap space,
|
|
|
|
* place it after the end of the largest possible heap.
|
1995-05-30 08:16:23 +00:00
|
|
|
*
|
1997-08-30 18:50:06 +00:00
|
|
|
* There should really be a pmap call to determine a reasonable
|
|
|
|
* location.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_LOCK(td->td_proc);
|
|
|
|
if (addr == 0 ||
|
|
|
|
(addr >= round_page((vm_offset_t)vms->vm_taddr) &&
|
|
|
|
addr < round_page((vm_offset_t)vms->vm_daddr +
|
|
|
|
lim_max(td->td_proc, RLIMIT_DATA))))
|
|
|
|
addr = round_page((vm_offset_t)vms->vm_daddr +
|
|
|
|
lim_max(td->td_proc, RLIMIT_DATA));
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
|
|
|
}
|
2004-03-01 02:44:33 +00:00
|
|
|
if (flags & MAP_ANON) {
|
|
|
|
/*
|
|
|
|
* Mapping blank space is trivial.
|
|
|
|
*/
|
|
|
|
handle = NULL;
|
2005-04-01 20:00:11 +00:00
|
|
|
handle_type = OBJT_DEFAULT;
|
2004-03-01 02:44:33 +00:00
|
|
|
maxprot = VM_PROT_ALL;
|
|
|
|
pos = 0;
|
|
|
|
} else {
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
* Mapping file, get fp for validation. Obtain vnode and make
|
|
|
|
* sure it is of appropriate type.
|
2002-01-13 11:58:06 +00:00
|
|
|
* don't let the descriptor disappear on us if we block
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2002-01-14 00:13:45 +00:00
|
|
|
if ((error = fget(td, uap->fd, &fp)) != 0)
|
2002-01-13 11:58:06 +00:00
|
|
|
goto done;
|
2001-05-23 22:17:43 +00:00
|
|
|
if (fp->f_type != DTYPE_VNODE) {
|
2001-08-31 01:26:30 +00:00
|
|
|
error = EINVAL;
|
2002-01-13 11:58:06 +00:00
|
|
|
goto done;
|
2001-05-23 22:17:43 +00:00
|
|
|
}
|
2000-04-22 15:22:31 +00:00
|
|
|
/*
|
|
|
|
* POSIX shared-memory objects are defined to have
|
|
|
|
* kernel persistence, and are not defined to support
|
|
|
|
* read(2)/write(2) -- or even open(2). Thus, we can
|
|
|
|
* use MAP_ASYNC to trade on-disk coherence for speed.
|
|
|
|
* The shm_open(3) library routine turns on the FPOSIXSHM
|
|
|
|
* flag to request this behavior.
|
|
|
|
*/
|
|
|
|
if (fp->f_flag & FPOSIXSHM)
|
|
|
|
flags |= MAP_NOSYNC;
|
2003-06-22 08:41:43 +00:00
|
|
|
vp = fp->f_vnode;
|
2003-06-21 08:27:06 +00:00
|
|
|
/*
|
|
|
|
* Ensure that file and memory protections are
|
|
|
|
* compatible. Note that we only worry about
|
|
|
|
* writability if mapping is shared; in this case,
|
|
|
|
* current and max prot are dictated by the open file.
|
|
|
|
* XXX use the vnode instead? Problem is: what
|
|
|
|
* credentials do we use for determination? What if
|
|
|
|
* proc does a setuid?
|
|
|
|
*/
|
2004-05-11 10:26:37 +00:00
|
|
|
if (vp->v_mount != NULL && vp->v_mount->mnt_flag & MNT_NOEXEC)
|
2004-03-18 20:58:51 +00:00
|
|
|
maxprot = VM_PROT_NONE;
|
|
|
|
else
|
|
|
|
maxprot = VM_PROT_EXECUTE;
|
2003-06-21 08:27:06 +00:00
|
|
|
if (fp->f_flag & FREAD) {
|
|
|
|
maxprot |= VM_PROT_READ;
|
|
|
|
} else if (prot & PROT_READ) {
|
|
|
|
error = EACCES;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If we are sharing potential changes (either via
|
|
|
|
* MAP_SHARED or via the implicit sharing of character
|
|
|
|
* device mappings), and we are trying to get write
|
|
|
|
* permission although we opened it without asking
|
2004-02-27 22:02:15 +00:00
|
|
|
* for it, bail out.
|
2003-06-21 08:27:06 +00:00
|
|
|
*/
|
2004-04-05 04:54:22 +00:00
|
|
|
if ((flags & MAP_SHARED) != 0) {
|
2003-06-21 08:27:06 +00:00
|
|
|
if ((fp->f_flag & FWRITE) != 0) {
|
2004-02-27 22:02:15 +00:00
|
|
|
maxprot |= VM_PROT_WRITE;
|
2003-06-21 08:27:06 +00:00
|
|
|
} else if ((prot & PROT_WRITE) != 0) {
|
|
|
|
error = EACCES;
|
|
|
|
goto done;
|
2000-11-18 21:01:04 +00:00
|
|
|
}
|
2004-04-05 04:54:22 +00:00
|
|
|
} else if (vp->v_type != VCHR || (fp->f_flag & FWRITE) != 0) {
|
2003-06-21 08:27:06 +00:00
|
|
|
maxprot |= VM_PROT_WRITE;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2003-06-21 08:27:06 +00:00
|
|
|
handle = (void *)vp;
|
2005-04-01 20:00:11 +00:00
|
|
|
handle_type = OBJT_VNODE;
|
2004-03-01 02:44:33 +00:00
|
|
|
}
|
2000-02-16 21:11:33 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Do not allow more then a certain number of vm_map_entry structures
|
|
|
|
* per process. Scale with the number of rforks sharing the map
|
|
|
|
* to make the limit reasonable for threads.
|
|
|
|
*/
|
2003-12-08 02:45:45 +00:00
|
|
|
if (max_proc_mmap &&
|
2000-02-16 21:11:33 +00:00
|
|
|
vms->vm_map.nentries >= max_proc_mmap * vms->vm_refcnt) {
|
2000-11-18 21:01:04 +00:00
|
|
|
error = ENOMEM;
|
|
|
|
goto done;
|
2000-02-16 21:11:33 +00:00
|
|
|
}
|
|
|
|
|
2004-02-27 22:02:15 +00:00
|
|
|
error = vm_mmap(&vms->vm_map, &addr, size, prot, maxprot,
|
2005-04-01 20:00:11 +00:00
|
|
|
flags, handle_type, handle, pos);
|
1994-05-24 10:09:53 +00:00
|
|
|
if (error == 0)
|
2001-09-12 08:38:13 +00:00
|
|
|
td->td_retval[0] = (register_t) (addr + pageoff);
|
2000-11-18 21:01:04 +00:00
|
|
|
done:
|
|
|
|
if (fp)
|
2001-09-12 08:38:13 +00:00
|
|
|
fdrop(fp, td);
|
2002-07-06 22:14:38 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
1994-10-09 01:52:19 +00:00
|
|
|
#ifdef COMPAT_43
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-10-09 01:52:19 +00:00
|
|
|
struct ommap_args {
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
caddr_t addr;
|
|
|
|
int len;
|
|
|
|
int prot;
|
|
|
|
int flags;
|
|
|
|
int fd;
|
|
|
|
long pos;
|
1994-10-09 01:52:19 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
1994-10-09 01:52:19 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
ommap(td, uap)
|
|
|
|
struct thread *td;
|
2001-07-04 19:00:13 +00:00
|
|
|
struct ommap_args *uap;
|
1994-10-09 01:52:19 +00:00
|
|
|
{
|
|
|
|
struct mmap_args nargs;
|
|
|
|
static const char cvtbsdprot[8] = {
|
|
|
|
0,
|
|
|
|
PROT_EXEC,
|
|
|
|
PROT_WRITE,
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
PROT_EXEC | PROT_WRITE,
|
1994-10-09 01:52:19 +00:00
|
|
|
PROT_READ,
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
PROT_EXEC | PROT_READ,
|
|
|
|
PROT_WRITE | PROT_READ,
|
|
|
|
PROT_EXEC | PROT_WRITE | PROT_READ,
|
1994-10-09 01:52:19 +00:00
|
|
|
};
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
1994-10-09 01:52:19 +00:00
|
|
|
#define OMAP_ANON 0x0002
|
|
|
|
#define OMAP_COPY 0x0020
|
|
|
|
#define OMAP_SHARED 0x0010
|
|
|
|
#define OMAP_FIXED 0x0100
|
|
|
|
|
|
|
|
nargs.addr = uap->addr;
|
|
|
|
nargs.len = uap->len;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
nargs.prot = cvtbsdprot[uap->prot & 0x7];
|
1994-10-09 01:52:19 +00:00
|
|
|
nargs.flags = 0;
|
|
|
|
if (uap->flags & OMAP_ANON)
|
|
|
|
nargs.flags |= MAP_ANON;
|
|
|
|
if (uap->flags & OMAP_COPY)
|
|
|
|
nargs.flags |= MAP_COPY;
|
|
|
|
if (uap->flags & OMAP_SHARED)
|
|
|
|
nargs.flags |= MAP_SHARED;
|
|
|
|
else
|
|
|
|
nargs.flags |= MAP_PRIVATE;
|
|
|
|
if (uap->flags & OMAP_FIXED)
|
|
|
|
nargs.flags |= MAP_FIXED;
|
|
|
|
nargs.fd = uap->fd;
|
|
|
|
nargs.pos = uap->pos;
|
2001-09-12 08:38:13 +00:00
|
|
|
return (mmap(td, &nargs));
|
1994-10-09 01:52:19 +00:00
|
|
|
}
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
#endif /* COMPAT_43 */
|
1994-10-09 01:52:19 +00:00
|
|
|
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct msync_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
void *addr;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int len;
|
1995-03-25 16:55:46 +00:00
|
|
|
int flags;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
msync(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct msync_args *uap;
|
|
|
|
{
|
|
|
|
vm_offset_t addr;
|
1996-02-23 18:49:25 +00:00
|
|
|
vm_size_t size, pageoff;
|
1995-03-25 16:55:46 +00:00
|
|
|
int flags;
|
1994-05-24 10:09:53 +00:00
|
|
|
vm_map_t map;
|
|
|
|
int rv;
|
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
addr = (vm_offset_t) uap->addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size = uap->len;
|
1995-03-25 16:55:46 +00:00
|
|
|
flags = uap->flags;
|
|
|
|
|
1996-02-23 18:49:25 +00:00
|
|
|
pageoff = (addr & PAGE_MASK);
|
|
|
|
addr -= pageoff;
|
|
|
|
size += pageoff;
|
|
|
|
size = (vm_size_t) round_page(size);
|
1996-03-02 17:14:09 +00:00
|
|
|
if (addr + size < addr)
|
2002-03-10 21:52:48 +00:00
|
|
|
return (EINVAL);
|
1996-02-23 18:49:25 +00:00
|
|
|
|
|
|
|
if ((flags & (MS_ASYNC|MS_INVALIDATE)) == (MS_ASYNC|MS_INVALIDATE))
|
1995-03-25 17:36:00 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
map = &td->td_proc->p_vmspace->vm_map;
|
1996-03-02 17:14:09 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Clean the pages and interpret the return value.
|
|
|
|
*/
|
2003-11-09 05:25:35 +00:00
|
|
|
rv = vm_map_sync(map, addr, addr + size, (flags & MS_ASYNC) == 0,
|
1995-03-25 16:55:46 +00:00
|
|
|
(flags & MS_INVALIDATE) != 0);
|
1994-05-24 10:09:53 +00:00
|
|
|
switch (rv) {
|
|
|
|
case KERN_SUCCESS:
|
2002-03-10 21:52:48 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
case KERN_INVALID_ADDRESS:
|
|
|
|
return (EINVAL); /* Sun returns ENOMEM? */
|
2003-11-14 06:55:11 +00:00
|
|
|
case KERN_INVALID_ARGUMENT:
|
|
|
|
return (EBUSY);
|
1994-05-24 10:09:53 +00:00
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct munmap_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
void *addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size_t len;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
munmap(td, uap)
|
|
|
|
struct thread *td;
|
2001-07-04 19:00:13 +00:00
|
|
|
struct munmap_args *uap;
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
vm_offset_t addr;
|
1996-02-23 18:49:25 +00:00
|
|
|
vm_size_t size, pageoff;
|
1994-05-24 10:09:53 +00:00
|
|
|
vm_map_t map;
|
|
|
|
|
|
|
|
addr = (vm_offset_t) uap->addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size = uap->len;
|
2003-11-10 01:37:40 +00:00
|
|
|
if (size == 0)
|
|
|
|
return (EINVAL);
|
1996-02-23 18:49:25 +00:00
|
|
|
|
|
|
|
pageoff = (addr & PAGE_MASK);
|
|
|
|
addr -= pageoff;
|
|
|
|
size += pageoff;
|
|
|
|
size = (vm_size_t) round_page(size);
|
1996-03-02 17:14:09 +00:00
|
|
|
if (addr + size < addr)
|
2002-03-10 21:52:48 +00:00
|
|
|
return (EINVAL);
|
1996-03-02 17:14:09 +00:00
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
2002-09-21 22:07:17 +00:00
|
|
|
* Check for illegal addresses. Watch out for address wrap...
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2001-09-12 08:38:13 +00:00
|
|
|
map = &td->td_proc->p_vmspace->vm_map;
|
2002-09-21 22:07:17 +00:00
|
|
|
if (addr < vm_map_min(map) || addr + size > vm_map_max(map))
|
|
|
|
return (EINVAL);
|
2003-11-10 01:37:40 +00:00
|
|
|
vm_map_lock(map);
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
|
|
|
* Make sure entire range is allocated.
|
|
|
|
*/
|
2003-11-10 01:37:40 +00:00
|
|
|
if (!vm_map_check_protection(map, addr, addr + size, VM_PROT_NONE)) {
|
|
|
|
vm_map_unlock(map);
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
return (EINVAL);
|
2003-11-10 01:37:40 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
/* returns nothing but KERN_SUCCESS anyway */
|
2003-11-10 01:37:40 +00:00
|
|
|
vm_map_delete(map, addr, addr + size);
|
|
|
|
vm_map_unlock(map);
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mprotect_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
const void *addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size_t len;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int prot;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
mprotect(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mprotect_args *uap;
|
|
|
|
{
|
|
|
|
vm_offset_t addr;
|
1996-02-23 18:49:25 +00:00
|
|
|
vm_size_t size, pageoff;
|
2001-07-04 19:00:13 +00:00
|
|
|
vm_prot_t prot;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
addr = (vm_offset_t) uap->addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size = uap->len;
|
1994-05-24 10:09:53 +00:00
|
|
|
prot = uap->prot & VM_PROT_ALL;
|
1996-12-30 05:31:21 +00:00
|
|
|
#if defined(VM_PROT_READ_IS_EXEC)
|
|
|
|
if (prot & VM_PROT_READ)
|
|
|
|
prot |= VM_PROT_EXECUTE;
|
|
|
|
#endif
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1996-02-23 18:49:25 +00:00
|
|
|
pageoff = (addr & PAGE_MASK);
|
|
|
|
addr -= pageoff;
|
|
|
|
size += pageoff;
|
|
|
|
size = (vm_size_t) round_page(size);
|
1996-03-02 17:14:09 +00:00
|
|
|
if (addr + size < addr)
|
2002-03-10 21:52:48 +00:00
|
|
|
return (EINVAL);
|
1996-02-23 18:49:25 +00:00
|
|
|
|
2002-05-18 03:58:16 +00:00
|
|
|
switch (vm_map_protect(&td->td_proc->p_vmspace->vm_map, addr,
|
|
|
|
addr + size, prot, FALSE)) {
|
1994-05-24 10:09:53 +00:00
|
|
|
case KERN_SUCCESS:
|
|
|
|
return (0);
|
|
|
|
case KERN_PROTECTION_FAILURE:
|
|
|
|
return (EACCES);
|
|
|
|
}
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
1996-02-23 18:49:25 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
|
|
|
struct minherit_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
void *addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size_t len;
|
1996-02-23 18:49:25 +00:00
|
|
|
int inherit;
|
|
|
|
};
|
|
|
|
#endif
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1996-02-23 18:49:25 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
minherit(td, uap)
|
|
|
|
struct thread *td;
|
1996-02-23 18:49:25 +00:00
|
|
|
struct minherit_args *uap;
|
|
|
|
{
|
|
|
|
vm_offset_t addr;
|
|
|
|
vm_size_t size, pageoff;
|
2001-07-04 19:00:13 +00:00
|
|
|
vm_inherit_t inherit;
|
1996-02-23 18:49:25 +00:00
|
|
|
|
|
|
|
addr = (vm_offset_t)uap->addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size = uap->len;
|
1996-02-23 18:49:25 +00:00
|
|
|
inherit = uap->inherit;
|
|
|
|
|
|
|
|
pageoff = (addr & PAGE_MASK);
|
|
|
|
addr -= pageoff;
|
|
|
|
size += pageoff;
|
|
|
|
size = (vm_size_t) round_page(size);
|
1996-03-02 17:14:09 +00:00
|
|
|
if (addr + size < addr)
|
2002-03-10 21:52:48 +00:00
|
|
|
return (EINVAL);
|
1996-02-23 18:49:25 +00:00
|
|
|
|
2002-05-18 18:59:00 +00:00
|
|
|
switch (vm_map_inherit(&td->td_proc->p_vmspace->vm_map, addr,
|
|
|
|
addr + size, inherit)) {
|
1996-02-23 18:49:25 +00:00
|
|
|
case KERN_SUCCESS:
|
|
|
|
return (0);
|
|
|
|
case KERN_PROTECTION_FAILURE:
|
|
|
|
return (EACCES);
|
|
|
|
}
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct madvise_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
void *addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size_t len;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
int behav;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
madvise(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct madvise_args *uap;
|
|
|
|
{
|
1996-05-31 00:38:04 +00:00
|
|
|
vm_offset_t start, end;
|
2002-09-21 22:07:17 +00:00
|
|
|
vm_map_t map;
|
2003-03-31 21:09:57 +00:00
|
|
|
struct proc *p;
|
|
|
|
int error;
|
1999-09-21 05:00:48 +00:00
|
|
|
|
2003-03-31 21:09:57 +00:00
|
|
|
/*
|
|
|
|
* Check for our special case, advising the swap pager we are
|
|
|
|
* "immortal."
|
|
|
|
*/
|
|
|
|
if (uap->behav == MADV_PROTECT) {
|
|
|
|
error = suser(td);
|
2003-04-17 22:38:27 +00:00
|
|
|
if (error == 0) {
|
|
|
|
p = td->td_proc;
|
|
|
|
PROC_LOCK(p);
|
2003-03-31 21:09:57 +00:00
|
|
|
p->p_flag |= P_PROTECTED;
|
2003-04-17 22:38:27 +00:00
|
|
|
PROC_UNLOCK(p);
|
|
|
|
}
|
2003-03-31 21:09:57 +00:00
|
|
|
return (error);
|
|
|
|
}
|
1999-09-21 05:00:48 +00:00
|
|
|
/*
|
|
|
|
* Check for illegal behavior
|
|
|
|
*/
|
2000-02-28 04:10:35 +00:00
|
|
|
if (uap->behav < 0 || uap->behav > MADV_CORE)
|
1999-09-21 05:00:48 +00:00
|
|
|
return (EINVAL);
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* Check for illegal addresses. Watch out for address wrap... Note
|
|
|
|
* that VM_*_ADDRESS are not constants due to casts (argh).
|
|
|
|
*/
|
2002-09-21 22:07:17 +00:00
|
|
|
map = &td->td_proc->p_vmspace->vm_map;
|
|
|
|
if ((vm_offset_t)uap->addr < vm_map_min(map) ||
|
|
|
|
(vm_offset_t)uap->addr + uap->len > vm_map_max(map))
|
1996-05-19 07:36:50 +00:00
|
|
|
return (EINVAL);
|
|
|
|
if (((vm_offset_t) uap->addr + uap->len) < (vm_offset_t) uap->addr)
|
|
|
|
return (EINVAL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Since this routine is only advisory, we default to conservative
|
|
|
|
* behavior.
|
|
|
|
*/
|
1996-09-19 10:12:41 +00:00
|
|
|
start = trunc_page((vm_offset_t) uap->addr);
|
|
|
|
end = round_page((vm_offset_t) uap->addr + uap->len);
|
2003-12-08 02:45:45 +00:00
|
|
|
|
2002-09-21 22:07:17 +00:00
|
|
|
if (vm_map_madvise(map, start, end, uap->behav))
|
2002-05-18 07:48:06 +00:00
|
|
|
return (EINVAL);
|
|
|
|
return (0);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mincore_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
const void *addr;
|
1996-03-02 17:14:09 +00:00
|
|
|
size_t len;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
char *vec;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
/* ARGSUSED */
|
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
mincore(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mincore_args *uap;
|
|
|
|
{
|
1996-05-19 07:36:50 +00:00
|
|
|
vm_offset_t addr, first_addr;
|
|
|
|
vm_offset_t end, cend;
|
|
|
|
pmap_t pmap;
|
|
|
|
vm_map_t map;
|
1995-10-21 17:42:28 +00:00
|
|
|
char *vec;
|
2001-08-31 01:26:30 +00:00
|
|
|
int error = 0;
|
1996-05-19 07:36:50 +00:00
|
|
|
int vecindex, lastvecindex;
|
2001-07-04 19:00:13 +00:00
|
|
|
vm_map_entry_t current;
|
1996-05-19 07:36:50 +00:00
|
|
|
vm_map_entry_t entry;
|
|
|
|
int mincoreinfo;
|
1999-03-02 22:55:02 +00:00
|
|
|
unsigned int timestamp;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* Make sure that the addresses presented are valid for user
|
|
|
|
* mode.
|
|
|
|
*/
|
|
|
|
first_addr = addr = trunc_page((vm_offset_t) uap->addr);
|
1996-03-02 17:14:09 +00:00
|
|
|
end = addr + (vm_size_t)round_page(uap->len);
|
2002-09-21 22:07:17 +00:00
|
|
|
map = &td->td_proc->p_vmspace->vm_map;
|
|
|
|
if (end > vm_map_max(map) || end < addr)
|
1995-10-21 17:42:28 +00:00
|
|
|
return (EINVAL);
|
|
|
|
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* Address of byte vector
|
|
|
|
*/
|
1995-10-21 17:42:28 +00:00
|
|
|
vec = uap->vec;
|
1996-05-19 07:36:50 +00:00
|
|
|
|
2001-09-12 08:38:13 +00:00
|
|
|
pmap = vmspace_pmap(td->td_proc->p_vmspace);
|
1996-05-19 07:36:50 +00:00
|
|
|
|
1999-03-01 20:42:16 +00:00
|
|
|
vm_map_lock_read(map);
|
1999-03-02 22:55:02 +00:00
|
|
|
RestartScan:
|
|
|
|
timestamp = map->timestamp;
|
1996-05-19 07:36:50 +00:00
|
|
|
|
|
|
|
if (!vm_map_lookup_entry(map, addr, &entry))
|
|
|
|
entry = entry->next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do this on a map entry basis so that if the pages are not
|
|
|
|
* in the current processes address space, we can easily look
|
|
|
|
* up the pages elsewhere.
|
|
|
|
*/
|
|
|
|
lastvecindex = -1;
|
2001-07-04 19:00:13 +00:00
|
|
|
for (current = entry;
|
|
|
|
(current != &map->header) && (current->start < end);
|
|
|
|
current = current->next) {
|
1996-05-19 07:36:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* ignore submaps (for now) or null objects
|
|
|
|
*/
|
1999-02-07 21:48:23 +00:00
|
|
|
if ((current->eflags & MAP_ENTRY_IS_SUB_MAP) ||
|
1996-05-19 07:36:50 +00:00
|
|
|
current->object.vm_object == NULL)
|
|
|
|
continue;
|
2003-12-08 02:45:45 +00:00
|
|
|
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* limit this scan to the current map entry and the
|
|
|
|
* limits for the mincore call
|
|
|
|
*/
|
|
|
|
if (addr < current->start)
|
|
|
|
addr = current->start;
|
|
|
|
cend = current->end;
|
|
|
|
if (cend > end)
|
|
|
|
cend = end;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* scan this entry one page at a time
|
|
|
|
*/
|
2001-07-04 19:00:13 +00:00
|
|
|
while (addr < cend) {
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* Check pmap first, it is likely faster, also
|
|
|
|
* it can provide info as to whether we are the
|
|
|
|
* one referencing or modifying the page.
|
|
|
|
*/
|
|
|
|
mincoreinfo = pmap_mincore(pmap, addr);
|
|
|
|
if (!mincoreinfo) {
|
|
|
|
vm_pindex_t pindex;
|
|
|
|
vm_ooffset_t offset;
|
|
|
|
vm_page_t m;
|
|
|
|
/*
|
|
|
|
* calculate the page index into the object
|
|
|
|
*/
|
|
|
|
offset = current->offset + (addr - current->start);
|
|
|
|
pindex = OFF_TO_IDX(offset);
|
2003-06-09 07:01:05 +00:00
|
|
|
VM_OBJECT_LOCK(current->object.vm_object);
|
1996-05-19 07:36:50 +00:00
|
|
|
m = vm_page_lookup(current->object.vm_object,
|
|
|
|
pindex);
|
|
|
|
/*
|
|
|
|
* if the page is resident, then gather information about
|
|
|
|
* it.
|
|
|
|
*/
|
2003-12-21 06:03:40 +00:00
|
|
|
if (m != NULL && m->valid != 0) {
|
1996-05-19 07:36:50 +00:00
|
|
|
mincoreinfo = MINCORE_INCORE;
|
2003-09-07 18:47:54 +00:00
|
|
|
vm_page_lock_queues();
|
1996-05-19 07:36:50 +00:00
|
|
|
if (m->dirty ||
|
2000-05-21 12:50:18 +00:00
|
|
|
pmap_is_modified(m))
|
1996-05-19 07:36:50 +00:00
|
|
|
mincoreinfo |= MINCORE_MODIFIED_OTHER;
|
|
|
|
if ((m->flags & PG_REFERENCED) ||
|
2000-05-21 12:50:18 +00:00
|
|
|
pmap_ts_referenced(m)) {
|
1998-09-04 08:06:57 +00:00
|
|
|
vm_page_flag_set(m, PG_REFERENCED);
|
1996-05-19 07:36:50 +00:00
|
|
|
mincoreinfo |= MINCORE_REFERENCED_OTHER;
|
1997-01-11 07:19:02 +00:00
|
|
|
}
|
2003-09-07 18:47:54 +00:00
|
|
|
vm_page_unlock_queues();
|
1996-05-19 07:36:50 +00:00
|
|
|
}
|
2003-09-07 18:47:54 +00:00
|
|
|
VM_OBJECT_UNLOCK(current->object.vm_object);
|
1996-05-19 07:36:50 +00:00
|
|
|
}
|
|
|
|
|
1999-03-02 22:55:02 +00:00
|
|
|
/*
|
|
|
|
* subyte may page fault. In case it needs to modify
|
|
|
|
* the map, we release the lock.
|
|
|
|
*/
|
|
|
|
vm_map_unlock_read(map);
|
|
|
|
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* calculate index into user supplied byte vector
|
|
|
|
*/
|
|
|
|
vecindex = OFF_TO_IDX(addr - first_addr);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we have skipped map entries, we need to make sure that
|
|
|
|
* the byte vector is zeroed for those skipped entries.
|
|
|
|
*/
|
2001-07-04 19:00:13 +00:00
|
|
|
while ((lastvecindex + 1) < vecindex) {
|
2002-03-10 21:52:48 +00:00
|
|
|
error = subyte(vec + lastvecindex, 0);
|
1996-05-19 07:36:50 +00:00
|
|
|
if (error) {
|
2001-08-31 01:26:30 +00:00
|
|
|
error = EFAULT;
|
|
|
|
goto done2;
|
1996-05-19 07:36:50 +00:00
|
|
|
}
|
|
|
|
++lastvecindex;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Pass the page information to the user
|
|
|
|
*/
|
2002-03-10 21:52:48 +00:00
|
|
|
error = subyte(vec + vecindex, mincoreinfo);
|
1996-05-19 07:36:50 +00:00
|
|
|
if (error) {
|
2001-08-31 01:26:30 +00:00
|
|
|
error = EFAULT;
|
|
|
|
goto done2;
|
1996-05-19 07:36:50 +00:00
|
|
|
}
|
1999-03-02 22:55:02 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the map has changed, due to the subyte, the previous
|
|
|
|
* output may be invalid.
|
|
|
|
*/
|
|
|
|
vm_map_lock_read(map);
|
|
|
|
if (timestamp != map->timestamp)
|
|
|
|
goto RestartScan;
|
|
|
|
|
1996-05-19 07:36:50 +00:00
|
|
|
lastvecindex = vecindex;
|
|
|
|
addr += PAGE_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-03-02 22:55:02 +00:00
|
|
|
/*
|
|
|
|
* subyte may page fault. In case it needs to modify
|
|
|
|
* the map, we release the lock.
|
|
|
|
*/
|
|
|
|
vm_map_unlock_read(map);
|
|
|
|
|
1996-05-19 07:36:50 +00:00
|
|
|
/*
|
|
|
|
* Zero the last entries in the byte vector.
|
|
|
|
*/
|
|
|
|
vecindex = OFF_TO_IDX(end - first_addr);
|
2001-07-04 19:00:13 +00:00
|
|
|
while ((lastvecindex + 1) < vecindex) {
|
2002-03-10 21:52:48 +00:00
|
|
|
error = subyte(vec + lastvecindex, 0);
|
1996-05-19 07:36:50 +00:00
|
|
|
if (error) {
|
2001-08-31 01:26:30 +00:00
|
|
|
error = EFAULT;
|
|
|
|
goto done2;
|
1995-10-21 17:42:28 +00:00
|
|
|
}
|
1996-05-19 07:36:50 +00:00
|
|
|
++lastvecindex;
|
1995-10-21 17:42:28 +00:00
|
|
|
}
|
2003-12-08 02:45:45 +00:00
|
|
|
|
1999-03-02 22:55:02 +00:00
|
|
|
/*
|
|
|
|
* If the map has changed, due to the subyte, the previous
|
|
|
|
* output may be invalid.
|
|
|
|
*/
|
|
|
|
vm_map_lock_read(map);
|
|
|
|
if (timestamp != map->timestamp)
|
|
|
|
goto RestartScan;
|
1999-03-01 20:42:16 +00:00
|
|
|
vm_map_unlock_read(map);
|
2001-08-31 01:26:30 +00:00
|
|
|
done2:
|
|
|
|
return (error);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mlock_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
const void *addr;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
size_t len;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
mlock(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct mlock_args *uap;
|
|
|
|
{
|
2004-03-15 06:43:51 +00:00
|
|
|
struct proc *proc;
|
2004-03-15 09:11:23 +00:00
|
|
|
vm_offset_t addr, end, last, start;
|
|
|
|
vm_size_t npages, size;
|
|
|
|
int error;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2004-02-26 00:27:04 +00:00
|
|
|
error = suser(td);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2004-03-05 22:03:11 +00:00
|
|
|
addr = (vm_offset_t)uap->addr;
|
|
|
|
size = uap->len;
|
2004-03-15 09:11:23 +00:00
|
|
|
last = addr + size;
|
2004-03-05 22:03:11 +00:00
|
|
|
start = trunc_page(addr);
|
2004-03-15 09:11:23 +00:00
|
|
|
end = round_page(last);
|
|
|
|
if (last < addr || end < addr)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EINVAL);
|
2004-03-05 22:03:11 +00:00
|
|
|
npages = atop(end - start);
|
|
|
|
if (npages > vm_page_max_wired)
|
|
|
|
return (ENOMEM);
|
2004-03-15 06:43:51 +00:00
|
|
|
proc = td->td_proc;
|
2004-02-26 00:27:04 +00:00
|
|
|
PROC_LOCK(proc);
|
2004-03-15 09:11:23 +00:00
|
|
|
if (ptoa(npages +
|
|
|
|
pmap_wired_count(vm_map_pmap(&proc->p_vmspace->vm_map))) >
|
|
|
|
lim_cur(proc, RLIMIT_MEMLOCK)) {
|
2004-02-26 00:27:04 +00:00
|
|
|
PROC_UNLOCK(proc);
|
1997-06-15 23:35:32 +00:00
|
|
|
return (ENOMEM);
|
2004-02-04 21:52:57 +00:00
|
|
|
}
|
2004-02-26 00:27:04 +00:00
|
|
|
PROC_UNLOCK(proc);
|
2004-03-05 22:03:11 +00:00
|
|
|
if (npages + cnt.v_wire_count > vm_page_max_wired)
|
|
|
|
return (EAGAIN);
|
|
|
|
error = vm_map_wire(&proc->p_vmspace->vm_map, start, end,
|
2004-03-15 06:43:51 +00:00
|
|
|
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error == KERN_SUCCESS ? 0 : ENOMEM);
|
|
|
|
}
|
|
|
|
|
1997-06-15 23:35:32 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
|
|
|
struct mlockall_args {
|
|
|
|
int how;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1997-06-15 23:35:32 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
mlockall(td, uap)
|
|
|
|
struct thread *td;
|
1997-06-15 23:35:32 +00:00
|
|
|
struct mlockall_args *uap;
|
|
|
|
{
|
2003-08-11 07:14:08 +00:00
|
|
|
vm_map_t map;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
map = &td->td_proc->p_vmspace->vm_map;
|
|
|
|
error = 0;
|
|
|
|
|
|
|
|
if ((uap->how == 0) || ((uap->how & ~(MCL_CURRENT|MCL_FUTURE)) != 0))
|
|
|
|
return (EINVAL);
|
|
|
|
|
2003-10-06 01:59:04 +00:00
|
|
|
#if 0
|
2003-08-11 07:14:08 +00:00
|
|
|
/*
|
|
|
|
* If wiring all pages in the process would cause it to exceed
|
|
|
|
* a hard resource limit, return ENOMEM.
|
|
|
|
*/
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_LOCK(td->td_proc);
|
2003-08-11 07:14:08 +00:00
|
|
|
if (map->size - ptoa(pmap_wired_count(vm_map_pmap(map)) >
|
2004-02-04 21:52:57 +00:00
|
|
|
lim_cur(td->td_proc, RLIMIT_MEMLOCK))) {
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
2003-08-11 07:14:08 +00:00
|
|
|
return (ENOMEM);
|
2004-02-04 21:52:57 +00:00
|
|
|
}
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
2003-08-11 07:14:08 +00:00
|
|
|
#else
|
|
|
|
error = suser(td);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (uap->how & MCL_FUTURE) {
|
|
|
|
vm_map_lock(map);
|
|
|
|
vm_map_modflags(map, MAP_WIREFUTURE, 0);
|
|
|
|
vm_map_unlock(map);
|
|
|
|
error = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (uap->how & MCL_CURRENT) {
|
|
|
|
/*
|
|
|
|
* P1003.1-2001 mandates that all currently mapped pages
|
|
|
|
* will be memory resident and locked (wired) upon return
|
|
|
|
* from mlockall(). vm_map_wire() will wire pages, by
|
|
|
|
* calling vm_fault_wire() for each page in the region.
|
|
|
|
*/
|
|
|
|
error = vm_map_wire(map, vm_map_min(map), vm_map_max(map),
|
|
|
|
VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK);
|
|
|
|
error = (error == KERN_SUCCESS ? 0 : EAGAIN);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (error);
|
1997-06-15 23:35:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
2002-06-06 18:51:14 +00:00
|
|
|
struct munlockall_args {
|
2003-08-11 07:14:08 +00:00
|
|
|
register_t dummy;
|
1997-06-15 23:35:32 +00:00
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1997-06-15 23:35:32 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
munlockall(td, uap)
|
|
|
|
struct thread *td;
|
1997-06-15 23:35:32 +00:00
|
|
|
struct munlockall_args *uap;
|
|
|
|
{
|
2003-08-11 07:14:08 +00:00
|
|
|
vm_map_t map;
|
|
|
|
int error;
|
|
|
|
|
|
|
|
map = &td->td_proc->p_vmspace->vm_map;
|
|
|
|
error = suser(td);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
/* Clear the MAP_WIREFUTURE flag from this vm_map. */
|
|
|
|
vm_map_lock(map);
|
|
|
|
vm_map_modflags(map, 0, MAP_WIREFUTURE);
|
|
|
|
vm_map_unlock(map);
|
|
|
|
|
|
|
|
/* Forcibly unwire all pages. */
|
|
|
|
error = vm_map_unwire(map, vm_map_min(map), vm_map_max(map),
|
|
|
|
VM_MAP_WIRE_USER|VM_MAP_WIRE_HOLESOK);
|
|
|
|
|
|
|
|
return (error);
|
1997-06-15 23:35:32 +00:00
|
|
|
}
|
|
|
|
|
1995-11-12 06:43:28 +00:00
|
|
|
#ifndef _SYS_SYSPROTO_H_
|
1994-05-24 10:09:53 +00:00
|
|
|
struct munlock_args {
|
1997-12-31 02:35:29 +00:00
|
|
|
const void *addr;
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
size_t len;
|
1994-05-24 10:09:53 +00:00
|
|
|
};
|
1995-11-12 06:43:28 +00:00
|
|
|
#endif
|
2001-08-31 01:26:30 +00:00
|
|
|
/*
|
|
|
|
* MPSAFE
|
|
|
|
*/
|
1994-05-24 10:09:53 +00:00
|
|
|
int
|
2001-09-12 08:38:13 +00:00
|
|
|
munlock(td, uap)
|
|
|
|
struct thread *td;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct munlock_args *uap;
|
|
|
|
{
|
2004-03-15 09:11:23 +00:00
|
|
|
vm_offset_t addr, end, last, start;
|
2004-03-05 22:03:11 +00:00
|
|
|
vm_size_t size;
|
1994-05-24 10:09:53 +00:00
|
|
|
int error;
|
|
|
|
|
2004-02-26 00:27:04 +00:00
|
|
|
error = suser(td);
|
|
|
|
if (error)
|
|
|
|
return (error);
|
2004-03-05 22:03:11 +00:00
|
|
|
addr = (vm_offset_t)uap->addr;
|
|
|
|
size = uap->len;
|
2004-03-15 09:11:23 +00:00
|
|
|
last = addr + size;
|
2004-03-05 22:03:11 +00:00
|
|
|
start = trunc_page(addr);
|
2004-03-15 09:11:23 +00:00
|
|
|
end = round_page(last);
|
|
|
|
if (last < addr || end < addr)
|
1994-05-24 10:09:53 +00:00
|
|
|
return (EINVAL);
|
2004-03-05 22:03:11 +00:00
|
|
|
error = vm_map_unwire(&td->td_proc->p_vmspace->vm_map, start, end,
|
2004-03-15 06:43:51 +00:00
|
|
|
VM_MAP_WIRE_USER | VM_MAP_WIRE_NOHOLES);
|
1994-05-24 10:09:53 +00:00
|
|
|
return (error == KERN_SUCCESS ? 0 : ENOMEM);
|
|
|
|
}
|
|
|
|
|
2004-02-27 22:02:15 +00:00
|
|
|
/*
|
|
|
|
* vm_mmap_vnode()
|
|
|
|
*
|
|
|
|
* MPSAFE
|
|
|
|
*
|
|
|
|
* Helper function for vm_mmap. Perform sanity check specific for mmap
|
|
|
|
* operations on vnodes.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vm_mmap_vnode(struct thread *td, vm_size_t objsize,
|
|
|
|
vm_prot_t prot, vm_prot_t *maxprotp, int *flagsp,
|
|
|
|
struct vnode *vp, vm_ooffset_t foff, vm_object_t *objp)
|
|
|
|
{
|
|
|
|
struct vattr va;
|
|
|
|
void *handle;
|
|
|
|
vm_object_t obj;
|
2005-01-24 10:48:29 +00:00
|
|
|
struct mount *mp;
|
2004-08-05 07:04:33 +00:00
|
|
|
int error, flags, type;
|
2005-01-24 10:48:29 +00:00
|
|
|
int vfslocked;
|
2004-02-27 22:02:15 +00:00
|
|
|
|
2005-01-24 10:48:29 +00:00
|
|
|
mp = vp->v_mount;
|
|
|
|
vfslocked = VFS_LOCK_GIANT(mp);
|
2004-02-27 22:02:15 +00:00
|
|
|
if ((error = vget(vp, LK_EXCLUSIVE, td)) != 0) {
|
2005-01-24 10:48:29 +00:00
|
|
|
VFS_UNLOCK_GIANT(vfslocked);
|
2004-02-27 22:02:15 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
flags = *flagsp;
|
2005-01-25 00:40:01 +00:00
|
|
|
obj = vp->v_object;
|
2004-02-27 22:02:15 +00:00
|
|
|
if (vp->v_type == VREG) {
|
|
|
|
/*
|
|
|
|
* Get the proper underlying object
|
|
|
|
*/
|
2005-01-25 00:40:01 +00:00
|
|
|
if (obj == NULL) {
|
2004-02-27 22:02:15 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if (obj->handle != vp) {
|
|
|
|
vput(vp);
|
|
|
|
vp = (struct vnode*)obj->handle;
|
|
|
|
vget(vp, LK_EXCLUSIVE, td);
|
|
|
|
}
|
|
|
|
type = OBJT_VNODE;
|
|
|
|
handle = vp;
|
|
|
|
} else if (vp->v_type == VCHR) {
|
|
|
|
type = OBJT_DEVICE;
|
|
|
|
handle = vp->v_rdev;
|
|
|
|
|
2004-09-24 08:32:36 +00:00
|
|
|
/* XXX: lack thredref on device */
|
2004-02-27 22:02:15 +00:00
|
|
|
if(vp->v_rdev->si_devsw->d_flags & D_MMAP_ANON) {
|
|
|
|
*maxprotp = VM_PROT_ALL;
|
|
|
|
*flagsp |= MAP_ANON;
|
|
|
|
error = 0;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* cdevs does not provide private mappings of any kind.
|
|
|
|
*/
|
2004-04-05 04:54:22 +00:00
|
|
|
if ((*maxprotp & VM_PROT_WRITE) == 0 &&
|
|
|
|
(prot & PROT_WRITE) != 0) {
|
|
|
|
error = EACCES;
|
|
|
|
goto done;
|
|
|
|
}
|
2004-08-05 07:04:33 +00:00
|
|
|
if (flags & (MAP_PRIVATE|MAP_COPY)) {
|
2004-02-27 22:02:15 +00:00
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Force device mappings to be shared.
|
|
|
|
*/
|
|
|
|
flags |= MAP_SHARED;
|
|
|
|
} else {
|
|
|
|
error = EINVAL;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
if ((error = VOP_GETATTR(vp, &va, td->td_ucred, td))) {
|
|
|
|
goto done;
|
|
|
|
}
|
2005-04-14 16:03:30 +00:00
|
|
|
#ifdef MAC
|
|
|
|
error = mac_check_vnode_mmap(td->td_ucred, vp, prot, flags);
|
|
|
|
if (error != 0)
|
|
|
|
goto done;
|
|
|
|
#endif
|
2004-02-27 22:02:15 +00:00
|
|
|
if ((flags & MAP_SHARED) != 0) {
|
|
|
|
if ((va.va_flags & (SF_SNAPSHOT|IMMUTABLE|APPEND)) != 0) {
|
|
|
|
if (prot & PROT_WRITE) {
|
|
|
|
error = EPERM;
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
*maxprotp &= ~VM_PROT_WRITE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* If it is a regular file without any references
|
|
|
|
* we do not need to sync it.
|
|
|
|
* Adjust object size to be the size of actual file.
|
|
|
|
*/
|
|
|
|
if (vp->v_type == VREG) {
|
|
|
|
objsize = round_page(va.va_size);
|
|
|
|
if (va.va_nlink == 0)
|
|
|
|
flags |= MAP_NOSYNC;
|
|
|
|
}
|
|
|
|
obj = vm_pager_allocate(type, handle, objsize, prot, foff);
|
|
|
|
if (obj == NULL) {
|
|
|
|
error = (type == OBJT_DEVICE ? EINVAL : ENOMEM);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
*objp = obj;
|
|
|
|
*flagsp = flags;
|
|
|
|
done:
|
|
|
|
vput(vp);
|
2005-01-24 10:48:29 +00:00
|
|
|
VFS_UNLOCK_GIANT(vfslocked);
|
2004-02-27 22:02:15 +00:00
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
2005-04-01 20:00:11 +00:00
|
|
|
/*
|
|
|
|
* vm_mmap_cdev()
|
|
|
|
*
|
|
|
|
* MPSAFE
|
|
|
|
*
|
|
|
|
* Helper function for vm_mmap. Perform sanity check specific for mmap
|
|
|
|
* operations on cdevs.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
vm_mmap_cdev(struct thread *td, vm_size_t objsize,
|
|
|
|
vm_prot_t prot, vm_prot_t *maxprotp, int *flagsp,
|
|
|
|
struct cdev *cdev, vm_ooffset_t foff, vm_object_t *objp)
|
|
|
|
{
|
|
|
|
vm_object_t obj;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
flags = *flagsp;
|
|
|
|
|
|
|
|
/* XXX: lack thredref on device */
|
|
|
|
if (cdev->si_devsw->d_flags & D_MMAP_ANON) {
|
|
|
|
*maxprotp = VM_PROT_ALL;
|
|
|
|
*flagsp |= MAP_ANON;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* cdevs does not provide private mappings of any kind.
|
|
|
|
*/
|
|
|
|
if ((*maxprotp & VM_PROT_WRITE) == 0 &&
|
|
|
|
(prot & PROT_WRITE) != 0)
|
|
|
|
return (EACCES);
|
|
|
|
if (flags & (MAP_PRIVATE|MAP_COPY))
|
|
|
|
return (EINVAL);
|
|
|
|
/*
|
|
|
|
* Force device mappings to be shared.
|
|
|
|
*/
|
|
|
|
flags |= MAP_SHARED;
|
|
|
|
#ifdef MAC_XXX
|
|
|
|
error = mac_check_cdev_mmap(td->td_ucred, cdev, prot);
|
|
|
|
if (error != 0)
|
|
|
|
return (error);
|
|
|
|
#endif
|
|
|
|
obj = vm_pager_allocate(OBJT_DEVICE, cdev, objsize, prot, foff);
|
|
|
|
if (obj == NULL)
|
|
|
|
return (EINVAL);
|
|
|
|
*objp = obj;
|
|
|
|
*flagsp = flags;
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
2001-08-31 01:26:30 +00:00
|
|
|
* vm_mmap()
|
|
|
|
*
|
|
|
|
* MPSAFE
|
|
|
|
*
|
|
|
|
* Internal version of mmap. Currently used by mmap, exec, and sys5
|
|
|
|
* shared memory. Handle is either a vnode pointer or NULL for MAP_ANON.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
int
|
1997-08-25 22:15:31 +00:00
|
|
|
vm_mmap(vm_map_t map, vm_offset_t *addr, vm_size_t size, vm_prot_t prot,
|
|
|
|
vm_prot_t maxprot, int flags,
|
2005-04-01 20:00:11 +00:00
|
|
|
objtype_t handle_type, void *handle,
|
1997-08-25 22:15:31 +00:00
|
|
|
vm_ooffset_t foff)
|
1994-05-24 10:09:53 +00:00
|
|
|
{
|
|
|
|
boolean_t fitit;
|
1996-10-24 02:56:23 +00:00
|
|
|
vm_object_t object;
|
1994-05-24 10:09:53 +00:00
|
|
|
int rv = KERN_SUCCESS;
|
2003-12-06 05:45:32 +00:00
|
|
|
int docow, error;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread *td = curthread;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
|
|
|
if (size == 0)
|
|
|
|
return (0);
|
|
|
|
|
2005-09-20 22:08:27 +00:00
|
|
|
size = round_page(size);
|
1994-05-24 10:09:53 +00:00
|
|
|
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_LOCK(td->td_proc);
|
2002-06-26 00:29:28 +00:00
|
|
|
if (td->td_proc->p_vmspace->vm_map.size + size >
|
2004-02-04 21:52:57 +00:00
|
|
|
lim_cur(td->td_proc, RLIMIT_VMEM)) {
|
|
|
|
PROC_UNLOCK(td->td_proc);
|
2002-06-26 00:29:28 +00:00
|
|
|
return(ENOMEM);
|
|
|
|
}
|
2004-02-04 21:52:57 +00:00
|
|
|
PROC_UNLOCK(td->td_proc);
|
2002-06-26 00:29:28 +00:00
|
|
|
|
1995-03-21 10:15:52 +00:00
|
|
|
/*
|
|
|
|
* We currently can only deal with page aligned file offsets.
|
|
|
|
* The check is here rather than in the syscall because the
|
|
|
|
* kernel calls this function internally for other mmaping
|
|
|
|
* operations (such as in exec) and non-aligned offsets will
|
|
|
|
* cause pmap inconsistencies...so we want to be sure to
|
|
|
|
* disallow this in all cases.
|
|
|
|
*/
|
|
|
|
if (foff & PAGE_MASK)
|
|
|
|
return (EINVAL);
|
|
|
|
|
1995-07-09 06:58:03 +00:00
|
|
|
if ((flags & MAP_FIXED) == 0) {
|
|
|
|
fitit = TRUE;
|
|
|
|
*addr = round_page(*addr);
|
|
|
|
} else {
|
|
|
|
if (*addr != trunc_page(*addr))
|
|
|
|
return (EINVAL);
|
|
|
|
fitit = FALSE;
|
|
|
|
(void) vm_map_remove(map, *addr, *addr + size);
|
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
/*
|
NOTE: libkvm, w, ps, 'top', and any other utility which depends on struct
proc or any VM system structure will have to be rebuilt!!!
Much needed overhaul of the VM system. Included in this first round of
changes:
1) Improved pager interfaces: init, alloc, dealloc, getpages, putpages,
haspage, and sync operations are supported. The haspage interface now
provides information about clusterability. All pager routines now take
struct vm_object's instead of "pagers".
2) Improved data structures. In the previous paradigm, there is constant
confusion caused by pagers being both a data structure ("allocate a
pager") and a collection of routines. The idea of a pager structure has
escentially been eliminated. Objects now have types, and this type is
used to index the appropriate pager. In most cases, items in the pager
structure were duplicated in the object data structure and thus were
unnecessary. In the few cases that remained, a un_pager structure union
was created in the object to contain these items.
3) Because of the cleanup of #1 & #2, a lot of unnecessary layering can now
be removed. For instance, vm_object_enter(), vm_object_lookup(),
vm_object_remove(), and the associated object hash list were some of the
things that were removed.
4) simple_lock's removed. Discussion with several people reveals that the
SMP locking primitives used in the VM system aren't likely the mechanism
that we'll be adopting. Even if it were, the locking that was in the code
was very inadequate and would have to be mostly re-done anyway. The
locking in a uni-processor kernel was a no-op but went a long way toward
making the code difficult to read and debug.
5) Places that attempted to kludge-up the fact that we don't have kernel
thread support have been fixed to reflect the reality that we are really
dealing with processes, not threads. The VM system didn't have complete
thread support, so the comments and mis-named routines were just wrong.
We now use tsleep and wakeup directly in the lock routines, for instance.
6) Where appropriate, the pagers have been improved, especially in the
pager_alloc routines. Most of the pager_allocs have been rewritten and
are now faster and easier to maintain.
7) The pagedaemon pageout clustering algorithm has been rewritten and
now tries harder to output an even number of pages before and after
the requested page. This is sort of the reverse of the ideal pagein
algorithm and should provide better overall performance.
8) Unnecessary (incorrect) casts to caddr_t in calls to tsleep & wakeup
have been removed. Some other unnecessary casts have also been removed.
9) Some almost useless debugging code removed.
10) Terminology of shadow objects vs. backing objects straightened out.
The fact that the vm_object data structure escentially had this
backwards really confused things. The use of "shadow" and "backing
object" throughout the code is now internally consistent and correct
in the Mach terminology.
11) Several minor bug fixes, including one in the vm daemon that caused
0 RSS objects to not get purged as intended.
12) A "default pager" has now been created which cleans up the transition
of objects to the "swap" type. The previous checks throughout the code
for swp->pg_data != NULL were really ugly. This change also provides
the rudiments for future backing of "anonymous" memory by something
other than the swap pager (via the vnode pager, for example), and it
allows the decision about which of these pagers to use to be made
dynamically (although will need some additional decision code to do
this, of course).
13) (dyson) MAP_COPY has been deprecated and the corresponding "copy
object" code has been removed. MAP_COPY was undocumented and non-
standard. It was furthermore broken in several ways which caused its
behavior to degrade to MAP_PRIVATE. Binaries that use MAP_COPY will
continue to work correctly, but via the slightly different semantics
of MAP_PRIVATE.
14) (dyson) Sharing maps have been removed. It's marginal usefulness in a
threads design can be worked around in other ways. Both #12 and #13
were done to simplify the code and improve readability and maintain-
ability. (As were most all of these changes)
TODO:
1) Rewrite most of the vnode pager to use VOP_GETPAGES/PUTPAGES. Doing
this will reduce the vnode pager to a mere fraction of its current size.
2) Rewrite vm_fault and the swap/vnode pagers to use the clustering
information provided by the new haspage pager interface. This will
substantially reduce the overhead by eliminating a large number of
VOP_BMAP() calls. The VOP_BMAP() filesystem interface should be
improved to provide both a "behind" and "ahead" indication of
contiguousness.
3) Implement the extended features of pager_haspage in swap_pager_haspage().
It currently just says 0 pages ahead/behind.
4) Re-implement the swap device (swstrategy) in a more elegant way, perhaps
via a much more general mechanism that could also be used for disk
striping of regular filesystems.
5) Do something to improve the architecture of vm_object_collapse(). The
fact that it makes calls into the swap pager and knows too much about
how the swap pager operates really bothers me. It also doesn't allow
for collapsing of non-swap pager objects ("unnamed" objects backed by
other pagers).
1995-07-13 08:48:48 +00:00
|
|
|
* Lookup/allocate object.
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
2005-04-01 20:00:11 +00:00
|
|
|
switch (handle_type) {
|
|
|
|
case OBJT_DEVICE:
|
|
|
|
error = vm_mmap_cdev(td, size, prot, &maxprot, &flags,
|
|
|
|
handle, foff, &object);
|
|
|
|
break;
|
|
|
|
case OBJT_VNODE:
|
2004-02-27 22:02:15 +00:00
|
|
|
error = vm_mmap_vnode(td, size, prot, &maxprot, &flags,
|
|
|
|
handle, foff, &object);
|
2005-04-01 20:00:11 +00:00
|
|
|
break;
|
|
|
|
case OBJT_DEFAULT:
|
|
|
|
if (handle == NULL) {
|
|
|
|
error = 0;
|
|
|
|
break;
|
2003-12-06 05:45:32 +00:00
|
|
|
}
|
2005-04-01 20:00:11 +00:00
|
|
|
/* FALLTHROUGH */
|
|
|
|
default:
|
|
|
|
error = EINVAL;
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2005-04-01 20:00:11 +00:00
|
|
|
if (error)
|
|
|
|
return (error);
|
2004-02-27 22:02:15 +00:00
|
|
|
if (flags & MAP_ANON) {
|
1996-12-28 22:40:44 +00:00
|
|
|
object = NULL;
|
1999-06-05 18:21:53 +00:00
|
|
|
docow = 0;
|
2004-02-27 22:02:15 +00:00
|
|
|
/*
|
|
|
|
* Unnamed anonymous regions always start at 0.
|
|
|
|
*/
|
|
|
|
if (handle == 0)
|
|
|
|
foff = 0;
|
1996-12-28 22:40:44 +00:00
|
|
|
} else {
|
1999-06-05 18:21:53 +00:00
|
|
|
docow = MAP_PREFAULT_PARTIAL;
|
1996-12-28 22:40:44 +00:00
|
|
|
}
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1999-12-12 03:19:33 +00:00
|
|
|
if ((flags & (MAP_ANON|MAP_SHARED)) == 0)
|
1999-06-05 18:21:53 +00:00
|
|
|
docow |= MAP_COPY_ON_WRITE;
|
1999-12-12 03:19:33 +00:00
|
|
|
if (flags & MAP_NOSYNC)
|
|
|
|
docow |= MAP_DISABLE_SYNCER;
|
2000-02-28 04:10:35 +00:00
|
|
|
if (flags & MAP_NOCORE)
|
|
|
|
docow |= MAP_DISABLE_COREDUMP;
|
1996-03-12 02:27:20 +00:00
|
|
|
|
1996-12-30 05:31:21 +00:00
|
|
|
#if defined(VM_PROT_READ_IS_EXEC)
|
|
|
|
if (prot & VM_PROT_READ)
|
|
|
|
prot |= VM_PROT_EXECUTE;
|
|
|
|
|
|
|
|
if (maxprot & VM_PROT_READ)
|
|
|
|
maxprot |= VM_PROT_EXECUTE;
|
|
|
|
#endif
|
|
|
|
|
2001-05-23 22:17:43 +00:00
|
|
|
if (fitit)
|
1997-07-17 04:34:03 +00:00
|
|
|
*addr = pmap_addr_hint(object, *addr, size);
|
|
|
|
|
1999-01-06 23:05:42 +00:00
|
|
|
if (flags & MAP_STACK)
|
2003-09-27 22:28:14 +00:00
|
|
|
rv = vm_map_stack(map, *addr, size, prot, maxprot,
|
|
|
|
docow | MAP_STACK_GROWS_DOWN);
|
1999-01-06 23:05:42 +00:00
|
|
|
else
|
1999-04-19 14:14:14 +00:00
|
|
|
rv = vm_map_find(map, object, foff, addr, size, fitit,
|
|
|
|
prot, maxprot, docow);
|
1996-07-30 03:08:57 +00:00
|
|
|
|
2001-08-31 01:26:30 +00:00
|
|
|
if (rv != KERN_SUCCESS) {
|
1995-10-23 03:49:43 +00:00
|
|
|
/*
|
|
|
|
* Lose the object reference. Will destroy the
|
|
|
|
* object if it's an unnamed anonymous mapping
|
|
|
|
* or named anonymous without other references.
|
|
|
|
*/
|
1996-10-24 02:56:23 +00:00
|
|
|
vm_object_deallocate(object);
|
2001-08-31 01:26:30 +00:00
|
|
|
} else if (flags & MAP_SHARED) {
|
|
|
|
/*
|
|
|
|
* Shared memory is also shared with children.
|
|
|
|
*/
|
These changes embody the support of the fully coherent merged VM buffer cache,
much higher filesystem I/O performance, and much better paging performance. It
represents the culmination of over 6 months of R&D.
The majority of the merged VM/cache work is by John Dyson.
The following highlights the most significant changes. Additionally, there are
(mostly minor) changes to the various filesystem modules (nfs, msdosfs, etc) to
support the new VM/buffer scheme.
vfs_bio.c:
Significant rewrite of most of vfs_bio to support the merged VM buffer cache
scheme. The scheme is almost fully compatible with the old filesystem
interface. Significant improvement in the number of opportunities for write
clustering.
vfs_cluster.c, vfs_subr.c
Upgrade and performance enhancements in vfs layer code to support merged
VM/buffer cache. Fixup of vfs_cluster to eliminate the bogus pagemove stuff.
vm_object.c:
Yet more improvements in the collapse code. Elimination of some windows that
can cause list corruption.
vm_pageout.c:
Fixed it, it really works better now. Somehow in 2.0, some "enhancements"
broke the code. This code has been reworked from the ground-up.
vm_fault.c, vm_page.c, pmap.c, vm_object.c
Support for small-block filesystems with merged VM/buffer cache scheme.
pmap.c vm_map.c
Dynamic kernel VM size, now we dont have to pre-allocate excessive numbers of
kernel PTs.
vm_glue.c
Much simpler and more effective swapping code. No more gratuitous swapping.
proc.h
Fixed the problem that the p_lock flag was not being cleared on a fork.
swap_pager.c, vnode_pager.c
Removal of old vfs_bio cruft to support the past pseudo-coherency. Now the
code doesn't need it anymore.
machdep.c
Changes to better support the parameter values for the merged VM/buffer cache
scheme.
machdep.c, kern_exec.c, vm_glue.c
Implemented a seperate submap for temporary exec string space and another one
to contain process upages. This eliminates all map fragmentation problems
that previously existed.
ffs_inode.c, ufs_inode.c, ufs_readwrite.c
Changes for merged VM/buffer cache. Add "bypass" support for sneaking in on
busy buffers.
Submitted by: John Dyson and David Greenman
1995-01-09 16:06:02 +00:00
|
|
|
rv = vm_map_inherit(map, *addr, *addr + size, VM_INHERIT_SHARE);
|
2001-05-23 22:17:43 +00:00
|
|
|
if (rv != KERN_SUCCESS)
|
1995-02-21 01:22:48 +00:00
|
|
|
(void) vm_map_remove(map, *addr, *addr + size);
|
1994-05-24 10:09:53 +00:00
|
|
|
}
|
2003-08-11 07:14:08 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If the process has requested that all future mappings
|
|
|
|
* be wired, then heed this.
|
|
|
|
*/
|
|
|
|
if ((rv == KERN_SUCCESS) && (map->flags & MAP_WIREFUTURE))
|
|
|
|
vm_map_wire(map, *addr, *addr + size,
|
|
|
|
VM_MAP_WIRE_USER|VM_MAP_WIRE_NOHOLES);
|
|
|
|
|
1994-05-24 10:09:53 +00:00
|
|
|
switch (rv) {
|
|
|
|
case KERN_SUCCESS:
|
|
|
|
return (0);
|
|
|
|
case KERN_INVALID_ADDRESS:
|
|
|
|
case KERN_NO_SPACE:
|
|
|
|
return (ENOMEM);
|
|
|
|
case KERN_PROTECTION_FAILURE:
|
|
|
|
return (EACCES);
|
|
|
|
default:
|
|
|
|
return (EINVAL);
|
|
|
|
}
|
|
|
|
}
|