1994-05-24 10:09:53 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1992, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @(#)vm_extern.h 8.2 (Berkeley) 1/12/94
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-05-24 10:09:53 +00:00
|
|
|
*/
|
|
|
|
|
1994-12-30 08:02:16 +00:00
|
|
|
#ifndef _VM_EXTERN_H_
|
|
|
|
#define _VM_EXTERN_H_
|
1994-08-21 07:19:45 +00:00
|
|
|
|
2013-09-20 17:06:49 +00:00
|
|
|
struct pmap;
|
1994-05-24 10:09:53 +00:00
|
|
|
struct proc;
|
|
|
|
struct vmspace;
|
|
|
|
struct vnode;
|
2013-08-07 06:21:20 +00:00
|
|
|
struct vmem;
|
1994-05-24 10:09:53 +00:00
|
|
|
|
1999-12-29 05:07:58 +00:00
|
|
|
#ifdef _KERNEL
|
1995-03-16 18:17:34 +00:00
|
|
|
|
2013-08-07 06:21:20 +00:00
|
|
|
/* These operate on kernel virtual addresses only. */
|
|
|
|
vm_offset_t kva_alloc(vm_size_t);
|
|
|
|
void kva_free(vm_offset_t, vm_size_t);
|
|
|
|
|
|
|
|
/* These operate on pageable virtual addresses. */
|
|
|
|
vm_offset_t kmap_alloc_wait(vm_map_t, vm_size_t);
|
|
|
|
void kmap_free_wakeup(vm_map_t, vm_offset_t, vm_size_t);
|
|
|
|
|
|
|
|
/* These operate on virtual addresses backed by memory. */
|
|
|
|
vm_offset_t kmem_alloc_attr(struct vmem *, vm_size_t size, int flags,
|
2010-04-09 02:39:20 +00:00
|
|
|
vm_paddr_t low, vm_paddr_t high, vm_memattr_t memattr);
|
2013-08-07 06:21:20 +00:00
|
|
|
vm_offset_t kmem_alloc_contig(struct vmem *, vm_size_t size, int flags,
|
2011-10-30 05:06:14 +00:00
|
|
|
vm_paddr_t low, vm_paddr_t high, u_long alignment, vm_paddr_t boundary,
|
2011-10-28 22:36:15 +00:00
|
|
|
vm_memattr_t memattr);
|
2013-08-07 06:21:20 +00:00
|
|
|
vm_offset_t kmem_malloc(struct vmem *, vm_size_t size, int flags);
|
|
|
|
void kmem_free(struct vmem *, vm_offset_t, vm_size_t);
|
|
|
|
|
|
|
|
/* This provides memory for previously allocated address space. */
|
|
|
|
int kmem_back(vm_object_t, vm_offset_t, vm_size_t, int);
|
|
|
|
void kmem_unback(vm_object_t, vm_offset_t, vm_size_t);
|
|
|
|
|
|
|
|
/* Bootstrapping. */
|
2008-05-10 21:46:20 +00:00
|
|
|
vm_map_t kmem_suballoc(vm_map_t, vm_offset_t *, vm_offset_t *, vm_size_t,
|
|
|
|
boolean_t);
|
2013-08-07 06:21:20 +00:00
|
|
|
void kmem_init(vm_offset_t, vm_offset_t);
|
|
|
|
void kmem_init_zero_region(void);
|
|
|
|
void kmeminit(void);
|
|
|
|
|
2002-03-19 22:20:14 +00:00
|
|
|
void swapout_procs(int);
|
2013-08-07 06:21:20 +00:00
|
|
|
int kernacc(void *, int, int);
|
2003-01-21 11:34:57 +00:00
|
|
|
int useracc(void *, int, int);
|
2002-03-19 22:20:14 +00:00
|
|
|
int vm_fault(vm_map_t, vm_offset_t, vm_prot_t, int);
|
2009-07-03 22:17:37 +00:00
|
|
|
void vm_fault_copy_entry(vm_map_t, vm_map_t, vm_map_entry_t, vm_map_entry_t,
|
|
|
|
vm_ooffset_t *);
|
2011-07-09 15:21:10 +00:00
|
|
|
int vm_fault_disable_pagefaults(void);
|
|
|
|
void vm_fault_enable_pagefaults(int save);
|
2013-08-05 08:55:35 +00:00
|
|
|
int vm_fault_hold(vm_map_t map, vm_offset_t vaddr, vm_prot_t fault_type,
|
2010-12-20 22:49:31 +00:00
|
|
|
int fault_flags, vm_page_t *m_hold);
|
2010-12-25 21:26:56 +00:00
|
|
|
int vm_fault_quick_hold_pages(vm_map_t map, vm_offset_t addr, vm_size_t len,
|
|
|
|
vm_prot_t prot, vm_page_t *ma, int max_count);
|
2004-05-22 04:53:51 +00:00
|
|
|
void vm_fault_unwire(vm_map_t, vm_offset_t, vm_offset_t, boolean_t);
|
2009-11-18 18:05:54 +00:00
|
|
|
int vm_fault_wire(vm_map_t, vm_offset_t, vm_offset_t, boolean_t);
|
2007-11-05 11:36:16 +00:00
|
|
|
int vm_forkproc(struct thread *, struct proc *, struct thread *, struct vmspace *, int);
|
2002-03-19 22:20:14 +00:00
|
|
|
void vm_waitproc(struct proc *);
|
2005-04-01 20:00:11 +00:00
|
|
|
int vm_mmap(vm_map_t, vm_offset_t *, vm_size_t, vm_prot_t, vm_prot_t, int, objtype_t, void *, vm_ooffset_t);
|
2011-07-10 20:49:13 +00:00
|
|
|
int vm_mmap_to_errno(int rv);
|
2002-03-19 22:20:14 +00:00
|
|
|
void vm_set_page_size(void);
|
2009-10-21 18:38:02 +00:00
|
|
|
void vm_sync_icache(vm_map_t, vm_offset_t, vm_size_t);
|
2013-09-20 17:06:49 +00:00
|
|
|
typedef int (*pmap_pinit_t)(struct pmap *pmap);
|
|
|
|
struct vmspace *vmspace_alloc(vm_offset_t, vm_offset_t, pmap_pinit_t);
|
Implement global and per-uid accounting of the anonymous memory. Add
rlimit RLIMIT_SWAP that limits the amount of swap that may be reserved
for the uid.
The accounting information (charge) is associated with either map entry,
or vm object backing the entry, assuming the object is the first one
in the shadow chain and entry does not require COW. Charge is moved
from entry to object on allocation of the object, e.g. during the mmap,
assuming the object is allocated, or on the first page fault on the
entry. It moves back to the entry on forks due to COW setup.
The per-entry granularity of accounting makes the charge process fair
for processes that change uid during lifetime, and decrements charge
for proper uid when region is unmapped.
The interface of vm_pager_allocate(9) is extended by adding struct ucred *,
that is used to charge appropriate uid when allocation if performed by
kernel, e.g. md(4).
Several syscalls, among them is fork(2), may now return ENOMEM when
global or per-uid limits are enforced.
In collaboration with: pho
Reviewed by: alc
Approved by: re (kensmith)
2009-06-23 20:45:22 +00:00
|
|
|
struct vmspace *vmspace_fork(struct vmspace *, vm_ooffset_t *);
|
2007-11-05 11:36:16 +00:00
|
|
|
int vmspace_exec(struct proc *, vm_offset_t, vm_offset_t);
|
|
|
|
int vmspace_unshare(struct proc *);
|
2006-05-29 21:28:56 +00:00
|
|
|
void vmspace_exit(struct thread *);
|
|
|
|
struct vmspace *vmspace_acquire_ref(struct proc *);
|
2002-03-19 22:20:14 +00:00
|
|
|
void vmspace_free(struct vmspace *);
|
|
|
|
void vmspace_exitfree(struct proc *);
|
|
|
|
void vnode_pager_setsize(struct vnode *, vm_ooffset_t);
|
2004-03-15 06:42:40 +00:00
|
|
|
int vslock(void *, size_t);
|
|
|
|
void vsunlock(void *, size_t);
|
2005-12-16 18:34:14 +00:00
|
|
|
struct sf_buf *vm_imgact_map_page(vm_object_t object, vm_ooffset_t offset);
|
2013-08-05 08:55:35 +00:00
|
|
|
void vm_imgact_unmap_page(struct sf_buf *sf);
|
2003-06-14 23:23:55 +00:00
|
|
|
void vm_thread_dispose(struct thread *td);
|
2007-11-05 11:36:16 +00:00
|
|
|
int vm_thread_new(struct thread *td, int pages);
|
2013-06-08 13:13:40 +00:00
|
|
|
int vm_mlock(struct proc *, struct ucred *, const void *, size_t);
|
1999-12-29 05:07:58 +00:00
|
|
|
#endif /* _KERNEL */
|
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 /* !_VM_EXTERN_H_ */
|