* How to get the address of the page structure from the given virtual address?
@ 2009-08-11 14:31 B.Vinai Kumar
2009-08-11 15:05 ` Jonathan Corbet
0 siblings, 1 reply; 3+ messages in thread
From: B.Vinai Kumar @ 2009-08-11 14:31 UTC (permalink / raw)
To: linux-kernel
Hi List
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?
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. Is there any method which
retrives the address of the page structure?
Thanks,
Vinai.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to get the address of the page structure from the given virtual address?
2009-08-11 14:31 How to get the address of the page structure from the given virtual address? B.Vinai Kumar
@ 2009-08-11 15:05 ` Jonathan Corbet
2009-08-12 4:58 ` B.Vinai Kumar
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Corbet @ 2009-08-11 15:05 UTC (permalink / raw)
To: B.Vinai Kumar; +Cc: linux-kernel
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: How to get the address of the page structure from the given virtual address?
2009-08-11 15:05 ` Jonathan Corbet
@ 2009-08-12 4:58 ` B.Vinai Kumar
0 siblings, 0 replies; 3+ messages in thread
From: B.Vinai Kumar @ 2009-08-12 4:58 UTC (permalink / raw)
To: Jonathan Corbet, linux-kernel
Hi Jon,
Thanks for your response.
I'am writing a kernel socket which calls the tcp_sendpage (modified to
take array of pages) to send the data out
of the kernel socket. I'am allocating 32K of data by calling
alloc_pages and want to send this 32K of data. I modified the
tcp_sendpages to take an array of page structures.
Original version takes pointer to single page structure as an argument.
I will use the above calls to get the address of the page structure
and let you know.
Thanks
Vinai.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-08-12 4:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-11 14:31 How to get the address of the page structure from the given virtual address? B.Vinai Kumar
2009-08-11 15:05 ` Jonathan Corbet
2009-08-12 4:58 ` B.Vinai Kumar
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®