archive mirror
 help / color / mirror / Atom feed
Cc: (Chris Higgins)
Subject: PATCH: kernel/sched.c - Optimisation of some variable assignments
Date: Mon, 05 Mar 2001 10:06:15 +0000	[thread overview]
Message-ID: <> (raw)

I was reading through sched.c and noticed two places where variable
assignments occur immediately prior to 'if(test) goto label:' statements.
If the test is TRUE, then the jump happens and in both cases the
variables are either not used, or immediately over-written..

So I've re-sequenced the two sets of statements to 'test then assign'
rather than 'assign regardless, then test'.

I presume that the C compiler is optimising this out, but not all 
platforms may been seeing this... It's probably only going to save
a couple of cycles on any iteration through the scheduler, but
the more available for everyone else the better :)

--- kernel/sched.c.orig Fri Feb  9 19:37:03 2001
+++ kernel/sched.c      Sun Mar  4 20:27:42 2001
@@ -507,11 +507,11 @@
        if (!current->active_mm) BUG();
+       if (in_interrupt())
+               goto scheduling_in_interrupt;
        prev = current;
        this_cpu = prev->processor;
-       if (in_interrupt())
-               goto scheduling_in_interrupt;
        release_kernel_lock(prev, this_cpu);
@@ -553,10 +553,10 @@
         * Default process to select..
-       next = idle_task(this_cpu);
-       c = -1000;
        if (prev->state == TASK_RUNNING)
                goto still_running;
+       next = idle_task(this_cpu);
+       c = -1000;
        list_for_each(tmp, &runqueue_head) {


** Chris Higgins                         e: chris.higgins at **
** Technical Business Development        tel: +353-1-6204916            **
** Horizon Technology Group              fax: +353-1-6204949            **

                 reply	other threads:[~2001-03-05 10:21 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \
    --subject='Re: PATCH: kernel/sched.c - Optimisation of some variable assignments' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).