diff options
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_mmap.c | 15 | ||||
-rw-r--r-- | sys/vm/vm_pageout.c | 3 |
2 files changed, 17 insertions, 1 deletions
diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 93c8524..d20756f 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -752,8 +752,23 @@ madvise(td, uap) { vm_offset_t start, end; vm_map_t map; + struct proc *p; + int error; /* + * Check for our special case, advising the swap pager we are + * "immortal." + */ + if (uap->behav == MADV_PROTECT) { + p = td->td_proc; + PROC_LOCK(p); + error = suser(td); + if (error == 0) + p->p_flag |= P_PROTECTED; + PROC_UNLOCK(p); + return (error); + } + /* * Check for illegal behavior */ if (uap->behav < 0 || uap->behav > MADV_CORE) diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c index dab4ae2..8c07be2 100644 --- a/sys/vm/vm_pageout.c +++ b/sys/vm/vm_pageout.c @@ -1184,9 +1184,10 @@ rescan0: if (PROC_TRYLOCK(p) == 0) continue; /* - * if this is a system process, skip it + * If this is a system or protected process, skip it. */ if ((p->p_flag & P_SYSTEM) || (p->p_pid == 1) || + (p->p_flag & P_PROTECTED) || ((p->p_pid < 48) && (vm_swap_size != 0))) { PROC_UNLOCK(p); continue; |