From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (localhost.localdomain [127.0.0.1]) by einstein.tteng.com.br (Postfix) with ESMTP id 8E5FEDE800D for ; Fri, 13 Aug 2004 13:06:53 -0300 (BRT) Received: from [192.168.0.141] (luciano.tteng.com.br [192.168.0.141]) by einstein.tteng.com.br (Postfix) with ESMTP id 7A49012003D for ; Fri, 13 Aug 2004 13:06:52 -0300 (BRT) Message-ID: <411CE8BA.6060401@tteng.com.br> Date: Fri, 13 Aug 2004 13:13:46 -0300 From: "Luciano A. Stertz" MIME-Version: 1.0 Subject: Pointers to contiguous pages Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org Return-Path: To: linux-mm@kvack.org List-ID: 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< aart@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Fri, 13 Aug 2004 09:24:14 -0700 From: "Martin J. Bligh" Subject: Re: Pointers to contiguous pages Message-ID: <90870000.1092414254@[10.10.2.4]> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline Sender: owner-linux-mm@kvack.org Return-Path: To: "Luciano A. Stertz" , linux-mm@kvack.org List-ID: > 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< { > 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< aart@kvack.org