Merge to Fedora kernel-2.6.7-1.441
[linux-2.6.git] / kernel / fork.c
index e0d588e..5edc154 100644 (file)
 #include <linux/mount.h>
 #include <linux/audit.h>
 #include <linux/rmap.h>
-#include <linux/vinline.h>
-#include <linux/ninline.h>
+
+#include <linux/vs_network.h>
+#include <linux/vs_memory.h>
+#include <linux/vs_limit.h>
+#include <linux/vs_base.h>
+
 #include <linux/ckrm.h>
 #include <linux/ckrm_tsk.h>
 
@@ -279,7 +283,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
        struct vm_area_struct * mpnt, *tmp, **pprev;
        struct rb_node **rb_link, *rb_parent;
        int retval;
-       unsigned long charge = 0;
+       unsigned long charge;
        struct mempolicy *pol;
 
        down_write(&oldmm->mmap_sem);
@@ -312,11 +316,12 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
 
                if(mpnt->vm_flags & VM_DONTCOPY)
                        continue;
+               charge = 0;
                if (mpnt->vm_flags & VM_ACCOUNT) {
                        unsigned int len = (mpnt->vm_end - mpnt->vm_start) >> PAGE_SHIFT;
                        if (security_vm_enough_memory(len))
                                goto fail_nomem;
-                       charge += len;
+                       charge = len;
                }
                tmp = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
                if (!tmp)
@@ -368,7 +373,7 @@ static inline int dup_mmap(struct mm_struct * mm, struct mm_struct * oldmm)
                        tmp->vm_ops->open(tmp);
 
                if (retval)
-                       goto fail;
+                       goto out;
        }
        retval = 0;
 
@@ -380,10 +385,10 @@ fail_nomem_policy:
        kmem_cache_free(vm_area_cachep, tmp);
 fail_nomem:
        retval = -ENOMEM;
-fail:
        vm_unacct_memory(charge);
        goto out;
 }
+
 static inline int mm_alloc_pgd(struct mm_struct * mm)
 {
        mm->pgd = pgd_alloc(mm);
@@ -529,7 +534,7 @@ void mm_release(struct task_struct *tsk, struct mm_struct *mm)
                 * not set up a proper pointer then tough luck.
                 */
                put_user(0, tidptr);
-               sys_futex(tidptr, FUTEX_WAKE, 1, NULL, NULL);
+               sys_futex(tidptr, FUTEX_WAKE, 1, NULL, NULL, 0);
        }
 }
 
@@ -935,10 +940,8 @@ struct task_struct *copy_process(unsigned long clone_flags,
        }
 
        retval = -EAGAIN;
-       vxi = current->vx_info;
-       if (vxi && (atomic_read(&vxi->limit.res[RLIMIT_NPROC])
-               >= vxi->limit.rlim[RLIMIT_NPROC]))
-               goto bad_fork_free;
+        if (!vx_nproc_avail(1))
+                goto bad_fork_free;
 
        if (atomic_read(&p->user->processes) >=
                        p->rlim[RLIMIT_NPROC].rlim_cur) {
@@ -1132,10 +1135,12 @@ struct task_struct *copy_process(unsigned long clone_flags,
                link_pid(p, p->pids + PIDTYPE_TGID, &p->group_leader->pids[PIDTYPE_TGID].pid);
 
        nr_threads++;
+       vxi = current->vx_info;
        if (vxi) {
                atomic_inc(&vxi->cacct.nr_threads);
-               atomic_inc(&vxi->limit.res[RLIMIT_NPROC]);
+               // atomic_inc(&vxi->limit.res[RLIMIT_NPROC]);
        }
+       vx_nproc_inc();
        write_unlock_irq(&tasklist_lock);
        retval = 0;