Pointers to contiguous pages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




I need to allocate multiple contiguous pages, so I called 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

--
Luciano A. Stertz
luciano@xxxxxxxxxxxx
T&T Engenheiros Associados Ltda
http://www.tteng.com.br
Fone/Fax (51) 3224 8425

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux