Re: how does generic_file_read work with page_cache?

Andi Kleen (ak@muc.de)
17 Sep 1999 21:09:10 +0200


braam@cs.cmu.edu (Peter J. Braam) writes:
>
> Below in the snippet from generic_page read, the normal path does:
>
> get_page(page)
> if all is well copy the data from the page
> page_cache_release(page)
>
> But the latter is in fact __free_page(page) which is defined in
> page_alloc.c and is very appropriately labeled as "You really aren't
> expected to understand this".

Really?

In my kernel it is:

void __free_page(struct page *page)
{
if (!PageReserved(page) && atomic_dec_and_test(&page->count)) {
if (PageSwapCache(page))
panic ("Freeing swap cache page");
page->flags &= ~(1 << PG_referenced);
free_pages_ok(page - mem_map, 0);
return;
}
}

which is very understandable IMHO, and probably answers your later
questions. Perhaps you were looking at the wrong __free_page ?

BTW, even the low level free_pages_ok code isn't that hard to understand if you
look up the buddy allocator algorithm in some text book like the Knuth.

-Andi

-- 
This is like TV. I don't like TV.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/