forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'memblock-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/…
…kernel/git/rppt/memblock Pull memblock updates from Mike Rapoport: "Test suite and a small cleanup: - A small cleanup of unused variable in __next_mem_pfn_range_in_zone - Initial test suite to simulate memblock behaviour in userspace" * tag 'memblock-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock: (27 commits) memblock tests: Add TODO and README files memblock tests: Add memblock_alloc_try_nid tests for bottom up memblock tests: Add memblock_alloc_try_nid tests for top down memblock tests: Add memblock_alloc_from tests for bottom up memblock tests: Add memblock_alloc_from tests for top down memblock tests: Add memblock_alloc tests for bottom up memblock tests: Add memblock_alloc tests for top down memblock tests: Add simulation of physical memory memblock tests: Split up reset_memblock function memblock tests: Fix testing with 32-bit physical addresses memblock: __next_mem_pfn_range_in_zone: remove unneeded local variable nid memblock tests: Add memblock_free tests memblock tests: Add memblock_add_node test memblock tests: Add memblock_remove tests memblock tests: Add memblock_reserve tests memblock tests: Add memblock_add tests memblock tests: Add memblock reset function memblock tests: Add skeleton of the memblock simulator tools/include: Add debugfs.h stub tools/include: Add pfn.h stub ...
- Loading branch information
Showing
42 changed files
with
3,934 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12550,6 +12550,7 @@ S: Maintained | |
F: Documentation/core-api/boot-time-mm.rst | ||
F: include/linux/memblock.h | ||
F: mm/memblock.c | ||
F: tools/testing/memblock/ | ||
|
||
MEMORY CONTROLLER DRIVERS | ||
M: Krzysztof Kozlowski <[email protected]> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _TOOLS_LINUX_CACHE_H | ||
#define _TOOLS_LINUX_CACHE_H | ||
|
||
#define L1_CACHE_SHIFT 5 | ||
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) | ||
|
||
#define SMP_CACHE_BYTES L1_CACHE_BYTES | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _TOOLS_DEBUGFS_H | ||
#define _TOOLS_DEBUGFS_H | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,32 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _TOOLS_INCLUDE_LINUX_GFP_H | ||
#define _TOOLS_INCLUDE_LINUX_GFP_H | ||
|
||
#include <linux/types.h> | ||
|
||
#define __GFP_BITS_SHIFT 26 | ||
#define __GFP_BITS_MASK ((gfp_t)((1 << __GFP_BITS_SHIFT) - 1)) | ||
|
||
#define __GFP_HIGH 0x20u | ||
#define __GFP_IO 0x40u | ||
#define __GFP_FS 0x80u | ||
#define __GFP_NOWARN 0x200u | ||
#define __GFP_ZERO 0x8000u | ||
#define __GFP_ATOMIC 0x80000u | ||
#define __GFP_ACCOUNT 0x100000u | ||
#define __GFP_DIRECT_RECLAIM 0x400000u | ||
#define __GFP_KSWAPD_RECLAIM 0x2000000u | ||
|
||
#define __GFP_RECLAIM (__GFP_DIRECT_RECLAIM | __GFP_KSWAPD_RECLAIM) | ||
|
||
#define GFP_ZONEMASK 0x0fu | ||
#define GFP_ATOMIC (__GFP_HIGH | __GFP_ATOMIC | __GFP_KSWAPD_RECLAIM) | ||
#define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS) | ||
#define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM) | ||
|
||
static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) | ||
{ | ||
return !!(gfp_flags & __GFP_DIRECT_RECLAIM); | ||
} | ||
|
||
#endif /* _TOOLS_INCLUDE_LINUX_GFP_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _TOOLS_IO_H | ||
#define _TOOLS_IO_H | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _TOOLS_LINUX_MM_H | ||
#define _TOOLS_LINUX_MM_H | ||
|
||
#include <linux/mmzone.h> | ||
#include <uapi/linux/const.h> | ||
|
||
#define PAGE_SHIFT 12 | ||
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT) | ||
#define PAGE_MASK (~(PAGE_SIZE - 1)) | ||
|
||
#define PHYS_ADDR_MAX (~(phys_addr_t)0) | ||
|
||
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) | ||
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) | ||
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) | ||
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a)) | ||
|
||
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) | ||
|
||
#define __va(x) ((void *)((unsigned long)(x))) | ||
#define __pa(x) ((unsigned long)(x)) | ||
|
||
#define pfn_to_page(pfn) ((void *)((pfn) * PAGE_SIZE)) | ||
|
||
#define phys_to_virt phys_to_virt | ||
static inline void *phys_to_virt(unsigned long address) | ||
{ | ||
return __va(address); | ||
} | ||
|
||
void reserve_bootmem_region(phys_addr_t start, phys_addr_t end); | ||
|
||
static inline void totalram_pages_inc(void) | ||
{ | ||
} | ||
|
||
static inline void totalram_pages_add(long count) | ||
{ | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _TOOLS_LINUX_PFN_H_ | ||
#define _TOOLS_LINUX_PFN_H_ | ||
|
||
#include <linux/mm.h> | ||
|
||
#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT) | ||
#define PFN_DOWN(x) ((x) >> PAGE_SHIFT) | ||
#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT) | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include <urcu/uatomic.h> | ||
#include <linux/slab.h> | ||
#include <malloc.h> | ||
#include <linux/gfp.h> | ||
|
||
int kmalloc_nr_allocated; | ||
int kmalloc_verbose; | ||
|
||
void *kmalloc(size_t size, gfp_t gfp) | ||
{ | ||
void *ret; | ||
|
||
if (!(gfp & __GFP_DIRECT_RECLAIM)) | ||
return NULL; | ||
|
||
ret = malloc(size); | ||
uatomic_inc(&kmalloc_nr_allocated); | ||
if (kmalloc_verbose) | ||
printf("Allocating %p from malloc\n", ret); | ||
if (gfp & __GFP_ZERO) | ||
memset(ret, 0, size); | ||
return ret; | ||
} | ||
|
||
void kfree(void *p) | ||
{ | ||
if (!p) | ||
return; | ||
uatomic_dec(&kmalloc_nr_allocated); | ||
if (kmalloc_verbose) | ||
printf("Freeing %p to malloc\n", p); | ||
free(p); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
main | ||
memblock.c | ||
linux/memblock.h | ||
asm/cmpxchg.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# SPDX-License-Identifier: GPL-2.0 | ||
|
||
# Memblock simulator requires AddressSanitizer (libasan) and liburcu development | ||
# packages installed | ||
CFLAGS += -I. -I../../include -Wall -O2 -fsanitize=address \ | ||
-fsanitize=undefined -D CONFIG_PHYS_ADDR_T_64BIT | ||
LDFLAGS += -fsanitize=address -fsanitize=undefined | ||
TARGETS = main | ||
TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \ | ||
tests/basic_api.o tests/common.o | ||
DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o | ||
OFILES = main.o $(DEP_OFILES) $(TEST_OFILES) | ||
EXTR_SRC = ../../../mm/memblock.c | ||
|
||
ifeq ($(BUILD), 32) | ||
CFLAGS += -m32 | ||
LDFLAGS += -m32 | ||
endif | ||
|
||
# Process user parameters | ||
include scripts/Makefile.include | ||
|
||
main: $(OFILES) | ||
|
||
$(OFILES): include | ||
|
||
include: ../../../include/linux/memblock.h ../../include/linux/*.h \ | ||
../../include/asm/*.h | ||
|
||
@mkdir -p linux | ||
test -L linux/memblock.h || ln -s ../../../../include/linux/memblock.h linux/memblock.h | ||
test -L asm/cmpxchg.h || ln -s ../../../arch/x86/include/asm/cmpxchg.h asm/cmpxchg.h | ||
|
||
memblock.c: $(EXTR_SRC) | ||
test -L memblock.c || ln -s $(EXTR_SRC) memblock.c | ||
|
||
clean: | ||
$(RM) $(TARGETS) $(OFILES) linux/memblock.h memblock.c asm/cmpxchg.h | ||
|
||
help: | ||
@echo 'Memblock simulator' | ||
@echo '' | ||
@echo 'Available targets:' | ||
@echo ' main - Build the memblock simulator' | ||
@echo ' clean - Remove generated files and symlinks in the directory' | ||
@echo '' | ||
@echo 'Configuration:' | ||
@echo ' make NUMA=1 - simulate enabled NUMA' | ||
@echo ' make MOVABLE_NODE=1 - override `movable_node_is_enabled`' | ||
@echo ' definition to simulate movable NUMA nodes' | ||
@echo ' make 32BIT_PHYS_ADDR_T=1 - Use 32 bit physical addresses' | ||
|
||
vpath %.c ../../lib | ||
|
||
.PHONY: clean include help |
Oops, something went wrong.