Skip to content

Commit

Permalink
mm: switch the test_vmalloc module to use __vmalloc_node
Browse files Browse the repository at this point in the history
No need to export the very low-level __vmalloc_node_range when the test
module can use a slightly higher level variant.

[[email protected]: add missing `node' arg]
[[email protected]: fix riscv nommu build]
Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Christophe Leroy <[email protected]>
Cc: Daniel Vetter <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Gao Xiang <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Haiyang Zhang <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: "K. Y. Srinivasan" <[email protected]>
Cc: Laura Abbott <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Michael Kelley <[email protected]>
Cc: Minchan Kim <[email protected]>
Cc: Nitin Gupta <[email protected]>
Cc: Robin Murphy <[email protected]>
Cc: Sakari Ailus <[email protected]>
Cc: Stephen Hemminger <[email protected]>
Cc: Sumit Semwal <[email protected]>
Cc: Wei Liu <[email protected]>
Cc: Benjamin Herrenschmidt <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Cc: Will Deacon <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Christoph Hellwig authored and torvalds committed Jun 2, 2020
1 parent 2b90594 commit c3f896d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 30 deletions.
4 changes: 2 additions & 2 deletions arch/riscv/include/asm/pgtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,9 @@ static inline int ptep_clear_flush_young(struct vm_area_struct *vma,
#define PAGE_SHARED __pgprot(0)
#define PAGE_KERNEL __pgprot(0)
#define swapper_pg_dir NULL
#define TASK_SIZE 0xffffffffUL
#define VMALLOC_START 0

#define TASK_SIZE 0xffffffffUL
#define VMALLOC_END TASK_SIZE

static inline void __kernel_map_pages(struct page *page, int numpages, int enable) {}

Expand Down
26 changes: 7 additions & 19 deletions lib/test_vmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,8 @@ static int random_size_align_alloc_test(void)
*/
size = ((rnd % 10) + 1) * PAGE_SIZE;

ptr = __vmalloc_node_range(size, align,
VMALLOC_START, VMALLOC_END,
GFP_KERNEL | __GFP_ZERO,
PAGE_KERNEL,
0, 0, __builtin_return_address(0));

ptr = __vmalloc_node(size, align, GFP_KERNEL | __GFP_ZERO, 0,
__builtin_return_address(0));
if (!ptr)
return -1;

Expand All @@ -118,12 +114,8 @@ static int align_shift_alloc_test(void)
for (i = 0; i < BITS_PER_LONG; i++) {
align = ((unsigned long) 1) << i;

ptr = __vmalloc_node_range(PAGE_SIZE, align,
VMALLOC_START, VMALLOC_END,
GFP_KERNEL | __GFP_ZERO,
PAGE_KERNEL,
0, 0, __builtin_return_address(0));

ptr = __vmalloc_node(PAGE_SIZE, align, GFP_KERNEL|__GFP_ZERO, 0,
__builtin_return_address(0));
if (!ptr)
return -1;

Expand All @@ -139,13 +131,9 @@ static int fix_align_alloc_test(void)
int i;

for (i = 0; i < test_loop_count; i++) {
ptr = __vmalloc_node_range(5 * PAGE_SIZE,
THREAD_ALIGN << 1,
VMALLOC_START, VMALLOC_END,
GFP_KERNEL | __GFP_ZERO,
PAGE_KERNEL,
0, 0, __builtin_return_address(0));

ptr = __vmalloc_node(5 * PAGE_SIZE, THREAD_ALIGN << 1,
GFP_KERNEL | __GFP_ZERO, 0,
__builtin_return_address(0));
if (!ptr)
return -1;

Expand Down
17 changes: 8 additions & 9 deletions mm/vmalloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -2523,15 +2523,6 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
return NULL;
}

/*
* This is only for performance analysis of vmalloc and stress purpose.
* It is required by vmalloc test module, therefore do not use it other
* than that.
*/
#ifdef CONFIG_TEST_VMALLOC_MODULE
EXPORT_SYMBOL_GPL(__vmalloc_node_range);
#endif

/**
* __vmalloc_node - allocate virtually contiguous memory
* @size: allocation size
Expand All @@ -2557,6 +2548,14 @@ void *__vmalloc_node(unsigned long size, unsigned long align,
return __vmalloc_node_range(size, align, VMALLOC_START, VMALLOC_END,
gfp_mask, PAGE_KERNEL, 0, node, caller);
}
/*
* This is only for performance analysis of vmalloc and stress purpose.
* It is required by vmalloc test module, therefore do not use it other
* than that.
*/
#ifdef CONFIG_TEST_VMALLOC_MODULE
EXPORT_SYMBOL_GPL(__vmalloc_node);
#endif

void *__vmalloc(unsigned long size, gfp_t gfp_mask)
{
Expand Down

0 comments on commit c3f896d

Please sign in to comment.