From: Daniel Phillips <phillips@arcor.de>
To: Andreas Dilger <adilger@clusterfs.com>
Cc: Andrew Morton <akpm@zip.com.au>, Lahti Oy <rlahti@netikka.fi>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched.c
Date: Wed, 28 Aug 2002 02:51:52 +0200 [thread overview]
Message-ID: <E17jr3o-0002k1-00@starship> (raw)
In-Reply-To: <20020828004154.GS19435@clusterfs.com>
On Wednesday 28 August 2002 02:41, Andreas Dilger wrote:
> On Aug 28, 2002 02:13 +0200, Daniel Phillips wrote:
> > On Tuesday 27 August 2002 20:35, Andrew Morton wrote:
> > > Lahti Oy wrote:
> > > > - for (i = 0; i < NR_CPUS; i++)
> > > > + for (i = NR_CPUS; i; i--)
> > > > sum += cpu_rq(i)->nr_running;
> > >
> > > Off-by-one there. You'd want
> > >
> > > for (i = NR_CPUS; --i >= 0; )
> > >
> > > or something similarly foul ;)
> >
> > int i = NR_CPUS;
> >
> > while (--i)
^^^ i--
>
> Actually, I prefer the following to avoid wrap-around conditions in
> strange circumstances (i.e. if 'i' is manipulated between setting
> and the while loop):
>
> while (i-- > 0) {
> ...
> }
Hi Andreas,
If this counter goes negative you have other, much bigger problems
and you better not try to cover them up.
Daniel
next prev parent reply other threads:[~2002-08-28 0:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-27 18:15 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 [this message]
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=E17jr3o-0002k1-00@starship \
--to=phillips@arcor.de \
--cc=adilger@clusterfs.com \
--cc=akpm@zip.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=rlahti@netikka.fi \
/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
all inboxes | Powered by JetHome®