Hello,

This change seems to be pretty logical. OTOH, it's just a micro-optimization.
So there is no hurry and we may wait till Con is back (Andrew, if you think 
it'd be better).

Logically-wise, this is similar to the changes I have sent earlier for the 
mainline.

There is no need to change TASK_PREEMPTS_CURR() here. All the infrastructure is 
already in place
(task_preempts_curr() already does the necessary checks). And nevertheless, 
set_user_nice() can be made
nicer. So that's what this patch is about.

---

Call for reschedule upon increasing a task's priority in set_user_nice() only
if the task may preempt the current one.


Signed-off-by: Dmitry Adamushko <[EMAIL PROTECTED]>

---

--- linux-2.6.21-rc6-mm1/kernel/sched-orig.c    2007-04-09 10:10:52.000000000 
+0200
+++ linux-2.6.21-rc6-mm1/kernel/sched.c 2007-04-09 17:07:12.000000000 +0200
@@ -4022,14 +4022,14 @@ EXPORT_SYMBOL(sleep_on_timeout);
 void rt_mutex_setprio(struct task_struct *p, int prio)
 {
        unsigned long flags;
-       int queued, oldprio;
+       int queued, delta;
        struct rq *rq;
 
        BUG_ON(prio < 0 || prio > MAX_PRIO);
 
        rq = task_rq_lock(p, &flags);
 
-       oldprio = p->prio;
+       delta = prio - p->prio;
        queued = task_queued(p);
        if (queued)
                dequeue_task(p, rq);
@@ -4043,7 +4043,7 @@ void rt_mutex_setprio(struct task_struct
                 * this runqueue and our priority is higher than the current's
                 */
                if (task_running(rq, p)) {
-                       if (p->prio > oldprio)
+                       if (delta > 0)
                                resched_task(rq->curr);
                } else
                        try_preempt(p, rq);
@@ -4055,7 +4055,7 @@ void rt_mutex_setprio(struct task_struct
 
 void set_user_nice(struct task_struct *p, long nice)
 {
-       int queued, old_prio,delta;
+       int queued, old_prio, delta;
        unsigned long flags;
        struct rq *rq;
 
@@ -4096,8 +4096,11 @@ void set_user_nice(struct task_struct *p
                 * If the task increased its priority or is running and
                 * lowered its priority, then reschedule its CPU:
                 */
-               if (delta < 0 || (delta > 0 && task_running(rq, p)))
-                       resched_task(rq->curr);
+               if (task_running(rq, p)) {
+                       if (delta > 0)
+                               resched_task(rq->curr);
+               } else
+                       try_preempt(p, rq);
        }
 out_unlock:
        task_rq_unlock(rq, &flags);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to