kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
From: tobias@gambas-buch.de (Tobias Boege)
To: kernelnewbies@lists.kernelnewbies.org
Subject: Clarifications on PFN_UP(x) macro
Date: Tue, 4 Jun 2013 14:34:07 +0200	[thread overview]
Message-ID: <20130604123407.GA535@aurora> (raw)
In-Reply-To: <CAOPDcRxwgZcvq9PKBiX-w_gqiqt+ZJqsQvuUPDL59nDUX+=04g@mail.gmail.com>

On Tue, 04 Jun 2013, stl wrote:
> Hello,
> I need some clarifications concerning the macro
> 
> #define PFN_UP(x)    (((x) + PAGE_SIZE-1) >> PAGE_SHIFT)
> 
> found in "pfn.h"
> 
> I suppose that its aim is to give the page frame number of the page
> following the page holding the physical address x, contrary to
> PFN_DOWN(x) which give the page frame number of the page holding the
> address x.
> 
> Assuming that the first page has the range 0x0000 to 0x0FFF,
> the second 0x1000 to 0x1FFF and so on, it seems that there is
> an issu with the starting address of each page, for example:
> x = 0x10000  (PFN number 10)
> 0x10000 + 0xFFF >> 12    =    10, but should be 11 no?
> 
> I certainly misunderstood something.
> Could someone clarify this point please?
> 

Your calculation is good. Your understanding of what the macro does is not.
You should understand the macro like "return the address of the next page
relative to this address" which includes the address as is if it is page-
aligned.

Regards,
Tobi

      reply	other threads:[~2013-06-04 12:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-04  8:41 Clarifications on PFN_UP(x) macro stl
2013-06-04 12:34 ` Tobias Boege [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=20130604123407.GA535@aurora \
    --to=tobias@gambas-buch.de \
    --cc=kernelnewbies@lists.kernelnewbies.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).