From: "Lahti Oy" <rlahti@netikka.fi>
To: <linux-kernel@vger.kernel.org>
Subject: [PATCH] sched.c
Date: Tue, 27 Aug 2002 21:15:03 +0300 [thread overview]
Message-ID: <000b01c24df5$aacc7ed0$d20a5f0a@deldaran> (raw)
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);
next reply other threads:[~2002-08-27 18:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-27 18:15 Lahti Oy [this message]
2002-08-27 18:33 ` [PATCH] sched.c 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='000b01c24df5$aacc7ed0$d20a5f0a@deldaran' \
--to=rlahti@netikka.fi \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox