From: "Martin J. Bligh" <mbligh@aracnet.com>
To: "Luciano A. Stertz" <luciano@tteng.com.br>, linux-mm@kvack.org
Subject: Re: Pointers to contiguous pages
Date: Fri, 13 Aug 2004 09:24:14 -0700 [thread overview]
Message-ID: <90870000.1092414254@[10.10.2.4]> (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...
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>
next reply other threads:[~2004-08-13 16:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-08-13 16:24 Martin J. Bligh [this message]
-- strict thread matches above, loose matches on Subject: below --
2004-08-13 16:13 Luciano A. Stertz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='90870000.1092414254@[10.10.2.4]' \
--to=mbligh@aracnet.com \
--cc=linux-mm@kvack.org \
--cc=luciano@tteng.com.br \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox