Skip to contentSkip to conversation

__get_free_pages and page_count

DISCUSSION Olivier Daigle 1 participant 1 message Dec 18, 2001

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi all,
Simple question regarding __get_free_pages and (struct page*)->count. Why
does only the first page returned by __get_free_pages have it's count set to 1 and all other pages have their count set to 0?

Example:

#define ORDER 2

  unsigned long p, offset=0;
  struct page *page;
    
  if(!(p=__get_free_pages(SLAB_KERNEL, ORDER))) {
    goto err;
  }

  while(offset < PAGE_SIZE<<ORDER) {
    page=virt_to_page(p+offset);
    SC_DEBUG("  offset: %lu, page_count is %d", offset, page_count(page));
    offset+=PAGE_SIZE;
  }

Resulting output is:

Dec 18 15:36:14 meteor kernel: sc:   offset: 0, page_count is 1 
Dec 18 15:36:14 meteor kernel: sc:   offset: 4096, page_count is 0 
Dec 18 15:36:14 meteor kernel: sc:   offset: 8192, page_count is 0 
Dec 18 15:36:14 meteor kernel: sc:   offset: 12288, page_count is 0 

Thanks,

Olivier

- --
Olivier Daigle <[email protected]>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.5 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE8H6tsOVJ6DEeRbpERAgTLAKCV6nBuOKKskB8mdhBSwIzoyPGR0gCgh0JN apjYQFpFixJMiDmn8JrmkXg=
=koo5
-----END PGP SIGNATURE-----