Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: Ralf Baechle <ralf@linux-mips.org>
To: Andrew Clausen <clausen@melbourne.sgi.com>
Cc: Linux-MIPS <linux-mips@linux-mips.org>
Subject: Re: weirdness in bootmem_init(), arch/mips64/kernel/setup.c
Date: Tue, 18 Feb 2003 11:42:44 +0100	[thread overview]
Message-ID: <20030218114244.B25047@linux-mips.org> (raw)
In-Reply-To: <20030218065427.GA915@pureza.melbourne.sgi.com>; from clausen@melbourne.sgi.com on Tue, Feb 18, 2003 at 05:54:27PM +1100

On Tue, Feb 18, 2003 at 05:54:27PM +1100, Andrew Clausen wrote:

> This code isn't really relevant to what I'm working on (it isn't compiled
> in to kernels for the ip27), but I just noticed it, and it looks broken:
> 
>         /* Find the highest page frame number we have available.  */
>         max_pfn = 0;
>         for (i = 0; i < boot_mem_map.nr_map; i++) {
>                 unsigned long start, end;
> 
>                 if (boot_mem_map.map[i].type != BOOT_MEM_RAM)
>                         continue;
> 
> *****           start = PFN_UP(boot_mem_map.map[i].addr);
> *****           end = PFN_DOWN(boot_mem_map.map[i].addr
>                       + boot_mem_map.map[i].size);
> 
> *****           if (start >= end)
>                         continue;
>                 if (end > max_pfn)
>                         max_pfn = end;
>         }
> 
> 
> That test looks like it will always succeed... and it looks like the
> author wanted it to be a sanity check.

> Why all this business with PFN_UP and PFN_DOWN?  (They are bit
> shifts... PFN_UP shifts left, PFN_DOWN shifts right)

Read again.  PFN_PHYS is shifting left, the others shift right.

Mm is based on complete pages and page numbers.  This code simply discards
partial pages before initializing mm with the list of available memory.
The case start > end cannot happen but start = end is possible for small
areas near the end of a page - but such an area is not usable for mm so
it's ignored.

  Ralf

  parent reply	other threads:[~2003-02-18 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-02-18  6:54 weirdness in bootmem_init(), arch/mips64/kernel/setup.c Andrew Clausen
2003-02-18 10:27 ` Juan Quintela
2003-02-18 10:33   ` Ralf Baechle
2003-02-18 10:42 ` Ralf Baechle [this message]
2003-02-18 22:29   ` Andrew Clausen

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=20030218114244.B25047@linux-mips.org \
    --to=ralf@linux-mips.org \
    --cc=clausen@melbourne.sgi.com \
    --cc=linux-mips@linux-mips.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