-
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 branch 'for-next' of git://git.kernel.org/pub/scm/linux/kernel/…
…git/rppt/memblock.git
- Loading branch information
Showing
34 changed files
with
1,409 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
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,54 @@ | ||
# 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/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 |
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_DMA_H | ||
#define _TOOLS_DMA_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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
#ifndef _MM_INTERNAL_H | ||
#define _MM_INTERNAL_H | ||
|
||
struct page {}; | ||
|
||
void memblock_free_pages(struct page *page, unsigned long pfn, | ||
unsigned int order) | ||
{ | ||
} | ||
|
||
#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,9 @@ | ||
// SPDX-License-Identifier: GPL-2.0 | ||
#include <linux/slab.h> | ||
|
||
enum slab_state slab_state; | ||
|
||
bool slab_is_available(void) | ||
{ | ||
return slab_state >= UP; | ||
} |
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,34 @@ | ||
/* SPDX-License-Identifier: GPL-2.0 */ | ||
#ifndef _LINUX_INIT_H | ||
#define _LINUX_INIT_H | ||
|
||
#include <linux/compiler.h> | ||
#include <asm/export.h> | ||
#include <linux/memory_hotplug.h> | ||
|
||
#define __section(section) __attribute__((__section__(section))) | ||
|
||
#define __initconst | ||
#define __meminit | ||
#define __meminitdata | ||
#define __refdata | ||
#define __initdata | ||
|
||
struct obs_kernel_param { | ||
const char *str; | ||
int (*setup_func)(char *st); | ||
int early; | ||
}; | ||
|
||
#define __setup_param(str, unique_id, fn, early) \ | ||
static const char __setup_str_##unique_id[] __initconst \ | ||
__aligned(1) = str; \ | ||
static struct obs_kernel_param __setup_##unique_id \ | ||
__used __section(".init.setup") \ | ||
__aligned(__alignof__(struct obs_kernel_param)) = \ | ||
{ __setup_str_##unique_id, fn, early } | ||
|
||
#define early_param(str, fn) \ | ||
__setup_param(str, fn, fn, 1) | ||
|
||
#endif |
Oops, something went wrong.