From: Jonathan Corbet <corbet@lwn.net>
To: "B.Vinai Kumar" <vinaibangala2001@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to get the address of the page structure from the given virtual address?
Date: Tue, 11 Aug 2009 09:05:54 -0600 [thread overview]
Message-ID: <20090811090554.79a1b1ac@bike.lwn.net> (raw)
In-Reply-To: <f74c922b0908110731ifcf162ai8770f07d7ca537d3@mail.gmail.com>
On Tue, 11 Aug 2009 20:01:41 +0530
"B.Vinai Kumar" <vinaibangala2001@gmail.com> wrote:
> 1) I allocated 8 pages using alloc_pages(GFP_KERNEL, 3). This function
> returns the pointer to the first page's page structure.
> How can I get the page structure address of the remaining 7 pages?
They will be immediately following the first page structure in the
system memory map - they are contiguous pages, after all. So just use
pointer arithmetic to find them.
Inquiring minds are indeed curious as to why you need them, though :)
>
> 2) There is a function page_address() which takes the page structure
> as an argument and returns the virtual address of the page
> that is pointed by that page structure.
Note that page_address() may not give you a valid address if it's a
high-memory page which is not currently mapped.
> Is there any method which
> retrives the address of the page structure?
Use virt_to_page() for normal kernel virtual addresses,
vmalloc_to_page() for memory in the vmalloc range.
jon
next prev parent reply other threads:[~2009-08-11 15:08 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-11 14:31 B.Vinai Kumar
2009-08-11 15:05 ` Jonathan Corbet [this message]
2009-08-12 4:58 ` B.Vinai Kumar
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=20090811090554.79a1b1ac@bike.lwn.net \
--to=corbet@lwn.net \
--cc=linux-kernel@vger.kernel.org \
--cc=vinaibangala2001@gmail.com \
/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®