mapping address pointer to page structure

swathi suresh swathi.suresh07 at gmail.com
Wed Mar 30 00:47:13 EDT 2011


Hi Syed,

      Thanks for the response, in order to check whether the data is in page
or not, i tried printing the whole page data, i found that it is present in
the page,
so i calculate the offset at which the data is present by using
*(unsigned long) skb->data - (unsigned long) page_address(page)*
seem like it working but my question is will it work in all case.

So am using the following code

*.*
*.*
*struct page *page = virt_to_page(skb->data);*
*int offset = **(unsigned long) skb->data - (unsigned long)
page_address(page);*
*skb_add_rx_frag(master_skb, skb_shinfo(master_skb)->nr_frags, page, offset,
skb->len)*
*.*
*.*
*
*
is this the right way to do ?
i want to understand how the memory handling are happening in kernel,
can some one point me to right material.

Thank you,



On Wed, Mar 30, 2011 at 1:10 AM, sk.syed2 <sk.syed2 at gmail.com> wrote:

> > .
> > struct page *page = virt_to_page(skb->data);
> If skb->data page aligned?
>
> > .
> > And can some one please tell what is the use of the functions like
> > virt_to_page and kmap_atomic_to_page,
> Generally to lock the page in memory(esp while doing dma) using get_page().
>
> > i tried calling virt_to_page(skb->data), but when i print the data in the
> > page address ( page_address(page) ) and
> > the data in pointed by skb->data, i came to know its mapping to a wrong
> > page.
>   If skb->data is not page aligned then page_address(page) will be
> equal to skb->data+(somevalue) (on nearest page boundary).
>
>
> -syed
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110330/958a892b/attachment-0001.html 


More information about the Kernelnewbies mailing list