OSDN Git Service

Merge branch 'akpm' (patches from Andrew)
[uclinux-h8/linux.git] / kernel / sys.c
index 2450a9f..ecc4cf0 100644 (file)
@@ -220,7 +220,6 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
                niceval = MAX_NICE;
 
        rcu_read_lock();
-       read_lock(&tasklist_lock);
        switch (which) {
        case PRIO_PROCESS:
                if (who)
@@ -235,9 +234,11 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
                        pgrp = find_vpid(who);
                else
                        pgrp = task_pgrp(current);
+               read_lock(&tasklist_lock);
                do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
                        error = set_one_prio(p, niceval, error);
                } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
+               read_unlock(&tasklist_lock);
                break;
        case PRIO_USER:
                uid = make_kuid(cred->user_ns, who);
@@ -249,16 +250,15 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
                        if (!user)
                                goto out_unlock;        /* No processes for this user */
                }
-               do_each_thread(g, p) {
+               for_each_process_thread(g, p) {
                        if (uid_eq(task_uid(p), uid) && task_pid_vnr(p))
                                error = set_one_prio(p, niceval, error);
-               } while_each_thread(g, p);
+               }
                if (!uid_eq(uid, cred->uid))
                        free_uid(user);         /* For find_user() */
                break;
        }
 out_unlock:
-       read_unlock(&tasklist_lock);
        rcu_read_unlock();
 out:
        return error;
@@ -283,7 +283,6 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
                return -EINVAL;
 
        rcu_read_lock();
-       read_lock(&tasklist_lock);
        switch (which) {
        case PRIO_PROCESS:
                if (who)
@@ -301,11 +300,13 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
                        pgrp = find_vpid(who);
                else
                        pgrp = task_pgrp(current);
+               read_lock(&tasklist_lock);
                do_each_pid_thread(pgrp, PIDTYPE_PGID, p) {
                        niceval = nice_to_rlimit(task_nice(p));
                        if (niceval > retval)
                                retval = niceval;
                } while_each_pid_thread(pgrp, PIDTYPE_PGID, p);
+               read_unlock(&tasklist_lock);
                break;
        case PRIO_USER:
                uid = make_kuid(cred->user_ns, who);
@@ -317,19 +318,18 @@ SYSCALL_DEFINE2(getpriority, int, which, int, who)
                        if (!user)
                                goto out_unlock;        /* No processes for this user */
                }
-               do_each_thread(g, p) {
+               for_each_process_thread(g, p) {
                        if (uid_eq(task_uid(p), uid) && task_pid_vnr(p)) {
                                niceval = nice_to_rlimit(task_nice(p));
                                if (niceval > retval)
                                        retval = niceval;
                        }
-               } while_each_thread(g, p);
+               }
                if (!uid_eq(uid, cred->uid))
                        free_uid(user);         /* for find_user() */
                break;
        }
 out_unlock:
-       read_unlock(&tasklist_lock);
        rcu_read_unlock();
 
        return retval;