diff options
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 66d881f1d576..b87681adf0ba 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -25,11 +25,17 @@ struct file_ra_state; | |||
25 | struct user_struct; | 25 | struct user_struct; |
26 | struct writeback_control; | 26 | struct writeback_control; |
27 | 27 | ||
28 | #ifndef CONFIG_DISCONTIGMEM /* Don't use mapnrs, do it properly */ | 28 | #ifndef CONFIG_NEED_MULTIPLE_NODES /* Don't use mapnrs, do it properly */ |
29 | extern unsigned long max_mapnr; | 29 | extern unsigned long max_mapnr; |
30 | |||
31 | static inline void set_max_mapnr(unsigned long limit) | ||
32 | { | ||
33 | max_mapnr = limit; | ||
34 | } | ||
35 | #else | ||
36 | static inline void set_max_mapnr(unsigned long limit) { } | ||
30 | #endif | 37 | #endif |
31 | 38 | ||
32 | extern unsigned long num_physpages; | ||
33 | extern unsigned long totalram_pages; | 39 | extern unsigned long totalram_pages; |
34 | extern void * high_memory; | 40 | extern void * high_memory; |
35 | extern int page_cluster; | 41 | extern int page_cluster; |
@@ -52,6 +58,9 @@ extern unsigned long sysctl_admin_reserve_kbytes; | |||
52 | /* to align the pointer to the (next) page boundary */ | 58 | /* to align the pointer to the (next) page boundary */ |
53 | #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) | 59 | #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) |
54 | 60 | ||
61 | /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ | ||
62 | #define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)addr, PAGE_SIZE) | ||
63 | |||
55 | /* | 64 | /* |
56 | * Linux kernel virtual memory manager primitives. | 65 | * Linux kernel virtual memory manager primitives. |
57 | * The idea being to have a "virtual" mm in the same way | 66 | * The idea being to have a "virtual" mm in the same way |
@@ -1305,11 +1314,12 @@ extern void free_initmem(void); | |||
1305 | /* | 1314 | /* |
1306 | * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK) | 1315 | * Free reserved pages within range [PAGE_ALIGN(start), end & PAGE_MASK) |
1307 | * into the buddy system. The freed pages will be poisoned with pattern | 1316 | * into the buddy system. The freed pages will be poisoned with pattern |
1308 | * "poison" if it's non-zero. | 1317 | * "poison" if it's within range [0, UCHAR_MAX]. |
1309 | * Return pages freed into the buddy system. | 1318 | * Return pages freed into the buddy system. |
1310 | */ | 1319 | */ |
1311 | extern unsigned long free_reserved_area(unsigned long start, unsigned long end, | 1320 | extern unsigned long free_reserved_area(void *start, void *end, |
1312 | int poison, char *s); | 1321 | int poison, char *s); |
1322 | |||
1313 | #ifdef CONFIG_HIGHMEM | 1323 | #ifdef CONFIG_HIGHMEM |
1314 | /* | 1324 | /* |
1315 | * Free a highmem page into the buddy system, adjusting totalhigh_pages | 1325 | * Free a highmem page into the buddy system, adjusting totalhigh_pages |
@@ -1318,10 +1328,8 @@ extern unsigned long free_reserved_area(unsigned long start, unsigned long end, | |||
1318 | extern void free_highmem_page(struct page *page); | 1328 | extern void free_highmem_page(struct page *page); |
1319 | #endif | 1329 | #endif |
1320 | 1330 | ||
1321 | static inline void adjust_managed_page_count(struct page *page, long count) | 1331 | extern void adjust_managed_page_count(struct page *page, long count); |
1322 | { | 1332 | extern void mem_init_print_info(const char *str); |
1323 | totalram_pages += count; | ||
1324 | } | ||
1325 | 1333 | ||
1326 | /* Free the reserved page into the buddy system, so it gets managed. */ | 1334 | /* Free the reserved page into the buddy system, so it gets managed. */ |
1327 | static inline void __free_reserved_page(struct page *page) | 1335 | static inline void __free_reserved_page(struct page *page) |
@@ -1345,18 +1353,29 @@ static inline void mark_page_reserved(struct page *page) | |||
1345 | 1353 | ||
1346 | /* | 1354 | /* |
1347 | * Default method to free all the __init memory into the buddy system. | 1355 | * Default method to free all the __init memory into the buddy system. |
1348 | * The freed pages will be poisoned with pattern "poison" if it is | 1356 | * The freed pages will be poisoned with pattern "poison" if it's within |
1349 | * non-zero. Return pages freed into the buddy system. | 1357 | * range [0, UCHAR_MAX]. |
1358 | * Return pages freed into the buddy system. | ||
1350 | */ | 1359 | */ |
1351 | static inline unsigned long free_initmem_default(int poison) | 1360 | static inline unsigned long free_initmem_default(int poison) |
1352 | { | 1361 | { |
1353 | extern char __init_begin[], __init_end[]; | 1362 | extern char __init_begin[], __init_end[]; |
1354 | 1363 | ||
1355 | return free_reserved_area(PAGE_ALIGN((unsigned long)&__init_begin) , | 1364 | return free_reserved_area(&__init_begin, &__init_end, |
1356 | ((unsigned long)&__init_end) & PAGE_MASK, | ||
1357 | poison, "unused kernel"); | 1365 | poison, "unused kernel"); |
1358 | } | 1366 | } |
1359 | 1367 | ||
1368 | static inline unsigned long get_num_physpages(void) | ||
1369 | { | ||
1370 | int nid; | ||
1371 | unsigned long phys_pages = 0; | ||
1372 | |||
1373 | for_each_online_node(nid) | ||
1374 | phys_pages += node_present_pages(nid); | ||
1375 | |||
1376 | return phys_pages; | ||
1377 | } | ||
1378 | |||
1360 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 1379 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
1361 | /* | 1380 | /* |
1362 | * With CONFIG_HAVE_MEMBLOCK_NODE_MAP set, an architecture may initialise its | 1381 | * With CONFIG_HAVE_MEMBLOCK_NODE_MAP set, an architecture may initialise its |