]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - fs/proc/base.c
oom: move oom_adj value from task_struct to signal_struct
[net-next-2.6.git] / fs / proc / base.c
index 6f742f6658a9897503568c3ea7b78407829e760f..81cfff82875bd127b00f7b7faa238bb7c2b71c4e 100644 (file)
@@ -999,11 +999,17 @@ static ssize_t oom_adjust_read(struct file *file, char __user *buf,
        struct task_struct *task = get_proc_task(file->f_path.dentry->d_inode);
        char buffer[PROC_NUMBUF];
        size_t len;
-       int oom_adjust;
+       int oom_adjust = OOM_DISABLE;
+       unsigned long flags;
 
        if (!task)
                return -ESRCH;
-       oom_adjust = task->oomkilladj;
+
+       if (lock_task_sighand(task, &flags)) {
+               oom_adjust = task->signal->oom_adj;
+               unlock_task_sighand(task, &flags);
+       }
+
        put_task_struct(task);
 
        len = snprintf(buffer, sizeof(buffer), "%i\n", oom_adjust);
@@ -1017,6 +1023,7 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
        struct task_struct *task;
        char buffer[PROC_NUMBUF], *end;
        int oom_adjust;
+       unsigned long flags;
 
        memset(buffer, 0, sizeof(buffer));
        if (count > sizeof(buffer) - 1)
@@ -1032,11 +1039,20 @@ static ssize_t oom_adjust_write(struct file *file, const char __user *buf,
        task = get_proc_task(file->f_path.dentry->d_inode);
        if (!task)
                return -ESRCH;
-       if (oom_adjust < task->oomkilladj && !capable(CAP_SYS_RESOURCE)) {
+       if (!lock_task_sighand(task, &flags)) {
+               put_task_struct(task);
+               return -ESRCH;
+       }
+
+       if (oom_adjust < task->signal->oom_adj && !capable(CAP_SYS_RESOURCE)) {
+               unlock_task_sighand(task, &flags);
                put_task_struct(task);
                return -EACCES;
        }
-       task->oomkilladj = oom_adjust;
+
+       task->signal->oom_adj = oom_adjust;
+
+       unlock_task_sighand(task, &flags);
        put_task_struct(task);
        if (end - buffer == 0)
                return -EIO;