linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Michael Ellerman <michael@ellerman.id.au>
To: Siva Prasad <sprasad@bivio.net>
Cc: linuxppc-dev@ozlabs.org, linuxppc-embedded@ozlabs.org
Subject: Re: lmb_remove_region - bad decrementing...
Date: Tue, 20 Mar 2007 17:12:30 +1100	[thread overview]
Message-ID: <1174371150.10827.17.camel@concordia.ozlabs.ibm.com> (raw)
In-Reply-To: <D83235F0F3C86D4D889D8B9A0DA8C6D746E786@corpexc01.corp.networkrobots.com>

[-- Attachment #1: Type: text/plain, Size: 1737 bytes --]

On Mon, 2007-03-19 at 13:00 -0700, Siva Prasad wrote:
> Hi,
> 
> This is based on 2.6.19 kernel.
> 
> In the file mm/lmb.c, we have function lmb_remove_region. In this
> function we are decrementing the region count even if the condition
> fails and we don't necessarily remove the region.
> 
> For example ...
> 
> static void __init lmb_remove_region(struct lmb_region *rgn, unsigned
> long r)
> {
>         unsigned long i;
> 
>         for (i = r; i < rgn->cnt - 1; i++) {
>                 rgn->region[i].base = rgn->region[i + 1].base;
>                 rgn->region[i].size = rgn->region[i + 1].size;
>         }
>         rgn->cnt--;
> }
> 
> Shound't the region count be decremented only if r > rgn->cnt -1. When
> we initially setup lmb, cnt will be 1, and as part of other functions,
> this gets called with out even increasing this number. So, region does
> not get removed, but cnt does get decremented by 1.
> 
> At least a quick fix like this "if (rgn->cnt > 1) rgn->cnt--;" should
> serve for now.
> 
> Same thing happens at routine lmb_enfore_memory_limit. Actually
> lmb_remove_region gets called from here and the problem starts. So, "i"
> should not be decremented here, if the initial condition fails.
> 
> What do you guys think?

I agree that's a bug in lmb_remove_region(), but I can't see how it's
ever triggered.

I can't see how lmb_enforce_memory_limit() would hit the bug either. Can
you give more detail?

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

      reply	other threads:[~2007-03-20  6:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-19 20:00 lmb_remove_region - bad decrementing Siva Prasad
2007-03-20  6:12 ` Michael Ellerman [this message]

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=1174371150.10827.17.camel@concordia.ozlabs.ibm.com \
    --to=michael@ellerman.id.au \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=linuxppc-embedded@ozlabs.org \
    --cc=sprasad@bivio.net \
    /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).