linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sched.c
@ 2002-08-27 18:15 Lahti Oy
  2002-08-27 18:33 ` Willy Tarreau
  2002-08-27 18:35 ` Andrew Morton
  0 siblings, 2 replies; 11+ messages in thread
From: Lahti Oy @ 2002-08-27 18:15 UTC (permalink / raw)
  To: linux-kernel

Small patch that makes NR_CPUS loops decrement from 31 to 0 in sched.c to
squeeze out some cycles (of course only on SMP machines). Also deprecated a
macro that was only used once in the code and changed one if-conditional to
else if.

If everyone agrees, do I need to post the patch to someone or will it be
picked from the list?

Furthermore, there are probably many other juicy spots in the kernel where
decrementing loops could be applied. Is there a reason for not doing so at
the moment?

--- sched.c.orig Tue Aug 27 08:32:38 2002
+++ sched.c Tue Aug 27 08:32:38 2002
@@ -161,7 +161,6 @@
 #define cpu_rq(cpu)  (runqueues + (cpu))
 #define this_rq()  cpu_rq(smp_processor_id())
 #define task_rq(p)  cpu_rq(task_cpu(p))
-#define cpu_curr(cpu)  (cpu_rq(cpu)->curr)
 #define rt_task(p)  ((p)->prio < MAX_RT_PRIO)

 /*
@@ -543,7 +542,7 @@
 {
  unsigned long i, sum = 0;

- for (i = 0; i < NR_CPUS; i++)
+ for (i = NR_CPUS; i; i--)
   sum += cpu_rq(i)->nr_running;

  return sum;
@@ -553,7 +552,7 @@
 {
  unsigned long i, sum = 0;

- for (i = 0; i < NR_CPUS; i++)
+ for (i = NR_CPUS; i; i--)
   sum += cpu_rq(i)->nr_uninterruptible;

  return sum;
@@ -563,7 +562,7 @@
 {
  unsigned long i, sum = 0;

- for (i = 0; i < NR_CPUS; i++)
+ for (i = NR_CPUS; i; i--)
   sum += cpu_rq(i)->nr_switches;

  return sum;
@@ -667,7 +666,7 @@

  busiest = NULL;
  max_load = 1;
- for (i = 0; i < NR_CPUS; i++) {
+ for (i = NR_CPUS; i; i--) {
   if (!cpu_online(i))
    continue;

@@ -1297,7 +1296,7 @@
   if (increment < -40)
    increment = -40;
  }
- if (increment > 40)
+ else if (increment > 40)
   increment = 40;

  nice = PRIO_TO_NICE(current->static_prio) + increment;
@@ -1344,7 +1343,7 @@
  */
 int idle_cpu(int cpu)
 {
- return cpu_curr(cpu) == cpu_rq(cpu)->idle;
+ return cpu_rq(cpu)->curr == cpu_rq(cpu)->idle;
 }

 /**
@@ -2081,7 +2080,7 @@
  runqueue_t *rq;
  int i, j, k;

- for (i = 0; i < NR_CPUS; i++) {
+ for (i = NR_CPUS; i; i--) {
   prio_array_t *array;

   rq = cpu_rq(i);


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2002-08-28 13:40 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-27 18:15 [PATCH] sched.c Lahti Oy
2002-08-27 18:33 ` Willy Tarreau
2002-08-27 18:35 ` Andrew Morton
2002-08-28  0:13   ` Daniel Phillips
2002-08-28  0:41     ` Andreas Dilger
2002-08-28  0:51       ` Daniel Phillips
2002-08-28  0:44     ` Stephen C. Biggs
2002-08-28  0:47     ` Daniel Phillips
2002-08-28  0:59       ` Stephen C. Biggs
2002-08-28 13:45         ` Thunder from the hill
2002-08-28  6:47   ` Rusty Russell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).