--- linux-2.6.14/arch/ia64/ia32/binfmt_elf32.c 2005-10-28 20:49:10 +0200 +++ linux-2.6.14-vs2.0.1-pre3/arch/ia64/ia32/binfmt_elf32.c 2005-10-29 04:33:06 +0200 @@ -199,7 +199,7 @@ ia64_elf32_init (struct pt_regs *regs) int ia32_setup_arg_pages (struct linux_binprm *bprm, int executable_stack) { - unsigned long stack_base; + unsigned long stack_base, grow; struct vm_area_struct *mpnt; struct mm_struct *mm = current->mm; int i, ret; --- linux-2.6.14/arch/ia64/ia32/binfmt_elf32.c 2005-10-28 20:49:10 +0200 +++ linux-2.6.14-vs2.0.1-pre3/arch/ia64/ia32/binfmt_elf32.c 2005-10-29 04:33:06 +0200 @@ -236,7 +236,8 @@ ia32_setup_arg_pages (struct linux_binpr kmem_cache_free(vm_area_cachep, mpnt); return ret; } - current->mm->stack_vm = current->mm->total_vm = vma_pages(mpnt); + vx_vmpages_sub(current->mm, current->mm->total_vm - vma_pages(mpnt)); + current->mm->stack_vm = current->mm->total_vm; } for (i = 0 ; i < MAX_ARG_PAGES ; i++) { --- linux-2.6.14/arch/ia64/kernel/perfmon.c 2005-10-28 20:49:11 +0200 +++ linux-2.6.14-vs2.0.1-pre3/arch/ia64/kernel/perfmon.c 2005-10-29 04:33:06 +0200 @@ -2351,7 +2353,7 @@ pfm_smpl_buffer_alloc(struct task_struct */ insert_vm_struct(mm, vma); - mm->total_vm += size >> PAGE_SHIFT; + vx_vmpages_add(mm, size >> PAGE_SHIFT); vm_stat_account(vma); up_write(&task->mm->mmap_sem); --- linux-2.6.14/arch/ia64/mm/fault.c 2005-10-28 20:49:11 +0200 +++ linux-2.6.14-vs2.0.1-pre3/arch/ia64/mm/fault.c 2005-10-29 04:33:06 +0200 @@ -35,12 +36,17 @@ expand_backing_store (struct vm_area_str grow = PAGE_SIZE >> PAGE_SHIFT; if (address - vma->vm_start > current->signal->rlim[RLIMIT_STACK].rlim_cur - || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > current->signal->rlim[RLIMIT_AS].rlim_cur)) + || (((vma->vm_mm->total_vm + grow) << PAGE_SHIFT) > + current->signal->rlim[RLIMIT_AS].rlim_cur)) + return -ENOMEM; + if (!vx_vmpages_avail(vma->vm_mm, grow) || + ((vma->vm_flags & VM_LOCKED) && + !vx_vmlocked_avail(vma->vm_mm, grow))) return -ENOMEM; vma->vm_end += PAGE_SIZE; - vma->vm_mm->total_vm += grow; + vx_vmpages_add(vma->vm_mm, grow); if (vma->vm_flags & VM_LOCKED) - vma->vm_mm->locked_vm += grow; + vx_vmlocked_add(vma->vm_mm, grow); __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, grow); return 0; } --- linux-2.6.14/arch/x86_64/ia32/ia32_binfmt.c 2005-10-28 20:49:18 +0200 +++ linux-2.6.14-vs2.0.1-pre3/arch/x86_64/ia32/ia32_binfmt.c 2005-10-29 04:33:06 +0200 @@ -337,7 +337,7 @@ static void elf32_init(struct pt_regs *r int setup_arg_pages(struct linux_binprm *bprm, unsigned long stack_top, int executable_stack) { - unsigned long stack_base; + unsigned long stack_base, grow; struct vm_area_struct *mpnt; struct mm_struct *mm = current->mm; int i, ret; --- linux-2.6.14/arch/x86_64/ia32/ia32_binfmt.c 2005-10-28 20:49:18 +0200 +++ linux-2.6.14-vs2.0.1-pre3/arch/x86_64/ia32/ia32_binfmt.c 2005-10-29 04:33:06 +0200 @@ -374,7 +374,8 @@ int setup_arg_pages(struct linux_binprm kmem_cache_free(vm_area_cachep, mpnt); return ret; } - mm->stack_vm = mm->total_vm = vma_pages(mpnt); + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt)); + mm->stack_vm = mm->total_vm; } for (i = 0 ; i < MAX_ARG_PAGES ; i++) { --- linux-2.6.14/fs/exec.c 2005-10-28 20:49:44 +0200 +++ linux-2.6.14-vs2.0.1-pre3/fs/exec.c 2005-10-29 04:33:06 +0200 @@ -449,7 +450,8 @@ int setup_arg_pages(struct linux_binprm kmem_cache_free(vm_area_cachep, mpnt); return ret; } - mm->stack_vm = mm->total_vm = vma_pages(mpnt); + vx_vmpages_sub(mm, mm->total_vm - vma_pages(mpnt)); + mm->stack_vm = mm->total_vm; } for (i = 0 ; i < MAX_ARG_PAGES ; i++) { --- linux-2.6.14/include/linux/sched.h 2005-10-28 20:49:56 +0200 +++ linux-2.6.14-vs2.0.1-pre3/include/linux/sched.h 2005-10-30 04:29:36 +0100 @@ -249,11 +251,12 @@ arch_get_unmapped_area_topdown(struct fi extern void arch_unmap_area(struct mm_struct *, unsigned long); extern void arch_unmap_area_topdown(struct mm_struct *, unsigned long); -#define set_mm_counter(mm, member, value) (mm)->_##member = (value) +#define __set_mm_counter(mm, member, value) (mm)->_##member = (value) +#define set_mm_counter(mm, member, value) vx_ ## member ## pages_sub((mm), ((mm)->_##member - value)) #define get_mm_counter(mm, member) ((mm)->_##member) -#define add_mm_counter(mm, member, value) (mm)->_##member += (value) -#define inc_mm_counter(mm, member) (mm)->_##member++ -#define dec_mm_counter(mm, member) (mm)->_##member-- +#define add_mm_counter(mm, member, value) vx_ ## member ## pages_add((mm), (value)) +#define inc_mm_counter(mm, member) vx_ ## member ## pages_inc((mm)) +#define dec_mm_counter(mm, member) vx_ ## member ## pages_dec((mm)) typedef unsigned long mm_counter_t; struct mm_struct { --- linux-2.6.14/include/linux/sched.h 2005-10-28 20:49:56 +0200 +++ linux-2.6.14-vs2.0.1-pre3/include/linux/sched.h 2005-10-30 04:29:36 +0100 @@ -296,6 +299,7 @@ struct mm_struct { /* Architecture-specific MM context */ mm_context_t context; + struct vx_info *mm_vx_info; /* Token based thrashing protection. */ unsigned long swap_token_time; --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -198,8 +203,8 @@ static inline int dup_mmap(struct mm_str mm->free_area_cache = oldmm->mmap_base; mm->cached_hole_size = ~0UL; mm->map_count = 0; - set_mm_counter(mm, rss, 0); - set_mm_counter(mm, anon_rss, 0); + __set_mm_counter(mm, rss, 0); + __set_mm_counter(mm, anon_rss, 0); cpus_clear(mm->cpu_vm_mask); mm->mm_rb = RB_ROOT; rb_link = &mm->mm_rb.rb_node; --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -332,6 +337,7 @@ static struct mm_struct * mm_init(struct if (likely(!mm_alloc_pgd(mm))) { mm->def_flags = 0; + set_vx_info(&mm->mm_vx_info, current->vx_info); return mm; } free_mm(mm); --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -363,6 +369,7 @@ void fastcall __mmdrop(struct mm_struct BUG_ON(mm == &init_mm); mm_free_pgd(mm); destroy_context(mm); + clr_vx_info(&mm->mm_vx_info); free_mm(mm); } --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -489,6 +496,7 @@ static int copy_mm(unsigned long clone_f /* Copy the current MM stuff.. */ memcpy(mm, oldmm, sizeof(*mm)); + mm->mm_vx_info = NULL; if (!mm_init(mm)) goto fail_nomem; --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -517,6 +525,7 @@ fail_nocontext: * If init_new_context() failed, we cannot use mmput() to free the mm * because it calls destroy_context() */ + clr_vx_info(&mm->mm_vx_info); mm_free_pgd(mm); free_mm(mm); return retval; --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -908,12 +921,30 @@ static task_t *copy_process(unsigned lon if (!p) goto fork_out; + init_vx_info(&p->vx_info, current->vx_info); + init_nx_info(&p->nx_info, current->nx_info); + + /* check vserver memory */ + if (p->mm && !(clone_flags & CLONE_VM)) { + if (vx_vmpages_avail(p->mm, p->mm->total_vm)) + vx_pages_add(p->mm->mm_vx_info, RLIMIT_AS, p->mm->total_vm); + else + goto bad_fork_free; + } + if (p->mm && vx_flags(VXF_FORK_RSS, 0)) { + if (!vx_rsspages_avail(p->mm, get_mm_counter(p->mm, rss))) + goto bad_fork_cleanup_vm; + } + retval = -EAGAIN; + if (!vx_nproc_avail(1)) + goto bad_fork_cleanup_vm; + if (atomic_read(&p->user->processes) >= p->signal->rlim[RLIMIT_NPROC].rlim_cur) { if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) && p->user != &root_user) - goto bad_fork_free; + goto bad_fork_cleanup_vm; } atomic_inc(&p->user->__count); --- linux-2.6.14/kernel/fork.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/kernel/fork.c 2005-10-30 04:29:36 +0100 @@ -1193,6 +1236,9 @@ bad_fork_cleanup_count: put_group_info(p->group_info); atomic_dec(&p->user->processes); free_uid(p->user); +bad_fork_cleanup_vm: + if (p->mm && !(clone_flags & CLONE_VM)) + vx_pages_sub(p->mm->mm_vx_info, RLIMIT_AS, p->mm->total_vm); bad_fork_free: free_task(p); goto fork_out; --- linux-2.6.14/mm/fremap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/fremap.c 2005-10-29 04:33:06 +0200 @@ -67,6 +68,9 @@ int install_page(struct mm_struct *mm, s pgd = pgd_offset(mm, addr); spin_lock(&mm->page_table_lock); + + if (!vx_rsspages_avail(mm, 1)) + goto err_unlock; pud = pud_alloc(mm, pgd, addr); if (!pud) --- linux-2.6.14/mm/memory.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/memory.c 2005-10-29 04:33:06 +0200 @@ -1694,6 +1694,10 @@ static int do_swap_page(struct mm_struct grab_swap_token(); } + if (!vx_rsspages_avail(mm, 1)) { + ret = VM_FAULT_OOM; + goto out; + } mark_page_accessed(page); lock_page(page); --- linux-2.6.14/mm/memory.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/memory.c 2005-10-29 04:33:06 +0200 @@ -1775,6 +1779,8 @@ do_anonymous_page(struct mm_struct *mm, pte_unmap(page_table); spin_unlock(&mm->page_table_lock); + if (!vx_rsspages_avail(mm, 1)) + goto no_mem; if (unlikely(anon_vma_prepare(vma))) goto no_mem; page = alloc_zeroed_user_highpage(vma, addr); --- linux-2.6.14/mm/memory.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/memory.c 2005-10-29 04:33:06 +0200 @@ -1848,6 +1854,9 @@ do_no_page(struct mm_struct *mm, struct } retry: cond_resched(); + /* FIXME: is that check useful here? */ + if (!vx_rsspages_avail(mm, 1)) + return VM_FAULT_OOM; new_page = vma->vm_ops->nopage(vma, address & PAGE_MASK, &ret); /* * No smp_rmb is needed here as long as there's a full --- linux-2.6.14/mm/mlock.c 2005-06-22 02:38:53 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mlock.c 2005-10-29 04:33:06 +0200 @@ -64,7 +65,7 @@ success: ret = make_pages_present(start, end); } - vma->vm_mm->locked_vm -= pages; + vx_vmlocked_sub(vma->vm_mm, pages); out: if (ret == -ENOMEM) ret = -EAGAIN; --- linux-2.6.14/mm/mlock.c 2005-06-22 02:38:53 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mlock.c 2005-10-29 04:33:06 +0200 @@ -122,7 +123,7 @@ static int do_mlock(unsigned long start, asmlinkage long sys_mlock(unsigned long start, size_t len) { - unsigned long locked; + unsigned long locked, grow; unsigned long lock_limit; int error = -ENOMEM; --- linux-2.6.14/mm/mlock.c 2005-06-22 02:38:53 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mlock.c 2005-10-29 04:33:06 +0200 @@ -133,8 +134,10 @@ asmlinkage long sys_mlock(unsigned long len = PAGE_ALIGN(len + (start & ~PAGE_MASK)); start &= PAGE_MASK; - locked = len >> PAGE_SHIFT; - locked += current->mm->locked_vm; + grow = len >> PAGE_SHIFT; + if (!vx_vmlocked_avail(current->mm, grow)) + goto out; + locked = current->mm->locked_vm + grow; lock_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur; lock_limit >>= PAGE_SHIFT; --- linux-2.6.14/mm/mlock.c 2005-06-22 02:38:53 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mlock.c 2005-10-29 04:33:06 +0200 @@ -142,6 +145,7 @@ asmlinkage long sys_mlock(unsigned long /* check against resource limits */ if ((locked <= lock_limit) || capable(CAP_IPC_LOCK)) error = do_mlock(start, len, 1); +out: up_write(¤t->mm->mmap_sem); return error; } --- linux-2.6.14/mm/mlock.c 2005-06-22 02:38:53 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mlock.c 2005-10-29 04:33:06 +0200 @@ -201,6 +205,8 @@ asmlinkage long sys_mlockall(int flags) lock_limit >>= PAGE_SHIFT; ret = -ENOMEM; + if (!vx_vmlocked_avail(current->mm, current->mm->total_vm)) + goto out; if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) || capable(CAP_IPC_LOCK)) ret = do_mlockall(flags); --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1109,10 +1109,10 @@ munmap_back: kmem_cache_free(vm_area_cachep, vma); } out: - mm->total_vm += len >> PAGE_SHIFT; + vx_vmpages_add(mm, len >> PAGE_SHIFT); __vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT); if (vm_flags & VM_LOCKED) { - mm->locked_vm += len >> PAGE_SHIFT; + vx_vmlocked_add(mm, len >> PAGE_SHIFT); make_pages_present(addr, addr + len); } if (flags & MAP_POPULATE) { --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1472,9 +1472,9 @@ static int acct_stack_growth(struct vm_a return -ENOMEM; /* Ok, everything looks good - let it rip */ - mm->total_vm += grow; + vx_vmpages_add(mm, grow); if (vma->vm_flags & VM_LOCKED) - mm->locked_vm += grow; + vx_vmlocked_add(mm, grow); __vm_stat_account(mm, vma->vm_flags, vma->vm_file, grow); return 0; } --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1614,9 +1614,10 @@ static void unmap_vma(struct mm_struct * { size_t len = area->vm_end - area->vm_start; - area->vm_mm->total_vm -= len >> PAGE_SHIFT; + vx_vmpages_sub(area->vm_mm, len >> PAGE_SHIFT); + if (area->vm_flags & VM_LOCKED) - area->vm_mm->locked_vm -= len >> PAGE_SHIFT; + vx_vmlocked_sub(area->vm_mm, len >> PAGE_SHIFT); vm_stat_unaccount(area); remove_vm_struct(area); } --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1860,6 +1861,8 @@ unsigned long do_brk(unsigned long addr, lock_limit >>= PAGE_SHIFT; if (locked > lock_limit && !capable(CAP_IPC_LOCK)) return -EAGAIN; + if (!vx_vmlocked_avail(mm, len >> PAGE_SHIFT)) + return -ENOMEM; } /* --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1886,7 +1889,8 @@ unsigned long do_brk(unsigned long addr, if (mm->map_count > sysctl_max_map_count) return -ENOMEM; - if (security_vm_enough_memory(len >> PAGE_SHIFT)) + if (security_vm_enough_memory(len >> PAGE_SHIFT) || + !vx_vmpages_avail(mm, len >> PAGE_SHIFT)) return -ENOMEM; flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags; --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1914,9 +1918,9 @@ unsigned long do_brk(unsigned long addr, vma->vm_page_prot = protection_map[flags & 0x0f]; vma_link(mm, vma, prev, rb_link, rb_parent); out: - mm->total_vm += len >> PAGE_SHIFT; + vx_vmpages_add(mm, len >> PAGE_SHIFT); if (flags & VM_LOCKED) { - mm->locked_vm += len >> PAGE_SHIFT; + vx_vmlocked_add(mm, len >> PAGE_SHIFT); make_pages_present(addr, addr + len); } return addr; --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1947,8 +1951,8 @@ void exit_mmap(struct mm_struct *mm) mm->mmap = mm->mmap_cache = NULL; mm->mm_rb = RB_ROOT; set_mm_counter(mm, rss, 0); - mm->total_vm = 0; - mm->locked_vm = 0; + vx_vmpages_sub(mm, mm->total_vm); + vx_vmlocked_sub(mm, mm->locked_vm); spin_unlock(&mm->page_table_lock); --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -1994,7 +1998,8 @@ int insert_vm_struct(struct mm_struct * if (__vma && __vma->vm_start < vma->vm_end) return -ENOMEM; if ((vma->vm_flags & VM_ACCOUNT) && - security_vm_enough_memory(vma_pages(vma))) + (security_vm_enough_memory(vma_pages(vma)) || + !vx_vmpages_avail(mm, vma_pages(vma)))) return -ENOMEM; vma_link(mm, vma, prev, rb_link, rb_parent); return 0; --- linux-2.6.14/mm/mmap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mmap.c 2005-10-30 02:48:41 +0100 @@ -2067,5 +2072,7 @@ int may_expand_vm(struct mm_struct *mm, if (cur + npages > lim) return 0; + if (!vx_vmpages_avail(mm, npages)) + return 0; return 1; } --- linux-2.6.14/mm/mremap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mremap.c 2005-10-29 04:33:06 +0200 @@ -232,7 +233,7 @@ static unsigned long move_vma(struct vm_ * if we failed to move page tables we still do total_vm increment * since do_munmap() will decrement it by old_len == new_len */ - mm->total_vm += new_len >> PAGE_SHIFT; + vx_vmpages_add(mm, new_len >> PAGE_SHIFT); __vm_stat_account(mm, vma->vm_flags, vma->vm_file, new_len>>PAGE_SHIFT); if (do_munmap(mm, old_addr, old_len) < 0) { --- linux-2.6.14/mm/mremap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mremap.c 2005-10-29 04:33:06 +0200 @@ -249,7 +250,7 @@ static unsigned long move_vma(struct vm_ } if (vm_flags & VM_LOCKED) { - mm->locked_vm += new_len >> PAGE_SHIFT; + vx_vmlocked_add(mm, new_len >> PAGE_SHIFT); if (new_len > old_len) make_pages_present(new_addr + old_len, new_addr + new_len); --- linux-2.6.14/mm/mremap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mremap.c 2005-10-29 04:33:06 +0200 @@ -355,6 +356,9 @@ unsigned long do_mremap(unsigned long ad ret = -EAGAIN; if (locked > lock_limit && !capable(CAP_IPC_LOCK)) goto out; + if (!vx_vmlocked_avail(current->mm, + (new_len - old_len) >> PAGE_SHIFT)) + goto out; } if (!may_expand_vm(current->mm, (new_len - old_len) >> PAGE_SHIFT)) { ret = -ENOMEM; --- linux-2.6.14/mm/mremap.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/mremap.c 2005-10-29 04:33:06 +0200 @@ -383,11 +387,11 @@ unsigned long do_mremap(unsigned long ad vma_adjust(vma, vma->vm_start, addr + new_len, vma->vm_pgoff, NULL); - current->mm->total_vm += pages; + vx_vmpages_add(current->mm, pages); __vm_stat_account(vma->vm_mm, vma->vm_flags, vma->vm_file, pages); if (vma->vm_flags & VM_LOCKED) { - current->mm->locked_vm += pages; + vx_vmlocked_add(vma->vm_mm, pages); make_pages_present(addr + old_len, addr + new_len); } --- linux-2.6.14/mm/nommu.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/nommu.c 2005-10-29 04:33:06 +0200 @@ -816,7 +816,7 @@ unsigned long do_mmap_pgoff(struct file realalloc += kobjsize(vma); askedalloc += sizeof(*vma); - current->mm->total_vm += len >> PAGE_SHIFT; + vx_vmpages_add(current->mm, len >> PAGE_SHIFT); add_nommu_vma(vma); --- linux-2.6.14/mm/nommu.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/nommu.c 2005-10-29 04:33:06 +0200 @@ -931,7 +931,7 @@ int do_munmap(struct mm_struct *mm, unsi realalloc -= kobjsize(vml); askedalloc -= sizeof(*vml); kfree(vml); - mm->total_vm -= len >> PAGE_SHIFT; + vx_vmpages_sub(mm, len >> PAGE_SHIFT); #ifdef DEBUG show_process_blocks(); --- linux-2.6.14/mm/nommu.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/nommu.c 2005-10-29 04:33:06 +0200 @@ -950,7 +950,7 @@ void exit_mmap(struct mm_struct * mm) printk("Exit_mmap:\n"); #endif - mm->total_vm = 0; + vx_vmpages_sub(mm, mm->total_vm); while ((tmp = mm->context.vmlist)) { mm->context.vmlist = tmp->next; --- linux-2.6.14/mm/oom_kill.c 2005-10-28 20:49:57 +0200 +++ linux-2.6.14-vs2.0.1-pre3/mm/oom_kill.c 2005-10-29 04:33:06 +0200 @@ -55,6 +55,7 @@ unsigned long badness(struct task_struct * The memory size of the process is the basis for the badness. */ points = p->mm->total_vm; + /* FIXME add vserver badness ;) */ /* * Processes which fork a lot of child processes are likely