linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* Pointers to contiguous pages
@ 2004-08-13 16:13 Luciano A. Stertz
  0 siblings, 0 replies; 2+ messages in thread
From: Luciano A. Stertz @ 2004-08-13 16:13 UTC (permalink / raw)
  To: linux-mm

alloc_pages with the desired order of pages. I'll fill these pages with 
data and need to add them to the page cache. So I need individual 
pointers to each page contained in the buffer. How do I get them?
     Is the following code correct?

     unsigned long pfn;
     struct page *page = alloc_pages(mask, order);
     if (!page)
         return;

     /* Fill the pages... */

     pfn = page_to_pfn(page)
     for (i=0; i<(1<<order); i++, pfn++)
     {
         struct page *p = pfn_to_page(pfn);
         ...
     }

     Is this correct? Is there a better way to do this?

     Thanks in advance,
         Luciano

	P.S.: I tryied kernelnewbies first, but I guess the question is too 
specific, nobody answered yet...


-- 
Luciano A. Stertz
luciano@tteng.com.br
T&T Engenheiros Associados Ltda
http://www.tteng.com.br
Fone/Fax (51) 3224 8425
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Pointers to contiguous pages
@ 2004-08-13 16:24 Martin J. Bligh
  0 siblings, 0 replies; 2+ messages in thread
From: Martin J. Bligh @ 2004-08-13 16:24 UTC (permalink / raw)
  To: Luciano A. Stertz, linux-mm

> alloc_pages with the desired order of pages. I'll fill these pages with data and need to add them to the page cache. So I need individual pointers to each page contained in the buffer. How do I get them?
>      Is the following code correct?
> 
>      unsigned long pfn;
>      struct page *page = alloc_pages(mask, order);
>      if (!page)
>          return;
> 
>      /* Fill the pages... */
> 
>      pfn = page_to_pfn(page)
>      for (i=0; i<(1<<order); i++, pfn++)
>      {
>          struct page *p = pfn_to_page(pfn);
>          ...
>      }
> 
>      Is this correct? Is there a better way to do this?
> 
>      Thanks in advance,
>          Luciano
> 
> 	P.S.: I tryied kernelnewbies first, but I guess the question is too specific, nobody answered yet...

Looks about right to me, except I'm not sure I'd bother calling pfn_to_page
each time (it's not fast on more complex systems), something like this 
should work (roughly):

      unsigned long pfn;
      struct page *page = alloc_pages(mask, order);
      if (!page)
          return;
 
      /* Fill the pages... */
 
      for (i=0; i<(1<<order); i++)
      {
          struct page *p = page + i;
          ...
      }

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"aart@kvack.org"> aart@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2004-08-13 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-13 16:13 Pointers to contiguous pages Luciano A. Stertz
2004-08-13 16:24 Martin J. Bligh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox