Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'memblock-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock

Pull memblock updates from Mike Rapoport:

- new memblock_estimated_nr_free_pages() helper to replace
totalram_pages() which is less accurate when
CONFIG_DEFERRED_STRUCT_PAGE_INIT is set

- fixes for memblock tests

* tag 'memblock-v6.12-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock:
s390/mm: get estimated free pages by memblock api
kernel/fork.c: get estimated free pages by memblock api
mm/memblock: introduce a new helper memblock_estimated_nr_free_pages()
memblock test: fix implicit declaration of function 'strscpy'
memblock test: fix implicit declaration of function 'isspace'
memblock test: fix implicit declaration of function 'memparse'
memblock test: add the definition of __setup()
memblock test: fix implicit declaration of function 'virt_to_phys'
tools/testing: abstract two init.h into common include directory
memblock tests: include export.h in linkage.h as kernel dose
memblock tests: include memory_hotplug.h in mmzone.h as kernel dose

+104 -15
+1 -1
arch/s390/mm/init.c
··· 62 62 63 63 static void __init setup_zero_pages(void) 64 64 { 65 - unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size()); 65 + unsigned long total_pages = memblock_estimated_nr_free_pages(); 66 66 unsigned int order; 67 67 struct page *page; 68 68 int i;
+1
include/linux/memblock.h
··· 467 467 468 468 phys_addr_t memblock_phys_mem_size(void); 469 469 phys_addr_t memblock_reserved_size(void); 470 + unsigned long memblock_estimated_nr_free_pages(void); 470 471 phys_addr_t memblock_start_of_DRAM(void); 471 472 phys_addr_t memblock_end_of_DRAM(void); 472 473 void memblock_enforce_memory_limit(phys_addr_t memory_limit);
+1 -1
kernel/fork.c
··· 999 999 static void __init set_max_threads(unsigned int max_threads_suggested) 1000 1000 { 1001 1001 u64 threads; 1002 - unsigned long nr_pages = PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size()); 1002 + unsigned long nr_pages = memblock_estimated_nr_free_pages(); 1003 1003 1004 1004 /* 1005 1005 * The number of threads shall be limited such that the thread
+17
mm/memblock.c
··· 1731 1731 return memblock.reserved.total_size; 1732 1732 } 1733 1733 1734 + /** 1735 + * memblock_estimated_nr_free_pages - return estimated number of free pages 1736 + * from memblock point of view 1737 + * 1738 + * During bootup, subsystems might need a rough estimate of the number of free 1739 + * pages in the whole system, before precise numbers are available from the 1740 + * buddy. Especially with CONFIG_DEFERRED_STRUCT_PAGE_INIT, the numbers 1741 + * obtained from the buddy might be very imprecise during bootup. 1742 + * 1743 + * Return: 1744 + * An estimated number of free pages from memblock point of view. 1745 + */ 1746 + unsigned long __init memblock_estimated_nr_free_pages(void) 1747 + { 1748 + return PHYS_PFN(memblock_phys_mem_size() - memblock_reserved_size()); 1749 + } 1750 + 1734 1751 /* lowest address */ 1735 1752 phys_addr_t __init_memblock memblock_start_of_DRAM(void) 1736 1753 {
-4
tools/include/linux/compiler.h
··· 128 128 # define unlikely(x) __builtin_expect(!!(x), 0) 129 129 #endif 130 130 131 - #ifndef __init 132 - # define __init 133 - #endif 134 - 135 131 #include <linux/types.h> 136 132 137 133 /*
+2
tools/include/linux/linkage.h
··· 1 1 #ifndef _TOOLS_INCLUDE_LINUX_LINKAGE_H 2 2 #define _TOOLS_INCLUDE_LINUX_LINKAGE_H 3 3 4 + #include <linux/export.h> 5 + 4 6 #define SYM_FUNC_START(x) .globl x; x: 5 7 6 8 #define SYM_FUNC_END(x)
+6
tools/include/linux/mm.h
··· 25 25 return __va(address); 26 26 } 27 27 28 + #define virt_to_phys virt_to_phys 29 + static inline phys_addr_t virt_to_phys(volatile void *address) 30 + { 31 + return (phys_addr_t)address; 32 + } 33 + 28 34 void reserve_bootmem_region(phys_addr_t start, phys_addr_t end, int nid); 29 35 30 36 static inline void totalram_pages_inc(void)
+1
tools/include/linux/pfn.h
··· 7 7 #define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT) 8 8 #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) 9 9 #define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT) 10 + #define PHYS_PFN(x) ((unsigned long)((x) >> PAGE_SHIFT)) 10 11 #endif
+3
tools/include/linux/string.h
··· 12 12 13 13 int strtobool(const char *s, bool *res); 14 14 15 + #define strscpy strcpy 16 + 15 17 /* 16 18 * glibc based builds needs the extern while uClibc doesn't. 17 19 * However uClibc headers also define __GLIBC__ hence the hack below ··· 51 49 extern void remove_spaces(char *s); 52 50 53 51 extern void *memchr_inv(const void *start, int c, size_t bytes); 52 + extern unsigned long long memparse(const char *ptr, char **retptr); 54 53 #endif /* _TOOLS_LINUX_STRING_H_ */
+53
tools/lib/cmdline.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * From lib/cmdline.c 4 + */ 5 + #include <stdlib.h> 6 + 7 + #if __has_attribute(__fallthrough__) 8 + # define fallthrough __attribute__((__fallthrough__)) 9 + #else 10 + # define fallthrough do {} while (0) /* fallthrough */ 11 + #endif 12 + 13 + unsigned long long memparse(const char *ptr, char **retptr) 14 + { 15 + char *endptr; /* local pointer to end of parsed string */ 16 + 17 + unsigned long long ret = strtoll(ptr, &endptr, 0); 18 + 19 + switch (*endptr) { 20 + case 'E': 21 + case 'e': 22 + ret <<= 10; 23 + fallthrough; 24 + case 'P': 25 + case 'p': 26 + ret <<= 10; 27 + fallthrough; 28 + case 'T': 29 + case 't': 30 + ret <<= 10; 31 + fallthrough; 32 + case 'G': 33 + case 'g': 34 + ret <<= 10; 35 + fallthrough; 36 + case 'M': 37 + case 'm': 38 + ret <<= 10; 39 + fallthrough; 40 + case 'K': 41 + case 'k': 42 + ret <<= 10; 43 + endptr++; 44 + fallthrough; 45 + default: 46 + break; 47 + } 48 + 49 + if (retptr) 50 + *retptr = endptr; 51 + 52 + return ret; 53 + }
+1 -1
tools/testing/memblock/Makefile
··· 8 8 TARGETS = main 9 9 TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \ 10 10 tests/basic_api.o tests/common.o tests/alloc_exact_nid_api.o 11 - DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o 11 + DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o cmdline.o 12 12 OFILES = main.o $(DEP_OFILES) $(TEST_OFILES) 13 13 EXTR_SRC = ../../../mm/memblock.c 14 14
+14 -5
tools/testing/memblock/linux/init.h tools/include/linux/init.h
··· 1 1 /* SPDX-License-Identifier: GPL-2.0 */ 2 - #ifndef _LINUX_INIT_H 3 - #define _LINUX_INIT_H 2 + #ifndef _TOOLS_LINUX_INIT_H_ 3 + #define _TOOLS_LINUX_INIT_H_ 4 4 5 5 #include <linux/compiler.h> 6 - #include <asm/export.h> 7 - #include <linux/memory_hotplug.h> 6 + 7 + #ifndef __init 8 + # define __init 9 + #endif 10 + 11 + #ifndef __exit 12 + # define __exit 13 + #endif 8 14 9 15 #define __section(section) __attribute__((__section__(section))) 10 16 ··· 34 28 __aligned(__alignof__(struct obs_kernel_param)) = \ 35 29 { __setup_str_##unique_id, fn, early } 36 30 31 + #define __setup(str, fn) \ 32 + __setup_param(str, fn, fn, 0) 33 + 37 34 #define early_param(str, fn) \ 38 35 __setup_param(str, fn, fn, 1) 39 36 40 - #endif 37 + #endif /* _TOOLS_LINUX_INIT_H_ */
+2
tools/testing/memblock/linux/kernel.h
··· 8 8 #include <linux/printk.h> 9 9 #include <linux/linkage.h> 10 10 #include <linux/kconfig.h> 11 + #include <linux/string.h> 12 + #include <linux/ctype.h> 11 13 12 14 #endif
+1
tools/testing/memblock/linux/mmzone.h
··· 3 3 #define _TOOLS_MMZONE_H 4 4 5 5 #include <linux/atomic.h> 6 + #include <linux/memory_hotplug.h> 6 7 7 8 struct pglist_data *first_online_pgdat(void); 8 9 struct pglist_data *next_online_pgdat(struct pglist_data *pgdat);
+1 -1
tools/testing/radix-tree/maple.c
··· 14 14 #include "test.h" 15 15 #include <stdlib.h> 16 16 #include <time.h> 17 - #include "linux/init.h" 17 + #include <linux/init.h> 18 18 19 19 #define module_init(x) 20 20 #define module_exit(x)
-2
tools/testing/shared/linux/init.h
··· 1 - #define __init 2 - #define __exit