[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20090811090554.79a1b1ac@bike.lwn.net>
Date: Tue, 11 Aug 2009 09:05:54 -0600
From: Jonathan Corbet <corbet@....net>
To: "B.Vinai Kumar" <vinaibangala2001@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: Re: How to get the address of the page structure from the given
virtual address?
On Tue, 11 Aug 2009 20:01:41 +0530
"B.Vinai Kumar" <vinaibangala2001@...il.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists