diff options
Diffstat (limited to 'mm/internal.h')
-rw-r--r-- | mm/internal.h | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/mm/internal.h b/mm/internal.h index 17256bb2f4ef..d20e3cc4aef0 100644 --- a/mm/internal.h +++ b/mm/internal.h | |||
@@ -8,23 +8,33 @@ | |||
8 | * as published by the Free Software Foundation; either version | 8 | * as published by the Free Software Foundation; either version |
9 | * 2 of the License, or (at your option) any later version. | 9 | * 2 of the License, or (at your option) any later version. |
10 | */ | 10 | */ |
11 | #ifndef __MM_INTERNAL_H | ||
12 | #define __MM_INTERNAL_H | ||
11 | 13 | ||
12 | static inline void set_page_refs(struct page *page, int order) | 14 | #include <linux/mm.h> |
15 | |||
16 | static inline void set_page_count(struct page *page, int v) | ||
17 | { | ||
18 | atomic_set(&page->_count, v); | ||
19 | } | ||
20 | |||
21 | /* | ||
22 | * Turn a non-refcounted page (->_count == 0) into refcounted with | ||
23 | * a count of one. | ||
24 | */ | ||
25 | static inline void set_page_refcounted(struct page *page) | ||
13 | { | 26 | { |
14 | #ifdef CONFIG_MMU | 27 | BUG_ON(PageCompound(page) && page_private(page) != (unsigned long)page); |
28 | BUG_ON(atomic_read(&page->_count)); | ||
15 | set_page_count(page, 1); | 29 | set_page_count(page, 1); |
16 | #else | 30 | } |
17 | int i; | ||
18 | 31 | ||
19 | /* | 32 | static inline void __put_page(struct page *page) |
20 | * We need to reference all the pages for this order, otherwise if | 33 | { |
21 | * anyone accesses one of the pages with (get/put) it will be freed. | 34 | atomic_dec(&page->_count); |
22 | * - eg: access_process_vm() | ||
23 | */ | ||
24 | for (i = 0; i < (1 << order); i++) | ||
25 | set_page_count(page + i, 1); | ||
26 | #endif /* CONFIG_MMU */ | ||
27 | } | 35 | } |
28 | 36 | ||
29 | extern void fastcall __init __free_pages_bootmem(struct page *page, | 37 | extern void fastcall __init __free_pages_bootmem(struct page *page, |
30 | unsigned int order); | 38 | unsigned int order); |
39 | |||
40 | #endif | ||