Skip to contentSkip to conversation

A question about alloc_pages()

DISCUSSION David Howells 2 participants 3 messages Sep 25, 2008 – Sep 29, 2008 Memory management

lore
Share & tools
lore
#0 lore raw

Hi,

When alloc_pages() is asked to allocate a block of pages (order > 0), should I be able to expect that page_count(pages[0]) will be 1, and page_count() for all the other pages will be 0?

As far as I can see, nothing in the allocator alters what's in the page count for pages beyond the first when pages are freed, and checks are made that these are 0 upon freeing, so it looks to me like this ought to be the case.

However, I have a report that sometimes this isn't true, and I'm wondering if the allocator can't be relied on in this way, or whether there's a bug somewhere keeping a reference to a released page.

David

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

#1 lore raw
Quoted 3 lines · David Howells

When alloc_pages() is asked to allocate a block of pages (order > 0), should I be able to expect that page_count(pages[0]) will be 1, and page_count() for all the other pages will be 0?

Correct.

Quoted 3 lines

However, I have a report that sometimes this isn't true, and I'm wondering if the allocator can't be relied on in this way, or whether there's a bug somewhere keeping a reference to a released page.

Must be a bug.

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

#2 lore raw
Quoted 1 line · Christoph Lameter

Must be a bug.

Seems I wasn't returning the blocks of pages correctly: the first page needed its page_count() setting to 1 and the an order-N sized page block had to be order-N aligned before calling __free_pages(). However, if you don't turn on CONFIG_DEBUG_VM, it appears to work, but produces some odd effects.

David

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