Skip to contentSkip to conversation

Pointers to contiguous pages

DISCUSSION Luciano A. Stertz 1 participant 1 message Aug 13, 2004 Memory management

lore
Share & tools
lore
#0 lore raw

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...

Signature · 10 lines
Luciano A. Stertz
[email protected]
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 [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>