lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <200704101716.14372.dmitry.adamushko@gmail.com>
Date:	Tue, 10 Apr 2007 17:16:13 +0200
From:	Dmitry Adamushko <dmitry.adamushko@...il.com>
To:	"Con Kolivas" <kernel@...ivas.org>,
	"Andrew Morton" <akpm@...ux-foundation.org>
Cc:	"Linux Kernel" <linux-kernel@...r.kernel.org>
Subject: [PATCH 2.6.21-rc6-mm1] SD sched: avoid redundant reschedule in set_user_nice()


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 <dmitry.adamushko@...il.com>

---

--- 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 majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ