linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ricardo Nabinger Sanchez <rnsanchez@terra.com.br>
To: linux-kernel@vger.kernel.org
Cc: Frank.Cornelis@elis.ugent.be
Subject: Re: [PATCH] sched: CPU_THRESHOLD
Date: Sat, 23 Aug 2003 19:57:40 -0300	[thread overview]
Message-ID: <20030823195740.7133874d.rnsanchez@terra.com.br> (raw)

hello Frank,

> -	*imbalance = (max_load - nr_running) / 2;
> +	*imbalance = (max_load - nr_running) >> 1;

I think it is a good coding practice to keep things human-readable. 
In this code snippet, the division by 2 is quickly understood by most
readers (specially those who didn't write it).  The right shift may
obfuscate the real meaning of this operation, which is a single
division by 2, not a bit-oriented expression.

Assuming that sched.c will be compiled with optimizations enabled, the
compiler will change the human-readable division by a fast machine
right shift operation, whenever possible (gcc surely will).

Thus, we keep the kernel code more readable, and sometimes let the
compiler apply newer (and hopefully faster) optimizations than some
tricks we have known as fastest available.

Regards, and please let me know what do you think about it.

-- 
Ricardo Nabinger Sanchez
GNU/Linux #140696 [http://counter.li.org]
Slackware Linux


             reply	other threads:[~2003-08-23 22:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-23 22:57 Ricardo Nabinger Sanchez [this message]
2003-08-25 17:12 ` [PATCH] sched: CPU_THRESHOLD Timothy Miller
  -- strict thread matches above, loose matches on Subject: below --
2003-08-22 12:43 Frank Cornelis

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=20030823195740.7133874d.rnsanchez@terra.com.br \
    --to=rnsanchez@terra.com.br \
    --cc=Frank.Cornelis@elis.ugent.be \
    --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).