diff options
| author | Andrew Morton <akpm@osdl.org> | 2004-01-19 05:06:28 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@home.osdl.org> | 2004-01-19 05:06:28 -0800 |
| commit | 3af6d494ee63e97d706178882ccd9245f1932e92 (patch) | |
| tree | 7b9566dd64d0dc364b69354b62671a4fe4d7db8d /include/linux | |
| parent | b58f2e6f01c7e57aa1d96a5e7ed56cd7b84d0709 (diff) | |
[PATCH] fix page counting for compound pages
From: "Bryan O'Sullivan" <bos@serpentine.com>
For compound pages, page_count needs to be sure to reference the head page.
This affects code that plays tricks with memory mappings into userspace,
which would mostly involve video drivers.
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/mm.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 881091514f01..85a921ae376a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -223,7 +223,6 @@ struct page { atomic_dec_and_test(&(p)->count); \ }) -#define page_count(p) atomic_read(&(p)->count) #define set_page_count(p,v) atomic_set(&(p)->count, v) #define __put_page(p) atomic_dec(&(p)->count) @@ -231,6 +230,13 @@ extern void FASTCALL(__page_cache_release(struct page *)); #ifdef CONFIG_HUGETLB_PAGE +static inline int page_count(struct page *p) +{ + if (PageCompound(p)) + p = (struct page *)p->lru.next; + return atomic_read(&(p)->count); +} + static inline void get_page(struct page *page) { if (PageCompound(page)) @@ -257,6 +263,8 @@ static inline void put_page(struct page *page) #else /* CONFIG_HUGETLB_PAGE */ +#define page_count(p) atomic_read(&(p)->count) + static inline void get_page(struct page *page) { atomic_inc(&page->count); |
