diff options
-rw-r--r-- | include/linux/mm.h | 12 | ||||
-rw-r--r-- | mm/page_alloc.c | 52 |
2 files changed, 64 insertions, 0 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 4310f80ce956..09c235301dbb 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -1323,6 +1323,7 @@ extern void free_highmem_page(struct page *page); | |||
1323 | #endif | 1323 | #endif |
1324 | 1324 | ||
1325 | extern void adjust_managed_page_count(struct page *page, long count); | 1325 | extern void adjust_managed_page_count(struct page *page, long count); |
1326 | extern void mem_init_print_info(const char *str); | ||
1326 | 1327 | ||
1327 | /* Free the reserved page into the buddy system, so it gets managed. */ | 1328 | /* Free the reserved page into the buddy system, so it gets managed. */ |
1328 | static inline void __free_reserved_page(struct page *page) | 1329 | static inline void __free_reserved_page(struct page *page) |
@@ -1358,6 +1359,17 @@ static inline unsigned long free_initmem_default(int poison) | |||
1358 | poison, "unused kernel"); | 1359 | poison, "unused kernel"); |
1359 | } | 1360 | } |
1360 | 1361 | ||
1362 | static inline unsigned long get_num_physpages(void) | ||
1363 | { | ||
1364 | int nid; | ||
1365 | unsigned long phys_pages = 0; | ||
1366 | |||
1367 | for_each_online_node(nid) | ||
1368 | phys_pages += node_present_pages(nid); | ||
1369 | |||
1370 | return phys_pages; | ||
1371 | } | ||
1372 | |||
1361 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP | 1373 | #ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP |
1362 | /* | 1374 | /* |
1363 | * With CONFIG_HAVE_MEMBLOCK_NODE_MAP set, an architecture may initialise its | 1375 | * With CONFIG_HAVE_MEMBLOCK_NODE_MAP set, an architecture may initialise its |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index d9445c4f5fd7..327516b7aee9 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -61,6 +61,7 @@ | |||
61 | #include <linux/hugetlb.h> | 61 | #include <linux/hugetlb.h> |
62 | #include <linux/sched/rt.h> | 62 | #include <linux/sched/rt.h> |
63 | 63 | ||
64 | #include <asm/sections.h> | ||
64 | #include <asm/tlbflush.h> | 65 | #include <asm/tlbflush.h> |
65 | #include <asm/div64.h> | 66 | #include <asm/div64.h> |
66 | #include "internal.h" | 67 | #include "internal.h" |
@@ -5246,6 +5247,57 @@ void free_highmem_page(struct page *page) | |||
5246 | } | 5247 | } |
5247 | #endif | 5248 | #endif |
5248 | 5249 | ||
5250 | |||
5251 | void __init mem_init_print_info(const char *str) | ||
5252 | { | ||
5253 | unsigned long physpages, codesize, datasize, rosize, bss_size; | ||
5254 | unsigned long init_code_size, init_data_size; | ||
5255 | |||
5256 | physpages = get_num_physpages(); | ||
5257 | codesize = _etext - _stext; | ||
5258 | datasize = _edata - _sdata; | ||
5259 | rosize = __end_rodata - __start_rodata; | ||
5260 | bss_size = __bss_stop - __bss_start; | ||
5261 | init_data_size = __init_end - __init_begin; | ||
5262 | init_code_size = _einittext - _sinittext; | ||
5263 | |||
5264 | /* | ||
5265 | * Detect special cases and adjust section sizes accordingly: | ||
5266 | * 1) .init.* may be embedded into .data sections | ||
5267 | * 2) .init.text.* may be out of [__init_begin, __init_end], | ||
5268 | * please refer to arch/tile/kernel/vmlinux.lds.S. | ||
5269 | * 3) .rodata.* may be embedded into .text or .data sections. | ||
5270 | */ | ||
5271 | #define adj_init_size(start, end, size, pos, adj) \ | ||
5272 | if (start <= pos && pos < end && size > adj) \ | ||
5273 | size -= adj; | ||
5274 | |||
5275 | adj_init_size(__init_begin, __init_end, init_data_size, | ||
5276 | _sinittext, init_code_size); | ||
5277 | adj_init_size(_stext, _etext, codesize, _sinittext, init_code_size); | ||
5278 | adj_init_size(_sdata, _edata, datasize, __init_begin, init_data_size); | ||
5279 | adj_init_size(_stext, _etext, codesize, __start_rodata, rosize); | ||
5280 | adj_init_size(_sdata, _edata, datasize, __start_rodata, rosize); | ||
5281 | |||
5282 | #undef adj_init_size | ||
5283 | |||
5284 | printk("Memory: %luK/%luK available " | ||
5285 | "(%luK kernel code, %luK rwdata, %luK rodata, " | ||
5286 | "%luK init, %luK bss, %luK reserved" | ||
5287 | #ifdef CONFIG_HIGHMEM | ||
5288 | ", %luK highmem" | ||
5289 | #endif | ||
5290 | "%s%s)\n", | ||
5291 | nr_free_pages() << (PAGE_SHIFT-10), physpages << (PAGE_SHIFT-10), | ||
5292 | codesize >> 10, datasize >> 10, rosize >> 10, | ||
5293 | (init_data_size + init_code_size) >> 10, bss_size >> 10, | ||
5294 | (physpages - totalram_pages) << (PAGE_SHIFT-10), | ||
5295 | #ifdef CONFIG_HIGHMEM | ||
5296 | totalhigh_pages << (PAGE_SHIFT-10), | ||
5297 | #endif | ||
5298 | str ? ", " : "", str ? str : ""); | ||
5299 | } | ||
5300 | |||
5249 | /** | 5301 | /** |
5250 | * set_dma_reserve - set the specified number of pages reserved in the first zone | 5302 | * set_dma_reserve - set the specified number of pages reserved in the first zone |
5251 | * @new_dma_reserve: The number of pages to mark reserved | 5303 | * @new_dma_reserve: The number of pages to mark reserved |