linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: chris.higgins@horizon.ie
To: linux-kernel@vger.kernel.org
Cc: chris.higgins@horizon.ie (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: <200103051006.f25A6FD06987@luggage.horizon.ie> (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();
 need_resched_back:
+       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;
 
 still_running_back:
        list_for_each(tmp, &runqueue_head) {


--END-OF-PATCH---


-- 
** Chris Higgins                         e: chris.higgins at horizon.ie **
** 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:
  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=200103051006.f25A6FD06987@luggage.horizon.ie \
    --to=chris.higgins@horizon.ie \
    --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;
as well as URLs for NNTP newsgroup(s).