Various changes to allow operation without any swapspace configured. Note
that this is intended for use only in floppy situations and is done at the sacrifice of performance in that case (in ther words, this is not the best solution, but works okay for this exceptional situation). Submitted by: John Dyson
This commit is contained in:
parent
6dde05f573
commit
5663e6de1c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=3766
@ -39,7 +39,7 @@
|
||||
* from: Utah $Hdr: swap_pager.c 1.4 91/04/30$
|
||||
*
|
||||
* @(#)swap_pager.c 8.9 (Berkeley) 3/21/94
|
||||
* $Id: swap_pager.c,v 1.13 1994/10/14 12:26:17 davidg Exp $
|
||||
* $Id: swap_pager.c,v 1.14 1994/10/15 13:33:06 davidg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -141,6 +141,8 @@ int dmmin, dmmax;
|
||||
extern int vm_page_count;
|
||||
|
||||
static inline void swapsizecheck() {
|
||||
if( vm_swap_size == 0)
|
||||
return;
|
||||
if( vm_swap_size < 128*btodb(PAGE_SIZE)) {
|
||||
if( swap_pager_full)
|
||||
printf("swap_pager: out of space\n");
|
||||
@ -235,9 +237,11 @@ swap_pager_alloc(handle, size, prot, offset)
|
||||
}
|
||||
}
|
||||
|
||||
if (swap_pager_full) {
|
||||
/*
|
||||
if (swap_pager_full && (vm_swap_size == 0)) {
|
||||
return(NULL);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* Pager doesn't exist, allocate swap management resources
|
||||
@ -534,6 +538,9 @@ swap_pager_copy(srcpager, srcoffset, dstpager, dstoffset, offset)
|
||||
vm_offset_t i;
|
||||
int s;
|
||||
|
||||
if( vm_swap_size == 0)
|
||||
return;
|
||||
|
||||
srcswp = (sw_pager_t) srcpager->pg_data;
|
||||
dstswp = (sw_pager_t) dstpager->pg_data;
|
||||
|
||||
@ -1204,6 +1211,12 @@ swap_pager_output(swp, m, count, flags, rtvals)
|
||||
if( count > 1)
|
||||
printf("off: 0x%x, count: %d\n", m[0]->offset, count);
|
||||
*/
|
||||
if( vm_swap_size == 0) {
|
||||
for(i=0;i<count;i++)
|
||||
rtvals[i] = VM_PAGER_FAIL;
|
||||
return VM_PAGER_FAIL;
|
||||
}
|
||||
|
||||
spc = NULL;
|
||||
|
||||
object = m[0]->object;
|
||||
|
@ -66,7 +66,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_fault.c,v 1.8 1994/10/15 10:33:47 davidg Exp $
|
||||
* $Id: vm_fault.c,v 1.9 1994/10/15 13:33:07 davidg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -325,10 +325,12 @@ vm_fault(map, vaddr, fault_type, change_wiring)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (swap_pager_full && !object->shadow && (!object->pager ||
|
||||
if ((cnt.v_free_count < cnt.v_free_min) &&
|
||||
swap_pager_full && !object->shadow && (!object->pager ||
|
||||
(object->pager && object->pager->pg_type == PG_SWAP &&
|
||||
!vm_pager_has_page(object->pager, offset+object->paging_offset)))) {
|
||||
if (vaddr < VM_MAXUSER_ADDRESS && curproc && curproc->p_pid >= 48) /* XXX */ {
|
||||
if (vaddr < VM_MAXUSER_ADDRESS &&
|
||||
curproc && curproc->p_pid >= 48) /* XXX */ {
|
||||
printf("Process %lu killed by vm_fault -- out of swap\n", (u_long)curproc->p_pid);
|
||||
psignal(curproc, SIGKILL);
|
||||
curproc->p_estcpu = 0;
|
||||
|
@ -65,7 +65,7 @@
|
||||
* any improvements or extensions that they make and grant Carnegie the
|
||||
* rights to redistribute these changes.
|
||||
*
|
||||
* $Id: vm_pageout.c,v 1.18 1994/10/15 13:33:08 davidg Exp $
|
||||
* $Id: vm_pageout.c,v 1.19 1994/10/18 14:59:20 davidg Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -97,6 +97,7 @@ extern int hz;
|
||||
int vm_pageout_proc_limit;
|
||||
extern int nswiodone;
|
||||
extern int swap_pager_full;
|
||||
extern int vm_swap_size;
|
||||
extern int swap_pager_ready();
|
||||
|
||||
#define MAXREF 32767
|
||||
@ -483,7 +484,8 @@ vm_pageout_scan()
|
||||
int pages_freed;
|
||||
int desired_free;
|
||||
vm_page_t next;
|
||||
struct proc *p;
|
||||
struct proc *p, *bigproc;
|
||||
vm_offset_t size, bigsize;
|
||||
vm_object_t object;
|
||||
int force_wakeup = 0;
|
||||
int cache_size, orig_cache_size;
|
||||
@ -510,7 +512,7 @@ vm_pageout_scan()
|
||||
object = vm_object_cached_list.tqh_first;
|
||||
vm_object_cache_lock();
|
||||
while ( object && (cnt.v_inactive_count < cnt.v_inactive_target) &&
|
||||
(cache_size >= vm_desired_cache_size)) {
|
||||
(cache_size >= (vm_swap_size?vm_desired_cache_size:0))) {
|
||||
vm_object_cache_unlock();
|
||||
|
||||
/*
|
||||
@ -538,7 +540,7 @@ vm_pageout_scan()
|
||||
/*
|
||||
* now swap processes out if we are in low memory conditions
|
||||
*/
|
||||
if (cnt.v_free_count <= cnt.v_free_min) {
|
||||
if ((cnt.v_free_count <= cnt.v_free_min) && !swap_pager_full && vm_swap_size) {
|
||||
/*
|
||||
* swap out inactive processes
|
||||
*/
|
||||
@ -551,7 +553,6 @@ vm_pageout_scan()
|
||||
*/
|
||||
|
||||
for (p = (struct proc *)allproc; p != NULL; p = p->p_next) {
|
||||
vm_offset_t size;
|
||||
int overage;
|
||||
quad_t limit;
|
||||
|
||||
@ -714,7 +715,7 @@ vm_pageout_scan()
|
||||
if (page_shortage <= 0) {
|
||||
if (pages_freed == 0) {
|
||||
if( cnt.v_free_count < cnt.v_free_min) {
|
||||
page_shortage = cnt.v_free_min - cnt.v_free_count;
|
||||
page_shortage = cnt.v_free_min - cnt.v_free_count + 1;
|
||||
} else if(((cnt.v_free_count + cnt.v_inactive_count) <
|
||||
(cnt.v_free_min + cnt.v_inactive_target))) {
|
||||
page_shortage = 1;
|
||||
@ -780,12 +781,58 @@ vm_pageout_scan()
|
||||
* then we keep trying until we get some (any) memory.
|
||||
*/
|
||||
|
||||
if( !force_wakeup && (swap_pager_full || !force_wakeup ||
|
||||
(pages_freed == 0 && (cnt.v_free_count < cnt.v_free_min)))){
|
||||
if (!force_wakeup && (swap_pager_full || !force_wakeup ||
|
||||
(pages_freed == 0 && (cnt.v_free_count < cnt.v_free_min)))){
|
||||
vm_pager_sync();
|
||||
force_wakeup = 1;
|
||||
goto morefree;
|
||||
}
|
||||
|
||||
/*
|
||||
* make sure that we have swap space -- if we are low on
|
||||
* memory and swap -- then kill the biggest process.
|
||||
*/
|
||||
if ((vm_swap_size == 0 || swap_pager_full) &&
|
||||
(cnt.v_free_count < cnt.v_free_min)) {
|
||||
bigproc = NULL;
|
||||
bigsize = 0;
|
||||
for (p = (struct proc *)allproc; p != NULL; p = p->p_next) {
|
||||
/*
|
||||
* if this is a system process, skip it
|
||||
*/
|
||||
if ((p->p_flag & P_SYSTEM) || ((p->p_pid < 48) && (vm_swap_size != 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
/*
|
||||
* if the process is in a non-running type state,
|
||||
* don't touch it.
|
||||
*/
|
||||
if (p->p_stat != SRUN && p->p_stat != SSLEEP) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* get the process size
|
||||
*/
|
||||
size = p->p_vmspace->vm_pmap.pm_stats.resident_count;
|
||||
/*
|
||||
* if the this process is bigger than the biggest one
|
||||
* remember it.
|
||||
*/
|
||||
if (size > bigsize) {
|
||||
bigproc = p;
|
||||
bigsize = size;
|
||||
}
|
||||
}
|
||||
if (bigproc != NULL) {
|
||||
printf("Process %lu killed by vm_pageout -- out of swap\n", (u_long)bigproc->p_pid);
|
||||
psignal(bigproc, SIGKILL);
|
||||
bigproc->p_estcpu = 0;
|
||||
bigproc->p_nice = PRIO_MIN;
|
||||
resetpriority(bigproc);
|
||||
wakeup( (caddr_t) &cnt.v_free_count);
|
||||
}
|
||||
}
|
||||
vm_page_pagesfreed += pages_freed;
|
||||
return force_wakeup;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user