History

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

Pull memblock updates from Mike Rapoport: "Extend test coverage: - add tests that trigger reallocation of memblock structures from memblock itself via memblock_double_array() - add tests for memblock_alloc_exact_nid_raw() that verify that requested node and memory range constraints are respected" * tag 'memblock-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock: memblock tests: remove completed TODO item memblock tests: add generic NUMA tests for memblock_alloc_exact_nid_raw memblock tests: add bottom-up NUMA tests for memblock_alloc_exact_nid_raw memblock tests: add top-down NUMA tests for memblock_alloc_exact_nid_raw memblock tests: introduce range tests for memblock_alloc_exact_nid_raw memblock test: Update TODO list memblock test: Add test to memblock_reserve() 129th region memblock test: Add test to memblock_add() 129th region

Linus Torvalds committed 3 years ago

Commit ad76bf12 parents 6f1f5ca 80c2fe010 files · +1622 −280Browse files

Unified · Split

10 files
  1. tools/testing/memblock/Makefile +1 −1
  2. tools/testing/memblock/TODO +1 −13
  3. tools/testing/memblock/main.c +2 −0
  4. tools/testing/memblock/tests/alloc_exact_nid_api.c +1113 −0
  5. tools/testing/memblock/tests/alloc_exact_nid_api.h +25 −0
  6. tools/testing/memblock/tests/alloc_nid_api.c +283 −263
  7. tools/testing/memblock/tests/alloc_nid_api.h +1 −0
  8. tools/testing/memblock/tests/basic_api.c +184 −0
  9. tools/testing/memblock/tests/common.c +5 −2
  10. tools/testing/memblock/tests/common.h +7 −1
tools/testing/memblock/Makefile+1−1
@@ -7,7 +7,7 @@ CFLAGS += -I. -I../../include -Wall -O2 -fsanitize=address \ · 6 unmodified lines
7LDFLAGS += -fsanitize=address -fsanitize=undefined7LDFLAGS += -fsanitize=address -fsanitize=undefined
8TARGETS = main8TARGETS = main
9TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \9TEST_OFILES = tests/alloc_nid_api.o tests/alloc_helpers_api.o tests/alloc_api.o \
10 tests/basic_api.o tests/common.o10 tests/basic_api.o tests/common.o tests/alloc_exact_nid_api.o
11DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o11DEP_OFILES = memblock.o lib/slab.o mmzone.o slab.o
12OFILES = main.o $(DEP_OFILES) $(TEST_OFILES)12OFILES = main.o $(DEP_OFILES) $(TEST_OFILES)
13EXTR_SRC = ../../../mm/memblock.c13EXTR_SRC = ../../../mm/memblock.c
tools/testing/memblock/TODO+1−13
@@ -1,17 +1,5 @@
1TODO1TODO
2=====2=====
3 3
41. Add tests trying to memblock_add() or memblock_reserve() 129th region.41. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
5 This will trigger memblock_double_array(), make sure it succeeds.
6 *Important:* These tests require valid memory ranges, use dummy physical
7 memory block from common.c to implement them. It is also very
8 likely that the current MEM_SIZE won't be enough for these
9 test cases. Use realloc to adjust the size accordingly.
10
112. Add test cases using this functions (implement them for both directions):
12 + memblock_alloc_raw()
13 + memblock_alloc_exact_nid_raw()
14 + memblock_alloc_try_nid_raw()
15
163. Add tests for memblock_alloc_node() to check if the correct NUMA node is set
17 for the new region5 for the new region
tools/testing/memblock/main.c+2−0
@@ -3,6 +3,7 @@ · 2 unmodified lines
3#include "tests/alloc_api.h"3#include "tests/alloc_api.h"
4#include "tests/alloc_helpers_api.h"4#include "tests/alloc_helpers_api.h"
5#include "tests/alloc_nid_api.h"5#include "tests/alloc_nid_api.h"
6#include "tests/alloc_exact_nid_api.h"
6#include "tests/common.h"7#include "tests/common.h"
7 8
8int main(int argc, char **argv)9int main(int argc, char **argv)
@@ -12,6 +13,7 @@ int main(int argc, char **argv) · 3 unmodified lines
12 memblock_alloc_checks();13 memblock_alloc_checks();
13 memblock_alloc_helpers_checks();14 memblock_alloc_helpers_checks();
14 memblock_alloc_nid_checks();15 memblock_alloc_nid_checks();
16 memblock_alloc_exact_nid_checks();
15 17
16 return 0;18 return 0;
17}19}
tools/testing/memblock/tests/alloc_exact_nid_api.c+1113−0
@@ -0,0 +1,1113 @@
1// SPDX-License-Identifier: GPL-2.0-or-later
2#include "alloc_exact_nid_api.h"
3#include "alloc_nid_api.h"
4
5#define FUNC_NAME "memblock_alloc_exact_nid_raw"
6
7/*
8 * contains the fraction of MEM_SIZE contained in each node in basis point
9 * units (one hundredth of 1% or 1/10000)
10 */
11static const unsigned int node_fractions[] = {
12 2500, /* 1/4 */
13 625, /* 1/16 */
14 1250, /* 1/8 */
15 1250, /* 1/8 */
16 625, /* 1/16 */
17 625, /* 1/16 */
18 2500, /* 1/4 */
19 625, /* 1/16 */
20};
21
22/*
23 * A test that tries to allocate a memory region in a specific NUMA node that
24 * has enough memory to allocate a region of the requested size.
25 * Expect to allocate an aligned region at the end of the requested node.
26 */
27static int alloc_exact_nid_top_down_numa_simple_check(void)
28{
29 int nid_req = 3;
30 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
31 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
32 void *allocated_ptr = NULL;
33 phys_addr_t size;
34 phys_addr_t min_addr;
35 phys_addr_t max_addr;
36
37 PREFIX_PUSH();
38 setup_numa_memblock(node_fractions);
39
40 ASSERT_LE(SZ_4, req_node->size);
41 size = req_node->size / SZ_4;
42 min_addr = memblock_start_of_DRAM();
43 max_addr = memblock_end_of_DRAM();
44
45 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
46 min_addr, max_addr,
47 nid_req);
48
49 ASSERT_NE(allocated_ptr, NULL);
50 ASSERT_MEM_NE(allocated_ptr, 0, size);
51
52 ASSERT_EQ(new_rgn->size, size);
53 ASSERT_EQ(new_rgn->base, region_end(req_node) - size);
54 ASSERT_LE(req_node->base, new_rgn->base);
55
56 ASSERT_EQ(memblock.reserved.cnt, 1);
57 ASSERT_EQ(memblock.reserved.total_size, size);
58
59 test_pass_pop();
60
61 return 0;
62}
63
64/*
65 * A test that tries to allocate a memory region in a specific NUMA node that
66 * is partially reserved but has enough memory for the allocated region:
67 *
68 * | +---------------------------------------+ |
69 * | | requested | |
70 * +-----------+---------------------------------------+----------+
71 *
72 * | +------------------+ +-----+ |
73 * | | reserved | | new | |
74 * +-----------+------------------+--------------+-----+----------+
75 *
76 * Expect to allocate an aligned region at the end of the requested node. The
77 * region count and total size get updated.
78 */
79static int alloc_exact_nid_top_down_numa_part_reserved_check(void)
80{
81 int nid_req = 4;
82 struct memblock_region *new_rgn = &memblock.reserved.regions[1];
83 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
84 void *allocated_ptr = NULL;
85 struct region r1;
86 phys_addr_t size;
87 phys_addr_t min_addr;
88 phys_addr_t max_addr;
89
90 PREFIX_PUSH();
91 setup_numa_memblock(node_fractions);
92
93 ASSERT_LE(SZ_8, req_node->size);
94 r1.base = req_node->base;
95 r1.size = req_node->size / SZ_2;
96 size = r1.size / SZ_4;
97 min_addr = memblock_start_of_DRAM();
98 max_addr = memblock_end_of_DRAM();
99
100 memblock_reserve(r1.base, r1.size);
101 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
102 min_addr, max_addr,
103 nid_req);
104
105 ASSERT_NE(allocated_ptr, NULL);
106 ASSERT_MEM_NE(allocated_ptr, 0, size);
107
108 ASSERT_EQ(new_rgn->size, size);
109 ASSERT_EQ(new_rgn->base, region_end(req_node) - size);
110 ASSERT_LE(req_node->base, new_rgn->base);
111
112 ASSERT_EQ(memblock.reserved.cnt, 2);
113 ASSERT_EQ(memblock.reserved.total_size, size + r1.size);
114
115 test_pass_pop();
116
117 return 0;
118}
119
120/*
121 * A test that tries to allocate a memory region that spans over the min_addr
122 * and max_addr range and overlaps with two different nodes, where the first
123 * node is the requested node:
124 *
125 * min_addr
126 * | max_addr
127 * | |
128 * v v
129 * | +-----------------------+-----------+ |
130 * | | requested | node3 | |
131 * +-----------+-----------------------+-----------+--------------+
132 * + +
133 * | +-----------+ |
134 * | | rgn | |
135 * +-----------------------+-----------+--------------------------+
136 *
137 * Expect to drop the lower limit and allocate a memory region that ends at
138 * the end of the requested node.
139 */
140static int alloc_exact_nid_top_down_numa_split_range_low_check(void)
141{
142 int nid_req = 2;
143 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
144 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
145 void *allocated_ptr = NULL;
146 phys_addr_t size = SZ_512;
147 phys_addr_t min_addr;
148 phys_addr_t max_addr;
149 phys_addr_t req_node_end;
150
151 PREFIX_PUSH();
152 setup_numa_memblock(node_fractions);
153
154 req_node_end = region_end(req_node);
155 min_addr = req_node_end - SZ_256;
156 max_addr = min_addr + size;
157
158 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
159 min_addr, max_addr,
160 nid_req);
161
162 ASSERT_NE(allocated_ptr, NULL);
163 ASSERT_MEM_NE(allocated_ptr, 0, size);
164
165 ASSERT_EQ(new_rgn->size, size);
166 ASSERT_EQ(new_rgn->base, req_node_end - size);
167 ASSERT_LE(req_node->base, new_rgn->base);
168
169 ASSERT_EQ(memblock.reserved.cnt, 1);
170 ASSERT_EQ(memblock.reserved.total_size, size);
171
172 test_pass_pop();
173
174 return 0;
175}
176
177/*
178 * A test that tries to allocate a memory region that spans over the min_addr
179 * and max_addr range and overlaps with two different nodes, where the requested
180 * node ends before min_addr:
181 *
182 * min_addr
183 * | max_addr
184 * | |
185 * v v
186 * | +---------------+ +-------------+---------+ |
187 * | | requested | | node1 | node2 | |
188 * +----+---------------+--------+-------------+---------+----------+
189 * + +
190 * | +---------+ |
191 * | | rgn | |
192 * +----------+---------+-------------------------------------------+
193 *
194 * Expect to drop the lower limit and allocate a memory region that ends at
195 * the end of the requested node.
196 */
197static int alloc_exact_nid_top_down_numa_no_overlap_split_check(void)
198{
199 int nid_req = 2;
200 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
201 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
202 struct memblock_region *node2 = &memblock.memory.regions[6];
203 void *allocated_ptr = NULL;
204 phys_addr_t size;
205 phys_addr_t min_addr;
206 phys_addr_t max_addr;
207
208 PREFIX_PUSH();
209 setup_numa_memblock(node_fractions);
210
211 size = SZ_512;
212 min_addr = node2->base - SZ_256;
213 max_addr = min_addr + size;
214
215 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
216 min_addr, max_addr,
217 nid_req);
218
219 ASSERT_NE(allocated_ptr, NULL);
220 ASSERT_MEM_NE(allocated_ptr, 0, size);
221
222 ASSERT_EQ(new_rgn->size, size);
223 ASSERT_EQ(new_rgn->base, region_end(req_node) - size);
224 ASSERT_LE(req_node->base, new_rgn->base);
225
226 ASSERT_EQ(memblock.reserved.cnt, 1);
227 ASSERT_EQ(memblock.reserved.total_size, size);
228
229 test_pass_pop();
230
231 return 0;
232}
233
234/*
235 * A test that tries to allocate memory within min_addr and max_add range when
236 * the requested node and the range do not overlap, and requested node ends
237 * before min_addr. The range overlaps with multiple nodes along node
238 * boundaries:
239 *
240 * min_addr
241 * | max_addr
242 * | |
243 * v v
244 * |-----------+ +----------+----...----+----------+ |
245 * | requested | | min node | ... | max node | |
246 * +-----------+-----------+----------+----...----+----------+------+
247 * + +
248 * | +-----+ |
249 * | | rgn | |
250 * +-----+-----+----------------------------------------------------+
251 *
252 * Expect to drop the lower limit and allocate a memory region that ends at
253 * the end of the requested node.
254 */
255static int alloc_exact_nid_top_down_numa_no_overlap_low_check(void)
256{
257 int nid_req = 0;
258 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
259 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
260 struct memblock_region *min_node = &memblock.memory.regions[2];
261 struct memblock_region *max_node = &memblock.memory.regions[5];
262 void *allocated_ptr = NULL;
263 phys_addr_t size = SZ_64;
264 phys_addr_t max_addr;
265 phys_addr_t min_addr;
266
267 PREFIX_PUSH();
268 setup_numa_memblock(node_fractions);
269
270 min_addr = min_node->base;
271 max_addr = region_end(max_node);
272
273 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
274 min_addr, max_addr,
275 nid_req);
276
277 ASSERT_NE(allocated_ptr, NULL);
278 ASSERT_MEM_NE(allocated_ptr, 0, size);
279
280 ASSERT_EQ(new_rgn->size, size);
281 ASSERT_EQ(new_rgn->base, region_end(req_node) - size);
282
283 ASSERT_EQ(memblock.reserved.cnt, 1);
284 ASSERT_EQ(memblock.reserved.total_size, size);
285
286 test_pass_pop();
287
288 return 0;
289}
290
291/*
292 * A test that tries to allocate a memory region in a specific NUMA node that
293 * has enough memory to allocate a region of the requested size.
294 * Expect to allocate an aligned region at the beginning of the requested node.
295 */
296static int alloc_exact_nid_bottom_up_numa_simple_check(void)
297{
298 int nid_req = 3;
299 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
300 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
301 void *allocated_ptr = NULL;
302 phys_addr_t size;
303 phys_addr_t min_addr;
304 phys_addr_t max_addr;
305
306 PREFIX_PUSH();
307 setup_numa_memblock(node_fractions);
308
309 ASSERT_LE(SZ_4, req_node->size);
310 size = req_node->size / SZ_4;
311 min_addr = memblock_start_of_DRAM();
312 max_addr = memblock_end_of_DRAM();
313
314 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
315 min_addr, max_addr,
316 nid_req);
317
318 ASSERT_NE(allocated_ptr, NULL);
319 ASSERT_MEM_NE(allocated_ptr, 0, size);
320
321 ASSERT_EQ(new_rgn->size, size);
322 ASSERT_EQ(new_rgn->base, req_node->base);
323 ASSERT_LE(region_end(new_rgn), region_end(req_node));
324
325 ASSERT_EQ(memblock.reserved.cnt, 1);
326 ASSERT_EQ(memblock.reserved.total_size, size);
327
328 test_pass_pop();
329
330 return 0;
331}
332
333/*
334 * A test that tries to allocate a memory region in a specific NUMA node that
335 * is partially reserved but has enough memory for the allocated region:
336 *
337 * | +---------------------------------------+ |
338 * | | requested | |
339 * +-----------+---------------------------------------+---------+
340 *
341 * | +------------------+-----+ |
342 * | | reserved | new | |
343 * +-----------+------------------+-----+------------------------+
344 *
345 * Expect to allocate an aligned region in the requested node that merges with
346 * the existing reserved region. The total size gets updated.
347 */
348static int alloc_exact_nid_bottom_up_numa_part_reserved_check(void)
349{
350 int nid_req = 4;
351 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
352 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
353 void *allocated_ptr = NULL;
354 struct region r1;
355 phys_addr_t size;
356 phys_addr_t min_addr;
357 phys_addr_t max_addr;
358 phys_addr_t total_size;
359
360 PREFIX_PUSH();
361 setup_numa_memblock(node_fractions);
362
363 ASSERT_LE(SZ_8, req_node->size);
364 r1.base = req_node->base;
365 r1.size = req_node->size / SZ_2;
366 size = r1.size / SZ_4;
367 min_addr = memblock_start_of_DRAM();
368 max_addr = memblock_end_of_DRAM();
369 total_size = size + r1.size;
370
371 memblock_reserve(r1.base, r1.size);
372 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
373 min_addr, max_addr,
374 nid_req);
375
376 ASSERT_NE(allocated_ptr, NULL);
377 ASSERT_MEM_NE(allocated_ptr, 0, size);
378
379 ASSERT_EQ(new_rgn->size, total_size);
380 ASSERT_EQ(new_rgn->base, req_node->base);
381 ASSERT_LE(region_end(new_rgn), region_end(req_node));
382
383 ASSERT_EQ(memblock.reserved.cnt, 1);
384 ASSERT_EQ(memblock.reserved.total_size, total_size);
385
386 test_pass_pop();
387
388 return 0;
389}
390
391/*
392 * A test that tries to allocate a memory region that spans over the min_addr
393 * and max_addr range and overlaps with two different nodes, where the first
394 * node is the requested node:
395 *
396 * min_addr
397 * | max_addr
398 * | |
399 * v v
400 * | +-----------------------+-----------+ |
401 * | | requested | node3 | |
402 * +-----------+-----------------------+-----------+--------------+
403 * + +
404 * | +-----------+ |
405 * | | rgn | |
406 * +-----------+-----------+--------------------------------------+
407 *
408 * Expect to drop the lower limit and allocate a memory region at the beginning
409 * of the requested node.
410 */
411static int alloc_exact_nid_bottom_up_numa_split_range_low_check(void)
412{
413 int nid_req = 2;
414 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
415 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
416 void *allocated_ptr = NULL;
417 phys_addr_t size = SZ_512;
418 phys_addr_t min_addr;
419 phys_addr_t max_addr;
420 phys_addr_t req_node_end;
421
422 PREFIX_PUSH();
423 setup_numa_memblock(node_fractions);
424
425 req_node_end = region_end(req_node);
426 min_addr = req_node_end - SZ_256;
427 max_addr = min_addr + size;
428
429 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
430 min_addr, max_addr,
431 nid_req);
432
433 ASSERT_NE(allocated_ptr, NULL);
434 ASSERT_MEM_NE(allocated_ptr, 0, size);
435
436 ASSERT_EQ(new_rgn->size, size);
437 ASSERT_EQ(new_rgn->base, req_node->base);
438 ASSERT_LE(region_end(new_rgn), req_node_end);
439
440 ASSERT_EQ(memblock.reserved.cnt, 1);
441 ASSERT_EQ(memblock.reserved.total_size, size);
442
443 test_pass_pop();
444
445 return 0;
446}
447
448/*
449 * A test that tries to allocate a memory region that spans over the min_addr
450 * and max_addr range and overlaps with two different nodes, where the requested
451 * node ends before min_addr:
452 *
453 * min_addr
454 * | max_addr
455 * | |
456 * v v
457 * | +---------------+ +-------------+---------+ |
458 * | | requested | | node1 | node2 | |
459 * +----+---------------+--------+-------------+---------+---------+
460 * + +
461 * | +---------+ |
462 * | | rgn | |
463 * +----+---------+------------------------------------------------+
464 *
465 * Expect to drop the lower limit and allocate a memory region that starts at
466 * the beginning of the requested node.
467 */
468static int alloc_exact_nid_bottom_up_numa_no_overlap_split_check(void)
469{
470 int nid_req = 2;
471 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
472 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
473 struct memblock_region *node2 = &memblock.memory.regions[6];
474 void *allocated_ptr = NULL;
475 phys_addr_t size;
476 phys_addr_t min_addr;
477 phys_addr_t max_addr;
478
479 PREFIX_PUSH();
480 setup_numa_memblock(node_fractions);
481
482 size = SZ_512;
483 min_addr = node2->base - SZ_256;
484 max_addr = min_addr + size;
485
486 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
487 min_addr, max_addr,
488 nid_req);
489
490 ASSERT_NE(allocated_ptr, NULL);
491 ASSERT_MEM_NE(allocated_ptr, 0, size);
492
493 ASSERT_EQ(new_rgn->size, size);
494 ASSERT_EQ(new_rgn->base, req_node->base);
495 ASSERT_LE(region_end(new_rgn), region_end(req_node));
496
497 ASSERT_EQ(memblock.reserved.cnt, 1);
498 ASSERT_EQ(memblock.reserved.total_size, size);
499
500 test_pass_pop();
501
502 return 0;
503}
504
505/*
506 * A test that tries to allocate memory within min_addr and max_add range when
507 * the requested node and the range do not overlap, and requested node ends
508 * before min_addr. The range overlaps with multiple nodes along node
509 * boundaries:
510 *
511 * min_addr
512 * | max_addr
513 * | |
514 * v v
515 * |-----------+ +----------+----...----+----------+ |
516 * | requested | | min node | ... | max node | |
517 * +-----------+-----------+----------+----...----+----------+------+
518 * + +
519 * |-----+ |
520 * | rgn | |
521 * +-----+----------------------------------------------------------+
522 *
523 * Expect to drop the lower limit and allocate a memory region that starts at
524 * the beginning of the requested node.
525 */
526static int alloc_exact_nid_bottom_up_numa_no_overlap_low_check(void)
527{
528 int nid_req = 0;
529 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
530 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
531 struct memblock_region *min_node = &memblock.memory.regions[2];
532 struct memblock_region *max_node = &memblock.memory.regions[5];
533 void *allocated_ptr = NULL;
534 phys_addr_t size = SZ_64;
535 phys_addr_t max_addr;
536 phys_addr_t min_addr;
537
538 PREFIX_PUSH();
539 setup_numa_memblock(node_fractions);
540
541 min_addr = min_node->base;
542 max_addr = region_end(max_node);
543
544 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
545 min_addr, max_addr,
546 nid_req);
547
548 ASSERT_NE(allocated_ptr, NULL);
549 ASSERT_MEM_NE(allocated_ptr, 0, size);
550
551 ASSERT_EQ(new_rgn->size, size);
552 ASSERT_EQ(new_rgn->base, req_node->base);
553 ASSERT_LE(region_end(new_rgn), region_end(req_node));
554
555 ASSERT_EQ(memblock.reserved.cnt, 1);
556 ASSERT_EQ(memblock.reserved.total_size, size);
557
558 test_pass_pop();
559
560 return 0;
561}
562
563/*
564 * A test that tries to allocate a memory region in a specific NUMA node that
565 * does not have enough memory to allocate a region of the requested size:
566 *
567 * | +-----+ |
568 * | | req | |
569 * +---+-----+----------------------------+
570 *
571 * +---------+
572 * | rgn |
573 * +---------+
574 *
575 * Expect no allocation to happen.
576 */
577static int alloc_exact_nid_numa_small_node_generic_check(void)
578{
579 int nid_req = 1;
580 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
581 void *allocated_ptr = NULL;
582 phys_addr_t size;
583 phys_addr_t min_addr;
584 phys_addr_t max_addr;
585
586 PREFIX_PUSH();
587 setup_numa_memblock(node_fractions);
588
589 size = SZ_2 * req_node->size;
590 min_addr = memblock_start_of_DRAM();
591 max_addr = memblock_end_of_DRAM();
592
593 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
594 min_addr, max_addr,
595 nid_req);
596
597 ASSERT_EQ(allocated_ptr, NULL);
598
599 test_pass_pop();
600
601 return 0;
602}
603
604/*
605 * A test that tries to allocate a memory region in a specific NUMA node that
606 * is fully reserved:
607 *
608 * | +---------+ |
609 * | |requested| |
610 * +--------------+---------+-------------+
611 *
612 * | +---------+ |
613 * | | reserved| |
614 * +--------------+---------+-------------+
615 *
616 * Expect no allocation to happen.
617 */
618static int alloc_exact_nid_numa_node_reserved_generic_check(void)
619{
620 int nid_req = 2;
621 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
622 void *allocated_ptr = NULL;
623 phys_addr_t size;
624 phys_addr_t min_addr;
625 phys_addr_t max_addr;
626
627 PREFIX_PUSH();
628 setup_numa_memblock(node_fractions);
629
630 size = req_node->size;
631 min_addr = memblock_start_of_DRAM();
632 max_addr = memblock_end_of_DRAM();
633
634 memblock_reserve(req_node->base, req_node->size);
635 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
636 min_addr, max_addr,
637 nid_req);
638
639 ASSERT_EQ(allocated_ptr, NULL);
640
641 test_pass_pop();
642
643 return 0;
644}
645
646/*
647 * A test that tries to allocate a memory region in a specific NUMA node that
648 * is partially reserved and does not have enough contiguous memory for the
649 * allocated region:
650 *
651 * | +-----------------------+ |
652 * | | requested | |
653 * +-----------+-----------------------+----+
654 *
655 * | +----------+ |
656 * | | reserved | |
657 * +-----------------+----------+-----------+
658 *
659 * Expect no allocation to happen.
660 */
661static int alloc_exact_nid_numa_part_reserved_fail_generic_check(void)
662{
663 int nid_req = 4;
664 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
665 void *allocated_ptr = NULL;
666 struct region r1;
667 phys_addr_t size;
668 phys_addr_t min_addr;
669 phys_addr_t max_addr;
670
671 PREFIX_PUSH();
672 setup_numa_memblock(node_fractions);
673
674 ASSERT_LE(SZ_4, req_node->size);
675 size = req_node->size / SZ_2;
676 r1.base = req_node->base + (size / SZ_2);
677 r1.size = size;
678
679 min_addr = memblock_start_of_DRAM();
680 max_addr = memblock_end_of_DRAM();
681
682 memblock_reserve(r1.base, r1.size);
683 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
684 min_addr, max_addr,
685 nid_req);
686
687 ASSERT_EQ(allocated_ptr, NULL);
688
689 test_pass_pop();
690
691 return 0;
692}
693
694/*
695 * A test that tries to allocate a memory region that spans over the min_addr
696 * and max_addr range and overlaps with two different nodes, where the second
697 * node is the requested node:
698 *
699 * min_addr
700 * | max_addr
701 * | |
702 * v v
703 * | +--------------------------+---------+ |
704 * | | first node |requested| |
705 * +------+--------------------------+---------+----------------+
706 *
707 * Expect no allocation to happen.
708 */
709static int alloc_exact_nid_numa_split_range_high_generic_check(void)
710{
711 int nid_req = 3;
712 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
713 void *allocated_ptr = NULL;
714 phys_addr_t size = SZ_512;
715 phys_addr_t min_addr;
716 phys_addr_t max_addr;
717
718 PREFIX_PUSH();
719 setup_numa_memblock(node_fractions);
720
721 min_addr = req_node->base - SZ_256;
722 max_addr = min_addr + size;
723
724 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
725 min_addr, max_addr,
726 nid_req);
727
728 ASSERT_EQ(allocated_ptr, NULL);
729
730 test_pass_pop();
731
732 return 0;
733}
734
735/*
736 * A test that tries to allocate memory within min_addr and max_add range when
737 * the requested node and the range do not overlap, and requested node starts
738 * after max_addr. The range overlaps with multiple nodes along node
739 * boundaries:
740 *
741 * min_addr
742 * | max_addr
743 * | |
744 * v v
745 * | +----------+----...----+----------+ +-----------+ |
746 * | | min node | ... | max node | | requested | |
747 * +-----+----------+----...----+----------+--------+-----------+---+
748 *
749 * Expect no allocation to happen.
750 */
751static int alloc_exact_nid_numa_no_overlap_high_generic_check(void)
752{
753 int nid_req = 7;
754 struct memblock_region *min_node = &memblock.memory.regions[2];
755 struct memblock_region *max_node = &memblock.memory.regions[5];
756 void *allocated_ptr = NULL;
757 phys_addr_t size = SZ_64;
758 phys_addr_t max_addr;
759 phys_addr_t min_addr;
760
761 PREFIX_PUSH();
762 setup_numa_memblock(node_fractions);
763
764 min_addr = min_node->base;
765 max_addr = region_end(max_node);
766
767 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
768 min_addr, max_addr,
769 nid_req);
770
771 ASSERT_EQ(allocated_ptr, NULL);
772
773 test_pass_pop();
774
775 return 0;
776}
777
778/*
779 * A test that tries to allocate a memory region in a specific NUMA node that
780 * does not have enough memory to allocate a region of the requested size.
781 * Additionally, none of the nodes have enough memory to allocate the region:
782 *
783 * +-----------------------------------+
784 * | new |
785 * +-----------------------------------+
786 * |-------+-------+-------+-------+-------+-------+-------+-------|
787 * | node0 | node1 | node2 | node3 | node4 | node5 | node6 | node7 |
788 * +-------+-------+-------+-------+-------+-------+-------+-------+
789 *
790 * Expect no allocation to happen.
791 */
792static int alloc_exact_nid_numa_large_region_generic_check(void)
793{
794 int nid_req = 3;
795 void *allocated_ptr = NULL;
796 phys_addr_t size = MEM_SIZE / SZ_2;
797 phys_addr_t min_addr;
798 phys_addr_t max_addr;
799
800 PREFIX_PUSH();
801 setup_numa_memblock(node_fractions);
802
803 min_addr = memblock_start_of_DRAM();
804 max_addr = memblock_end_of_DRAM();
805
806 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
807 min_addr, max_addr,
808 nid_req);
809 ASSERT_EQ(allocated_ptr, NULL);
810
811 test_pass_pop();
812
813 return 0;
814}
815
816/*
817 * A test that tries to allocate memory within min_addr and max_addr range when
818 * there are two reserved regions at the borders. The requested node starts at
819 * min_addr and ends at max_addr and is the same size as the region to be
820 * allocated:
821 *
822 * min_addr
823 * | max_addr
824 * | |
825 * v v
826 * | +-----------+-----------------------+-----------------------|
827 * | | node5 | requested | node7 |
828 * +------+-----------+-----------------------+-----------------------+
829 * + +
830 * | +----+-----------------------+----+ |
831 * | | r2 | new | r1 | |
832 * +-------------+----+-----------------------+----+------------------+
833 *
834 * Expect to merge all of the regions into one. The region counter and total
835 * size fields get updated.
836 */
837static int alloc_exact_nid_numa_reserved_full_merge_generic_check(void)
838{
839 int nid_req = 6;
840 int nid_next = nid_req + 1;
841 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
842 struct memblock_region *req_node = &memblock.memory.regions[nid_req];
843 struct memblock_region *next_node = &memblock.memory.regions[nid_next];
844 void *allocated_ptr = NULL;
845 struct region r1, r2;
846 phys_addr_t size = req_node->size;
847 phys_addr_t total_size;
848 phys_addr_t max_addr;
849 phys_addr_t min_addr;
850
851 PREFIX_PUSH();
852 setup_numa_memblock(node_fractions);
853
854 r1.base = next_node->base;
855 r1.size = SZ_128;
856
857 r2.size = SZ_128;
858 r2.base = r1.base - (size + r2.size);
859
860 total_size = r1.size + r2.size + size;
861 min_addr = r2.base + r2.size;
862 max_addr = r1.base;
863
864 memblock_reserve(r1.base, r1.size);
865 memblock_reserve(r2.base, r2.size);
866
867 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
868 min_addr, max_addr,
869 nid_req);
870
871 ASSERT_NE(allocated_ptr, NULL);
872 ASSERT_MEM_NE(allocated_ptr, 0, size);
873
874 ASSERT_EQ(new_rgn->size, total_size);
875 ASSERT_EQ(new_rgn->base, r2.base);
876
877 ASSERT_LE(new_rgn->base, req_node->base);
878 ASSERT_LE(region_end(req_node), region_end(new_rgn));
879
880 ASSERT_EQ(memblock.reserved.cnt, 1);
881 ASSERT_EQ(memblock.reserved.total_size, total_size);
882
883 test_pass_pop();
884
885 return 0;
886}
887
888/*
889 * A test that tries to allocate memory within min_addr and max_add range,
890 * where the total range can fit the region, but it is split between two nodes
891 * and everything else is reserved. Additionally, nid is set to NUMA_NO_NODE
892 * instead of requesting a specific node:
893 *
894 * +-----------+
895 * | new |
896 * +-----------+
897 * | +---------------------+-----------|
898 * | | prev node | next node |
899 * +------+---------------------+-----------+
900 * + +
901 * |----------------------+ +-----|
902 * | r1 | | r2 |
903 * +----------------------+-----------+-----+
904 * ^ ^
905 * | |
906 * | max_addr
907 * |
908 * min_addr
909 *
910 * Expect no allocation to happen.
911 */
912static int alloc_exact_nid_numa_split_all_reserved_generic_check(void)
913{
914 void *allocated_ptr = NULL;
915 struct memblock_region *next_node = &memblock.memory.regions[7];
916 struct region r1, r2;
917 phys_addr_t size = SZ_256;
918 phys_addr_t max_addr;
919 phys_addr_t min_addr;
920
921 PREFIX_PUSH();
922 setup_numa_memblock(node_fractions);
923
924 r2.base = next_node->base + SZ_128;
925 r2.size = memblock_end_of_DRAM() - r2.base;
926
927 r1.size = MEM_SIZE - (r2.size + size);
928 r1.base = memblock_start_of_DRAM();
929
930 min_addr = r1.base + r1.size;
931 max_addr = r2.base;
932
933 memblock_reserve(r1.base, r1.size);
934 memblock_reserve(r2.base, r2.size);
935
936 allocated_ptr = memblock_alloc_exact_nid_raw(size, SMP_CACHE_BYTES,
937 min_addr, max_addr,
938 NUMA_NO_NODE);
939
940 ASSERT_EQ(allocated_ptr, NULL);
941
942 test_pass_pop();
943
944 return 0;
945}
946
947/* Test case wrappers for NUMA tests */
948static int alloc_exact_nid_numa_simple_check(void)
949{
950 test_print("\tRunning %s...\n", __func__);
951 memblock_set_bottom_up(false);
952 alloc_exact_nid_top_down_numa_simple_check();
953 memblock_set_bottom_up(true);
954 alloc_exact_nid_bottom_up_numa_simple_check();
955
956 return 0;
957}
958
959static int alloc_exact_nid_numa_part_reserved_check(void)
960{
961 test_print("\tRunning %s...\n", __func__);
962 memblock_set_bottom_up(false);
963 alloc_exact_nid_top_down_numa_part_reserved_check();
964 memblock_set_bottom_up(true);
965 alloc_exact_nid_bottom_up_numa_part_reserved_check();
966
967 return 0;
968}
969
970static int alloc_exact_nid_numa_split_range_low_check(void)
971{
972 test_print("\tRunning %s...\n", __func__);
973 memblock_set_bottom_up(false);
974 alloc_exact_nid_top_down_numa_split_range_low_check();
975 memblock_set_bottom_up(true);
976 alloc_exact_nid_bottom_up_numa_split_range_low_check();
977
978 return 0;
979}
980
981static int alloc_exact_nid_numa_no_overlap_split_check(void)
982{
983 test_print("\tRunning %s...\n", __func__);
984 memblock_set_bottom_up(false);
985 alloc_exact_nid_top_down_numa_no_overlap_split_check();
986 memblock_set_bottom_up(true);
987 alloc_exact_nid_bottom_up_numa_no_overlap_split_check();
988
989 return 0;
990}
991
992static int alloc_exact_nid_numa_no_overlap_low_check(void)
993{
994 test_print("\tRunning %s...\n", __func__);
995 memblock_set_bottom_up(false);
996 alloc_exact_nid_top_down_numa_no_overlap_low_check();
997 memblock_set_bottom_up(true);
998 alloc_exact_nid_bottom_up_numa_no_overlap_low_check();
999
1000 return 0;
1001}
1002
1003static int alloc_exact_nid_numa_small_node_check(void)
1004{
1005 test_print("\tRunning %s...\n", __func__);
1006 run_top_down(alloc_exact_nid_numa_small_node_generic_check);
1007 run_bottom_up(alloc_exact_nid_numa_small_node_generic_check);
1008
1009 return 0;
1010}
1011
1012static int alloc_exact_nid_numa_node_reserved_check(void)
1013{
1014 test_print("\tRunning %s...\n", __func__);
1015 run_top_down(alloc_exact_nid_numa_node_reserved_generic_check);
1016 run_bottom_up(alloc_exact_nid_numa_node_reserved_generic_check);
1017
1018 return 0;
1019}
1020
1021static int alloc_exact_nid_numa_part_reserved_fail_check(void)
1022{
1023 test_print("\tRunning %s...\n", __func__);
1024 run_top_down(alloc_exact_nid_numa_part_reserved_fail_generic_check);
1025 run_bottom_up(alloc_exact_nid_numa_part_reserved_fail_generic_check);
1026
1027 return 0;
1028}
1029
1030static int alloc_exact_nid_numa_split_range_high_check(void)
1031{
1032 test_print("\tRunning %s...\n", __func__);
1033 run_top_down(alloc_exact_nid_numa_split_range_high_generic_check);
1034 run_bottom_up(alloc_exact_nid_numa_split_range_high_generic_check);
1035
1036 return 0;
1037}
1038
1039static int alloc_exact_nid_numa_no_overlap_high_check(void)
1040{
1041 test_print("\tRunning %s...\n", __func__);
1042 run_top_down(alloc_exact_nid_numa_no_overlap_high_generic_check);
1043 run_bottom_up(alloc_exact_nid_numa_no_overlap_high_generic_check);
1044
1045 return 0;
1046}
1047
1048static int alloc_exact_nid_numa_large_region_check(void)
1049{
1050 test_print("\tRunning %s...\n", __func__);
1051 run_top_down(alloc_exact_nid_numa_large_region_generic_check);
1052 run_bottom_up(alloc_exact_nid_numa_large_region_generic_check);
1053
1054 return 0;
1055}
1056
1057static int alloc_exact_nid_numa_reserved_full_merge_check(void)
1058{
1059 test_print("\tRunning %s...\n", __func__);
1060 run_top_down(alloc_exact_nid_numa_reserved_full_merge_generic_check);
1061 run_bottom_up(alloc_exact_nid_numa_reserved_full_merge_generic_check);
1062
1063 return 0;
1064}
1065
1066static int alloc_exact_nid_numa_split_all_reserved_check(void)
1067{
1068 test_print("\tRunning %s...\n", __func__);
1069 run_top_down(alloc_exact_nid_numa_split_all_reserved_generic_check);
1070 run_bottom_up(alloc_exact_nid_numa_split_all_reserved_generic_check);
1071
1072 return 0;
1073}
1074
1075int __memblock_alloc_exact_nid_numa_checks(void)
1076{
1077 test_print("Running %s NUMA tests...\n", FUNC_NAME);
1078
1079 alloc_exact_nid_numa_simple_check();
1080 alloc_exact_nid_numa_part_reserved_check();
1081 alloc_exact_nid_numa_split_range_low_check();
1082 alloc_exact_nid_numa_no_overlap_split_check();
1083 alloc_exact_nid_numa_no_overlap_low_check();
1084
1085 alloc_exact_nid_numa_small_node_check();
1086 alloc_exact_nid_numa_node_reserved_check();
1087 alloc_exact_nid_numa_part_reserved_fail_check();
1088 alloc_exact_nid_numa_split_range_high_check();
1089 alloc_exact_nid_numa_no_overlap_high_check();
1090 alloc_exact_nid_numa_large_region_check();
1091 alloc_exact_nid_numa_reserved_full_merge_check();
1092 alloc_exact_nid_numa_split_all_reserved_check();
1093
1094 return 0;
1095}
1096
1097int memblock_alloc_exact_nid_checks(void)
1098{
1099 prefix_reset();
1100 prefix_push(FUNC_NAME);
1101
1102 reset_memblock_attributes();
1103 dummy_physical_memory_init();
1104
1105 memblock_alloc_exact_nid_range_checks();
1106 memblock_alloc_exact_nid_numa_checks();
1107
1108 dummy_physical_memory_cleanup();
1109
1110 prefix_pop();
1111
1112 return 0;
1113}
tools/testing/memblock/tests/alloc_exact_nid_api.h+25−0
@@ -0,0 +1,25 @@
1/* SPDX-License-Identifier: GPL-2.0-or-later */
2#ifndef _MEMBLOCK_ALLOC_EXACT_NID_H
3#define _MEMBLOCK_ALLOC_EXACT_NID_H
4
5#include "common.h"
6
7int memblock_alloc_exact_nid_checks(void);
8int __memblock_alloc_exact_nid_numa_checks(void);
9
10#ifdef CONFIG_NUMA
11static inline int memblock_alloc_exact_nid_numa_checks(void)
12{
13 __memblock_alloc_exact_nid_numa_checks();
14 return 0;
15}
16
17#else
18static inline int memblock_alloc_exact_nid_numa_checks(void)
19{
20 return 0;
21}
22
23#endif /* CONFIG_NUMA */
24
25#endif
tools/testing/memblock/tests/alloc_nid_api.c+283−263
@@ -18,18 +18,29 @@ static const unsigned int node_fractions[] = { · 17 unmodified lines
18 625, /* 1/16 */18 625, /* 1/16 */
19};19};
20 20
21static inline const char * const get_memblock_alloc_try_nid_name(int flags)21static inline const char * const get_memblock_alloc_nid_name(int flags)
22{22{
23 if (flags & TEST_F_EXACT)
24 return "memblock_alloc_exact_nid_raw";
23 if (flags & TEST_F_RAW)25 if (flags & TEST_F_RAW)
24 return "memblock_alloc_try_nid_raw";26 return "memblock_alloc_try_nid_raw";
25 return "memblock_alloc_try_nid";27 return "memblock_alloc_try_nid";
26}28}
27 29
28static inline void *run_memblock_alloc_try_nid(phys_addr_t size,30static inline void *run_memblock_alloc_nid(phys_addr_t size,
29 phys_addr_t align,31 phys_addr_t align,
30 phys_addr_t min_addr,32 phys_addr_t min_addr,
31 phys_addr_t max_addr, int nid)33 phys_addr_t max_addr, int nid)
32{34{
35 assert(!(alloc_nid_test_flags & TEST_F_EXACT) ||
36 (alloc_nid_test_flags & TEST_F_RAW));
37 /*
38 * TEST_F_EXACT should be checked before TEST_F_RAW since
39 * memblock_alloc_exact_nid_raw() performs raw allocations.
40 */
41 if (alloc_nid_test_flags & TEST_F_EXACT)
42 return memblock_alloc_exact_nid_raw(size, align, min_addr,
43 max_addr, nid);
33 if (alloc_nid_test_flags & TEST_F_RAW)44 if (alloc_nid_test_flags & TEST_F_RAW)
34 return memblock_alloc_try_nid_raw(size, align, min_addr,45 return memblock_alloc_try_nid_raw(size, align, min_addr,
35 max_addr, nid);46 max_addr, nid);
@@ -50,7 +61,7 @@ static inline void *run_memblock_alloc_try_nid(phys_addr_t size, · 14 unmodified lines
50 *61 *
51 * Expect to allocate a region that ends at max_addr.62 * Expect to allocate a region that ends at max_addr.
52 */63 */
53static int alloc_try_nid_top_down_simple_check(void)64static int alloc_nid_top_down_simple_check(void)
54{65{
55 struct memblock_region *rgn = &memblock.reserved.regions[0];66 struct memblock_region *rgn = &memblock.reserved.regions[0];
56 void *allocated_ptr = NULL;67 void *allocated_ptr = NULL;
@@ -65,9 +76,9 @@ static int alloc_try_nid_top_down_simple_check(void) · 8 unmodified lines
65 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2;76 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2;
66 max_addr = min_addr + SZ_512;77 max_addr = min_addr + SZ_512;
67 78
68 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,79 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
69 min_addr, max_addr,80 min_addr, max_addr,
70 NUMA_NO_NODE);81 NUMA_NO_NODE);
71 rgn_end = rgn->base + rgn->size;82 rgn_end = rgn->base + rgn->size;
72 83
73 ASSERT_NE(allocated_ptr, NULL);84 ASSERT_NE(allocated_ptr, NULL);
@@ -102,7 +113,7 @@ static int alloc_try_nid_top_down_simple_check(void) · 28 unmodified lines
102 *113 *
103 * Expect to allocate an aligned region that ends before max_addr.114 * Expect to allocate an aligned region that ends before max_addr.
104 */115 */
105static int alloc_try_nid_top_down_end_misaligned_check(void)116static int alloc_nid_top_down_end_misaligned_check(void)
106{117{
107 struct memblock_region *rgn = &memblock.reserved.regions[0];118 struct memblock_region *rgn = &memblock.reserved.regions[0];
108 void *allocated_ptr = NULL;119 void *allocated_ptr = NULL;
@@ -118,9 +129,9 @@ static int alloc_try_nid_top_down_end_misaligned_check(void) · 9 unmodified lines
118 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2;129 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2;
119 max_addr = min_addr + SZ_512 + misalign;130 max_addr = min_addr + SZ_512 + misalign;
120 131
121 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,132 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
122 min_addr, max_addr,133 min_addr, max_addr,
123 NUMA_NO_NODE);134 NUMA_NO_NODE);
124 rgn_end = rgn->base + rgn->size;135 rgn_end = rgn->base + rgn->size;
125 136
126 ASSERT_NE(allocated_ptr, NULL);137 ASSERT_NE(allocated_ptr, NULL);
@@ -153,7 +164,7 @@ static int alloc_try_nid_top_down_end_misaligned_check(void) · 26 unmodified lines
153 * Expect to allocate a region that starts at min_addr and ends at164 * Expect to allocate a region that starts at min_addr and ends at
154 * max_addr, given that min_addr is aligned.165 * max_addr, given that min_addr is aligned.
155 */166 */
156static int alloc_try_nid_exact_address_generic_check(void)167static int alloc_nid_exact_address_generic_check(void)
157{168{
158 struct memblock_region *rgn = &memblock.reserved.regions[0];169 struct memblock_region *rgn = &memblock.reserved.regions[0];
159 void *allocated_ptr = NULL;170 void *allocated_ptr = NULL;
@@ -168,9 +179,9 @@ static int alloc_try_nid_exact_address_generic_check(void) · 8 unmodified lines
168 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES;179 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES;
169 max_addr = min_addr + size;180 max_addr = min_addr + size;
170 181
171 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,182 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
172 min_addr, max_addr,183 min_addr, max_addr,
173 NUMA_NO_NODE);184 NUMA_NO_NODE);
174 rgn_end = rgn->base + rgn->size;185 rgn_end = rgn->base + rgn->size;
175 186
176 ASSERT_NE(allocated_ptr, NULL);187 ASSERT_NE(allocated_ptr, NULL);
@@ -205,7 +216,7 @@ static int alloc_try_nid_exact_address_generic_check(void) · 28 unmodified lines
205 * Expect to drop the lower limit and allocate a memory region which216 * Expect to drop the lower limit and allocate a memory region which
206 * ends at max_addr (if the address is aligned).217 * ends at max_addr (if the address is aligned).
207 */218 */
208static int alloc_try_nid_top_down_narrow_range_check(void)219static int alloc_nid_top_down_narrow_range_check(void)
209{220{
210 struct memblock_region *rgn = &memblock.reserved.regions[0];221 struct memblock_region *rgn = &memblock.reserved.regions[0];
211 void *allocated_ptr = NULL;222 void *allocated_ptr = NULL;
@@ -219,9 +230,9 @@ static int alloc_try_nid_top_down_narrow_range_check(void) · 7 unmodified lines
219 min_addr = memblock_start_of_DRAM() + SZ_512;230 min_addr = memblock_start_of_DRAM() + SZ_512;
220 max_addr = min_addr + SMP_CACHE_BYTES;231 max_addr = min_addr + SMP_CACHE_BYTES;
221 232
222 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,233 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
223 min_addr, max_addr,234 min_addr, max_addr,
224 NUMA_NO_NODE);235 NUMA_NO_NODE);
225 236
226 ASSERT_NE(allocated_ptr, NULL);237 ASSERT_NE(allocated_ptr, NULL);
227 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);238 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -257,7 +268,7 @@ static int alloc_try_nid_top_down_narrow_range_check(void) · 29 unmodified lines
257 *268 *
258 * Expect no allocation to happen.269 * Expect no allocation to happen.
259 */270 */
260static int alloc_try_nid_low_max_generic_check(void)271static int alloc_nid_low_max_generic_check(void)
261{272{
262 void *allocated_ptr = NULL;273 void *allocated_ptr = NULL;
263 phys_addr_t size = SZ_1K;274 phys_addr_t size = SZ_1K;
@@ -270,9 +281,9 @@ static int alloc_try_nid_low_max_generic_check(void) · 6 unmodified lines
270 min_addr = memblock_start_of_DRAM();281 min_addr = memblock_start_of_DRAM();
271 max_addr = min_addr + SMP_CACHE_BYTES;282 max_addr = min_addr + SMP_CACHE_BYTES;
272 283
273 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,284 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
274 min_addr, max_addr,285 min_addr, max_addr,
275 NUMA_NO_NODE);286 NUMA_NO_NODE);
276 287
277 ASSERT_EQ(allocated_ptr, NULL);288 ASSERT_EQ(allocated_ptr, NULL);
278 289
@@ -295,7 +306,7 @@ static int alloc_try_nid_low_max_generic_check(void) · 16 unmodified lines
295 *306 *
296 * Expect a merge of both regions. Only the region size gets updated.307 * Expect a merge of both regions. Only the region size gets updated.
297 */308 */
298static int alloc_try_nid_min_reserved_generic_check(void)309static int alloc_nid_min_reserved_generic_check(void)
299{310{
300 struct memblock_region *rgn = &memblock.reserved.regions[0];311 struct memblock_region *rgn = &memblock.reserved.regions[0];
301 void *allocated_ptr = NULL;312 void *allocated_ptr = NULL;
@@ -315,9 +326,9 @@ static int alloc_try_nid_min_reserved_generic_check(void) · 13 unmodified lines
315 326
316 memblock_reserve(reserved_base, r1_size);327 memblock_reserve(reserved_base, r1_size);
317 328
318 allocated_ptr = run_memblock_alloc_try_nid(r2_size, SMP_CACHE_BYTES,329 allocated_ptr = run_memblock_alloc_nid(r2_size, SMP_CACHE_BYTES,
319 min_addr, max_addr,330 min_addr, max_addr,
320 NUMA_NO_NODE);331 NUMA_NO_NODE);
321 332
322 ASSERT_NE(allocated_ptr, NULL);333 ASSERT_NE(allocated_ptr, NULL);
323 assert_mem_content(allocated_ptr, r2_size, alloc_nid_test_flags);334 assert_mem_content(allocated_ptr, r2_size, alloc_nid_test_flags);
@@ -347,7 +358,7 @@ static int alloc_try_nid_min_reserved_generic_check(void) · 23 unmodified lines
347 *358 *
348 * Expect a merge of regions. Only the region size gets updated.359 * Expect a merge of regions. Only the region size gets updated.
349 */360 */
350static int alloc_try_nid_max_reserved_generic_check(void)361static int alloc_nid_max_reserved_generic_check(void)
351{362{
352 struct memblock_region *rgn = &memblock.reserved.regions[0];363 struct memblock_region *rgn = &memblock.reserved.regions[0];
353 void *allocated_ptr = NULL;364 void *allocated_ptr = NULL;
@@ -365,9 +376,9 @@ static int alloc_try_nid_max_reserved_generic_check(void) · 11 unmodified lines
365 376
366 memblock_reserve(max_addr, r1_size);377 memblock_reserve(max_addr, r1_size);
367 378
368 allocated_ptr = run_memblock_alloc_try_nid(r2_size, SMP_CACHE_BYTES,379 allocated_ptr = run_memblock_alloc_nid(r2_size, SMP_CACHE_BYTES,
369 min_addr, max_addr,380 min_addr, max_addr,
370 NUMA_NO_NODE);381 NUMA_NO_NODE);
371 382
372 ASSERT_NE(allocated_ptr, NULL);383 ASSERT_NE(allocated_ptr, NULL);
373 assert_mem_content(allocated_ptr, r2_size, alloc_nid_test_flags);384 assert_mem_content(allocated_ptr, r2_size, alloc_nid_test_flags);
@@ -400,7 +411,7 @@ static int alloc_try_nid_max_reserved_generic_check(void) · 26 unmodified lines
400 * updated. The total size field gets updated.411 * updated. The total size field gets updated.
401 */412 */
402 413
403static int alloc_try_nid_top_down_reserved_with_space_check(void)414static int alloc_nid_top_down_reserved_with_space_check(void)
404{415{
405 struct memblock_region *rgn1 = &memblock.reserved.regions[1];416 struct memblock_region *rgn1 = &memblock.reserved.regions[1];
406 struct memblock_region *rgn2 = &memblock.reserved.regions[0];417 struct memblock_region *rgn2 = &memblock.reserved.regions[0];
@@ -428,9 +439,9 @@ static int alloc_try_nid_top_down_reserved_with_space_check(void) · 21 unmodified lines
428 memblock_reserve(r1.base, r1.size);439 memblock_reserve(r1.base, r1.size);
429 memblock_reserve(r2.base, r2.size);440 memblock_reserve(r2.base, r2.size);
430 441
431 allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES,442 allocated_ptr = run_memblock_alloc_nid(r3_size, SMP_CACHE_BYTES,
432 min_addr, max_addr,443 min_addr, max_addr,
433 NUMA_NO_NODE);444 NUMA_NO_NODE);
434 445
435 ASSERT_NE(allocated_ptr, NULL);446 ASSERT_NE(allocated_ptr, NULL);
436 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);447 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);
@@ -465,7 +476,7 @@ static int alloc_try_nid_top_down_reserved_with_space_check(void) · 28 unmodified lines
465 * Expect to merge all of the regions into one. The region counter and total476 * Expect to merge all of the regions into one. The region counter and total
466 * size fields get updated.477 * size fields get updated.
467 */478 */
468static int alloc_try_nid_reserved_full_merge_generic_check(void)479static int alloc_nid_reserved_full_merge_generic_check(void)
469{480{
470 struct memblock_region *rgn = &memblock.reserved.regions[0];481 struct memblock_region *rgn = &memblock.reserved.regions[0];
471 void *allocated_ptr = NULL;482 void *allocated_ptr = NULL;
@@ -491,9 +502,9 @@ static int alloc_try_nid_reserved_full_merge_generic_check(void) · 19 unmodified lines
491 memblock_reserve(r1.base, r1.size);502 memblock_reserve(r1.base, r1.size);
492 memblock_reserve(r2.base, r2.size);503 memblock_reserve(r2.base, r2.size);
493 504
494 allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES,505 allocated_ptr = run_memblock_alloc_nid(r3_size, SMP_CACHE_BYTES,
495 min_addr, max_addr,506 min_addr, max_addr,
496 NUMA_NO_NODE);507 NUMA_NO_NODE);
497 508
498 ASSERT_NE(allocated_ptr, NULL);509 ASSERT_NE(allocated_ptr, NULL);
499 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);510 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);
@@ -527,7 +538,7 @@ static int alloc_try_nid_reserved_full_merge_generic_check(void) · 27 unmodified lines
527 * Expect to merge the new region with r2. The second region does not get538 * Expect to merge the new region with r2. The second region does not get
528 * updated. The total size counter gets updated.539 * updated. The total size counter gets updated.
529 */540 */
530static int alloc_try_nid_top_down_reserved_no_space_check(void)541static int alloc_nid_top_down_reserved_no_space_check(void)
531{542{
532 struct memblock_region *rgn1 = &memblock.reserved.regions[1];543 struct memblock_region *rgn1 = &memblock.reserved.regions[1];
533 struct memblock_region *rgn2 = &memblock.reserved.regions[0];544 struct memblock_region *rgn2 = &memblock.reserved.regions[0];
@@ -555,9 +566,9 @@ static int alloc_try_nid_top_down_reserved_no_space_check(void) · 21 unmodified lines
555 memblock_reserve(r1.base, r1.size);566 memblock_reserve(r1.base, r1.size);
556 memblock_reserve(r2.base, r2.size);567 memblock_reserve(r2.base, r2.size);
557 568
558 allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES,569 allocated_ptr = run_memblock_alloc_nid(r3_size, SMP_CACHE_BYTES,
559 min_addr, max_addr,570 min_addr, max_addr,
560 NUMA_NO_NODE);571 NUMA_NO_NODE);
561 572
562 ASSERT_NE(allocated_ptr, NULL);573 ASSERT_NE(allocated_ptr, NULL);
563 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);574 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);
@@ -596,7 +607,7 @@ static int alloc_try_nid_top_down_reserved_no_space_check(void) · 32 unmodified lines
596 * Expect no allocation to happen.607 * Expect no allocation to happen.
597 */608 */
598 609
599static int alloc_try_nid_reserved_all_generic_check(void)610static int alloc_nid_reserved_all_generic_check(void)
600{611{
601 void *allocated_ptr = NULL;612 void *allocated_ptr = NULL;
602 struct region r1, r2;613 struct region r1, r2;
@@ -620,9 +631,9 @@ static int alloc_try_nid_reserved_all_generic_check(void) · 17 unmodified lines
620 memblock_reserve(r1.base, r1.size);631 memblock_reserve(r1.base, r1.size);
621 memblock_reserve(r2.base, r2.size);632 memblock_reserve(r2.base, r2.size);
622 633
623 allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES,634 allocated_ptr = run_memblock_alloc_nid(r3_size, SMP_CACHE_BYTES,
624 min_addr, max_addr,635 min_addr, max_addr,
625 NUMA_NO_NODE);636 NUMA_NO_NODE);
626 637
627 ASSERT_EQ(allocated_ptr, NULL);638 ASSERT_EQ(allocated_ptr, NULL);
628 639
@@ -636,7 +647,7 @@ static int alloc_try_nid_reserved_all_generic_check(void) · 7 unmodified lines
636 * bigger than the end address of the available memory. Expect to allocate647 * bigger than the end address of the available memory. Expect to allocate
637 * a region that ends before the end of the memory.648 * a region that ends before the end of the memory.
638 */649 */
639static int alloc_try_nid_top_down_cap_max_check(void)650static int alloc_nid_top_down_cap_max_check(void)
640{651{
641 struct memblock_region *rgn = &memblock.reserved.regions[0];652 struct memblock_region *rgn = &memblock.reserved.regions[0];
642 void *allocated_ptr = NULL;653 void *allocated_ptr = NULL;
@@ -650,9 +661,9 @@ static int alloc_try_nid_top_down_cap_max_check(void) · 7 unmodified lines
650 min_addr = memblock_end_of_DRAM() - SZ_1K;661 min_addr = memblock_end_of_DRAM() - SZ_1K;
651 max_addr = memblock_end_of_DRAM() + SZ_256;662 max_addr = memblock_end_of_DRAM() + SZ_256;
652 663
653 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,664 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
654 min_addr, max_addr,665 min_addr, max_addr,
655 NUMA_NO_NODE);666 NUMA_NO_NODE);
656 667
657 ASSERT_NE(allocated_ptr, NULL);668 ASSERT_NE(allocated_ptr, NULL);
658 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);669 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -673,7 +684,7 @@ static int alloc_try_nid_top_down_cap_max_check(void) · 14 unmodified lines
673 * smaller than the start address of the available memory. Expect to allocate684 * smaller than the start address of the available memory. Expect to allocate
674 * a region that ends before the end of the memory.685 * a region that ends before the end of the memory.
675 */686 */
676static int alloc_try_nid_top_down_cap_min_check(void)687static int alloc_nid_top_down_cap_min_check(void)
677{688{
678 struct memblock_region *rgn = &memblock.reserved.regions[0];689 struct memblock_region *rgn = &memblock.reserved.regions[0];
679 void *allocated_ptr = NULL;690 void *allocated_ptr = NULL;
@@ -687,9 +698,9 @@ static int alloc_try_nid_top_down_cap_min_check(void) · 7 unmodified lines
687 min_addr = memblock_start_of_DRAM() - SZ_256;698 min_addr = memblock_start_of_DRAM() - SZ_256;
688 max_addr = memblock_end_of_DRAM();699 max_addr = memblock_end_of_DRAM();
689 700
690 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,701 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
691 min_addr, max_addr,702 min_addr, max_addr,
692 NUMA_NO_NODE);703 NUMA_NO_NODE);
693 704
694 ASSERT_NE(allocated_ptr, NULL);705 ASSERT_NE(allocated_ptr, NULL);
695 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);706 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -719,7 +730,7 @@ static int alloc_try_nid_top_down_cap_min_check(void) · 23 unmodified lines
719 *730 *
720 * Expect to allocate a region that ends before max_addr.731 * Expect to allocate a region that ends before max_addr.
721 */732 */
722static int alloc_try_nid_bottom_up_simple_check(void)733static int alloc_nid_bottom_up_simple_check(void)
723{734{
724 struct memblock_region *rgn = &memblock.reserved.regions[0];735 struct memblock_region *rgn = &memblock.reserved.regions[0];
725 void *allocated_ptr = NULL;736 void *allocated_ptr = NULL;
@@ -734,9 +745,9 @@ static int alloc_try_nid_bottom_up_simple_check(void) · 8 unmodified lines
734 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2;745 min_addr = memblock_start_of_DRAM() + SMP_CACHE_BYTES * 2;
735 max_addr = min_addr + SZ_512;746 max_addr = min_addr + SZ_512;
736 747
737 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,748 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
738 min_addr, max_addr,749 min_addr, max_addr,
739 NUMA_NO_NODE);750 NUMA_NO_NODE);
740 rgn_end = rgn->base + rgn->size;751 rgn_end = rgn->base + rgn->size;
741 752
742 ASSERT_NE(allocated_ptr, NULL);753 ASSERT_NE(allocated_ptr, NULL);
@@ -771,7 +782,7 @@ static int alloc_try_nid_bottom_up_simple_check(void) · 28 unmodified lines
771 *782 *
772 * Expect to allocate an aligned region that ends before max_addr.783 * Expect to allocate an aligned region that ends before max_addr.
773 */784 */
774static int alloc_try_nid_bottom_up_start_misaligned_check(void)785static int alloc_nid_bottom_up_start_misaligned_check(void)
775{786{
776 struct memblock_region *rgn = &memblock.reserved.regions[0];787 struct memblock_region *rgn = &memblock.reserved.regions[0];
777 void *allocated_ptr = NULL;788 void *allocated_ptr = NULL;
@@ -787,9 +798,9 @@ static int alloc_try_nid_bottom_up_start_misaligned_check(void) · 9 unmodified lines
787 min_addr = memblock_start_of_DRAM() + misalign;798 min_addr = memblock_start_of_DRAM() + misalign;
788 max_addr = min_addr + SZ_512;799 max_addr = min_addr + SZ_512;
789 800
790 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,801 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
791 min_addr, max_addr,802 min_addr, max_addr,
792 NUMA_NO_NODE);803 NUMA_NO_NODE);
793 rgn_end = rgn->base + rgn->size;804 rgn_end = rgn->base + rgn->size;
794 805
795 ASSERT_NE(allocated_ptr, NULL);806 ASSERT_NE(allocated_ptr, NULL);
@@ -824,7 +835,7 @@ static int alloc_try_nid_bottom_up_start_misaligned_check(void) · 28 unmodified lines
824 * Expect to drop the lower limit and allocate a memory region which835 * Expect to drop the lower limit and allocate a memory region which
825 * starts at the beginning of the available memory.836 * starts at the beginning of the available memory.
826 */837 */
827static int alloc_try_nid_bottom_up_narrow_range_check(void)838static int alloc_nid_bottom_up_narrow_range_check(void)
828{839{
829 struct memblock_region *rgn = &memblock.reserved.regions[0];840 struct memblock_region *rgn = &memblock.reserved.regions[0];
830 void *allocated_ptr = NULL;841 void *allocated_ptr = NULL;
@@ -838,9 +849,9 @@ static int alloc_try_nid_bottom_up_narrow_range_check(void) · 7 unmodified lines
838 min_addr = memblock_start_of_DRAM() + SZ_512;849 min_addr = memblock_start_of_DRAM() + SZ_512;
839 max_addr = min_addr + SMP_CACHE_BYTES;850 max_addr = min_addr + SMP_CACHE_BYTES;
840 851
841 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,852 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
842 min_addr, max_addr,853 min_addr, max_addr,
843 NUMA_NO_NODE);854 NUMA_NO_NODE);
844 855
845 ASSERT_NE(allocated_ptr, NULL);856 ASSERT_NE(allocated_ptr, NULL);
846 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);857 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -873,7 +884,7 @@ static int alloc_try_nid_bottom_up_narrow_range_check(void) · 26 unmodified lines
873 * updated. The total size field gets updated.884 * updated. The total size field gets updated.
874 */885 */
875 886
876static int alloc_try_nid_bottom_up_reserved_with_space_check(void)887static int alloc_nid_bottom_up_reserved_with_space_check(void)
877{888{
878 struct memblock_region *rgn1 = &memblock.reserved.regions[1];889 struct memblock_region *rgn1 = &memblock.reserved.regions[1];
879 struct memblock_region *rgn2 = &memblock.reserved.regions[0];890 struct memblock_region *rgn2 = &memblock.reserved.regions[0];
@@ -901,9 +912,9 @@ static int alloc_try_nid_bottom_up_reserved_with_space_check(void) · 21 unmodified lines
901 memblock_reserve(r1.base, r1.size);912 memblock_reserve(r1.base, r1.size);
902 memblock_reserve(r2.base, r2.size);913 memblock_reserve(r2.base, r2.size);
903 914
904 allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES,915 allocated_ptr = run_memblock_alloc_nid(r3_size, SMP_CACHE_BYTES,
905 min_addr, max_addr,916 min_addr, max_addr,
906 NUMA_NO_NODE);917 NUMA_NO_NODE);
907 918
908 ASSERT_NE(allocated_ptr, NULL);919 ASSERT_NE(allocated_ptr, NULL);
909 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);920 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);
@@ -942,7 +953,7 @@ static int alloc_try_nid_bottom_up_reserved_with_space_check(void) · 32 unmodified lines
942 * Other regions are not modified.953 * Other regions are not modified.
943 */954 */
944 955
945static int alloc_try_nid_bottom_up_reserved_no_space_check(void)956static int alloc_nid_bottom_up_reserved_no_space_check(void)
946{957{
947 struct memblock_region *rgn1 = &memblock.reserved.regions[2];958 struct memblock_region *rgn1 = &memblock.reserved.regions[2];
948 struct memblock_region *rgn2 = &memblock.reserved.regions[1];959 struct memblock_region *rgn2 = &memblock.reserved.regions[1];
@@ -971,9 +982,9 @@ static int alloc_try_nid_bottom_up_reserved_no_space_check(void) · 22 unmodified lines
971 memblock_reserve(r1.base, r1.size);982 memblock_reserve(r1.base, r1.size);
972 memblock_reserve(r2.base, r2.size);983 memblock_reserve(r2.base, r2.size);
973 984
974 allocated_ptr = run_memblock_alloc_try_nid(r3_size, SMP_CACHE_BYTES,985 allocated_ptr = run_memblock_alloc_nid(r3_size, SMP_CACHE_BYTES,
975 min_addr, max_addr,986 min_addr, max_addr,
976 NUMA_NO_NODE);987 NUMA_NO_NODE);
977 988
978 ASSERT_NE(allocated_ptr, NULL);989 ASSERT_NE(allocated_ptr, NULL);
979 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);990 assert_mem_content(allocated_ptr, r3_size, alloc_nid_test_flags);
@@ -1000,7 +1011,7 @@ static int alloc_try_nid_bottom_up_reserved_no_space_check(void) · 20 unmodified lines
1000 * bigger than the end address of the available memory. Expect to allocate1011 * bigger than the end address of the available memory. Expect to allocate
1001 * a region that starts at the min_addr.1012 * a region that starts at the min_addr.
1002 */1013 */
1003static int alloc_try_nid_bottom_up_cap_max_check(void)1014static int alloc_nid_bottom_up_cap_max_check(void)
1004{1015{
1005 struct memblock_region *rgn = &memblock.reserved.regions[0];1016 struct memblock_region *rgn = &memblock.reserved.regions[0];
1006 void *allocated_ptr = NULL;1017 void *allocated_ptr = NULL;
@@ -1014,9 +1025,9 @@ static int alloc_try_nid_bottom_up_cap_max_check(void) · 7 unmodified lines
1014 min_addr = memblock_start_of_DRAM() + SZ_1K;1025 min_addr = memblock_start_of_DRAM() + SZ_1K;
1015 max_addr = memblock_end_of_DRAM() + SZ_256;1026 max_addr = memblock_end_of_DRAM() + SZ_256;
1016 1027
1017 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1028 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1018 min_addr, max_addr,1029 min_addr, max_addr,
1019 NUMA_NO_NODE);1030 NUMA_NO_NODE);
1020 1031
1021 ASSERT_NE(allocated_ptr, NULL);1032 ASSERT_NE(allocated_ptr, NULL);
1022 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1033 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1037,7 +1048,7 @@ static int alloc_try_nid_bottom_up_cap_max_check(void) · 14 unmodified lines
1037 * smaller than the start address of the available memory. Expect to allocate1048 * smaller than the start address of the available memory. Expect to allocate
1038 * a region at the beginning of the available memory.1049 * a region at the beginning of the available memory.
1039 */1050 */
1040static int alloc_try_nid_bottom_up_cap_min_check(void)1051static int alloc_nid_bottom_up_cap_min_check(void)
1041{1052{
1042 struct memblock_region *rgn = &memblock.reserved.regions[0];1053 struct memblock_region *rgn = &memblock.reserved.regions[0];
1043 void *allocated_ptr = NULL;1054 void *allocated_ptr = NULL;
@@ -1051,9 +1062,9 @@ static int alloc_try_nid_bottom_up_cap_min_check(void) · 7 unmodified lines
1051 min_addr = memblock_start_of_DRAM();1062 min_addr = memblock_start_of_DRAM();
1052 max_addr = memblock_end_of_DRAM() - SZ_256;1063 max_addr = memblock_end_of_DRAM() - SZ_256;
1053 1064
1054 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1065 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1055 min_addr, max_addr,1066 min_addr, max_addr,
1056 NUMA_NO_NODE);1067 NUMA_NO_NODE);
1057 1068
1058 ASSERT_NE(allocated_ptr, NULL);1069 ASSERT_NE(allocated_ptr, NULL);
1059 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1070 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1070,133 +1081,133 @@ static int alloc_try_nid_bottom_up_cap_min_check(void) · 10 unmodified lines
1070}1081}
1071 1082
1072/* Test case wrappers for range tests */1083/* Test case wrappers for range tests */
1073static int alloc_try_nid_simple_check(void)1084static int alloc_nid_simple_check(void)
1074{1085{
1075 test_print("\tRunning %s...\n", __func__);1086 test_print("\tRunning %s...\n", __func__);
1076 memblock_set_bottom_up(false);1087 memblock_set_bottom_up(false);
1077 alloc_try_nid_top_down_simple_check();1088 alloc_nid_top_down_simple_check();
1078 memblock_set_bottom_up(true);1089 memblock_set_bottom_up(true);
1079 alloc_try_nid_bottom_up_simple_check();1090 alloc_nid_bottom_up_simple_check();
1080 1091
1081 return 0;1092 return 0;
1082}1093}
1083 1094
1084static int alloc_try_nid_misaligned_check(void)1095static int alloc_nid_misaligned_check(void)
1085{1096{
1086 test_print("\tRunning %s...\n", __func__);1097 test_print("\tRunning %s...\n", __func__);
1087 memblock_set_bottom_up(false);1098 memblock_set_bottom_up(false);
1088 alloc_try_nid_top_down_end_misaligned_check();1099 alloc_nid_top_down_end_misaligned_check();
1089 memblock_set_bottom_up(true);1100 memblock_set_bottom_up(true);
1090 alloc_try_nid_bottom_up_start_misaligned_check();1101 alloc_nid_bottom_up_start_misaligned_check();
1091 1102
1092 return 0;1103 return 0;
1093}1104}
1094 1105
1095static int alloc_try_nid_narrow_range_check(void)1106static int alloc_nid_narrow_range_check(void)
1096{1107{
1097 test_print("\tRunning %s...\n", __func__);1108 test_print("\tRunning %s...\n", __func__);
1098 memblock_set_bottom_up(false);1109 memblock_set_bottom_up(false);
1099 alloc_try_nid_top_down_narrow_range_check();1110 alloc_nid_top_down_narrow_range_check();
1100 memblock_set_bottom_up(true);1111 memblock_set_bottom_up(true);
1101 alloc_try_nid_bottom_up_narrow_range_check();1112 alloc_nid_bottom_up_narrow_range_check();
1102 1113
1103 return 0;1114 return 0;
1104}1115}
1105 1116
1106static int alloc_try_nid_reserved_with_space_check(void)1117static int alloc_nid_reserved_with_space_check(void)
1107{1118{
1108 test_print("\tRunning %s...\n", __func__);1119 test_print("\tRunning %s...\n", __func__);
1109 memblock_set_bottom_up(false);1120 memblock_set_bottom_up(false);
1110 alloc_try_nid_top_down_reserved_with_space_check();1121 alloc_nid_top_down_reserved_with_space_check();
1111 memblock_set_bottom_up(true);1122 memblock_set_bottom_up(true);
1112 alloc_try_nid_bottom_up_reserved_with_space_check();1123 alloc_nid_bottom_up_reserved_with_space_check();
1113 1124
1114 return 0;1125 return 0;
1115}1126}
1116 1127
1117static int alloc_try_nid_reserved_no_space_check(void)1128static int alloc_nid_reserved_no_space_check(void)
1118{1129{
1119 test_print("\tRunning %s...\n", __func__);1130 test_print("\tRunning %s...\n", __func__);
1120 memblock_set_bottom_up(false);1131 memblock_set_bottom_up(false);
1121 alloc_try_nid_top_down_reserved_no_space_check();1132 alloc_nid_top_down_reserved_no_space_check();
1122 memblock_set_bottom_up(true);1133 memblock_set_bottom_up(true);
1123 alloc_try_nid_bottom_up_reserved_no_space_check();1134 alloc_nid_bottom_up_reserved_no_space_check();
1124 1135
1125 return 0;1136 return 0;
1126}1137}
1127 1138
1128static int alloc_try_nid_cap_max_check(void)1139static int alloc_nid_cap_max_check(void)
1129{1140{
1130 test_print("\tRunning %s...\n", __func__);1141 test_print("\tRunning %s...\n", __func__);
1131 memblock_set_bottom_up(false);1142 memblock_set_bottom_up(false);
1132 alloc_try_nid_top_down_cap_max_check();1143 alloc_nid_top_down_cap_max_check();
1133 memblock_set_bottom_up(true);1144 memblock_set_bottom_up(true);
1134 alloc_try_nid_bottom_up_cap_max_check();1145 alloc_nid_bottom_up_cap_max_check();
1135 1146
1136 return 0;1147 return 0;
1137}1148}
1138 1149
1139static int alloc_try_nid_cap_min_check(void)1150static int alloc_nid_cap_min_check(void)
1140{1151{
1141 test_print("\tRunning %s...\n", __func__);1152 test_print("\tRunning %s...\n", __func__);
1142 memblock_set_bottom_up(false);1153 memblock_set_bottom_up(false);
1143 alloc_try_nid_top_down_cap_min_check();1154 alloc_nid_top_down_cap_min_check();
1144 memblock_set_bottom_up(true);1155 memblock_set_bottom_up(true);
1145 alloc_try_nid_bottom_up_cap_min_check();1156 alloc_nid_bottom_up_cap_min_check();
1146 1157
1147 return 0;1158 return 0;
1148}1159}
1149 1160
1150static int alloc_try_nid_min_reserved_check(void)1161static int alloc_nid_min_reserved_check(void)
1151{1162{
1152 test_print("\tRunning %s...\n", __func__);1163 test_print("\tRunning %s...\n", __func__);
1153 run_top_down(alloc_try_nid_min_reserved_generic_check);1164 run_top_down(alloc_nid_min_reserved_generic_check);
1154 run_bottom_up(alloc_try_nid_min_reserved_generic_check);1165 run_bottom_up(alloc_nid_min_reserved_generic_check);
1155 1166
1156 return 0;1167 return 0;
1157}1168}
1158 1169
1159static int alloc_try_nid_max_reserved_check(void)1170static int alloc_nid_max_reserved_check(void)
1160{1171{
1161 test_print("\tRunning %s...\n", __func__);1172 test_print("\tRunning %s...\n", __func__);
1162 run_top_down(alloc_try_nid_max_reserved_generic_check);1173 run_top_down(alloc_nid_max_reserved_generic_check);
1163 run_bottom_up(alloc_try_nid_max_reserved_generic_check);1174 run_bottom_up(alloc_nid_max_reserved_generic_check);
1164 1175
1165 return 0;1176 return 0;
1166}1177}
1167 1178
1168static int alloc_try_nid_exact_address_check(void)1179static int alloc_nid_exact_address_check(void)
1169{1180{
1170 test_print("\tRunning %s...\n", __func__);1181 test_print("\tRunning %s...\n", __func__);
1171 run_top_down(alloc_try_nid_exact_address_generic_check);1182 run_top_down(alloc_nid_exact_address_generic_check);
1172 run_bottom_up(alloc_try_nid_exact_address_generic_check);1183 run_bottom_up(alloc_nid_exact_address_generic_check);
1173 1184
1174 return 0;1185 return 0;
1175}1186}
1176 1187
1177static int alloc_try_nid_reserved_full_merge_check(void)1188static int alloc_nid_reserved_full_merge_check(void)
1178{1189{
1179 test_print("\tRunning %s...\n", __func__);1190 test_print("\tRunning %s...\n", __func__);
1180 run_top_down(alloc_try_nid_reserved_full_merge_generic_check);1191 run_top_down(alloc_nid_reserved_full_merge_generic_check);
1181 run_bottom_up(alloc_try_nid_reserved_full_merge_generic_check);1192 run_bottom_up(alloc_nid_reserved_full_merge_generic_check);
1182 1193
1183 return 0;1194 return 0;
1184}1195}
1185 1196
1186static int alloc_try_nid_reserved_all_check(void)1197static int alloc_nid_reserved_all_check(void)
1187{1198{
1188 test_print("\tRunning %s...\n", __func__);1199 test_print("\tRunning %s...\n", __func__);
1189 run_top_down(alloc_try_nid_reserved_all_generic_check);1200 run_top_down(alloc_nid_reserved_all_generic_check);
1190 run_bottom_up(alloc_try_nid_reserved_all_generic_check);1201 run_bottom_up(alloc_nid_reserved_all_generic_check);
1191 1202
1192 return 0;1203 return 0;
1193}1204}
1194 1205
1195static int alloc_try_nid_low_max_check(void)1206static int alloc_nid_low_max_check(void)
1196{1207{
1197 test_print("\tRunning %s...\n", __func__);1208 test_print("\tRunning %s...\n", __func__);
1198 run_top_down(alloc_try_nid_low_max_generic_check);1209 run_top_down(alloc_nid_low_max_generic_check);
1199 run_bottom_up(alloc_try_nid_low_max_generic_check);1210 run_bottom_up(alloc_nid_low_max_generic_check);
1200 1211
1201 return 0;1212 return 0;
1202}1213}
@@ -1204,22 +1215,22 @@ static int alloc_try_nid_low_max_check(void) · 1 unmodified line
1204static int memblock_alloc_nid_range_checks(void)1215static int memblock_alloc_nid_range_checks(void)
1205{1216{
1206 test_print("Running %s range tests...\n",1217 test_print("Running %s range tests...\n",
1207 get_memblock_alloc_try_nid_name(alloc_nid_test_flags));1218 get_memblock_alloc_nid_name(alloc_nid_test_flags));
1208 1219
1209 alloc_try_nid_simple_check();1220 alloc_nid_simple_check();
1210 alloc_try_nid_misaligned_check();1221 alloc_nid_misaligned_check();
1211 alloc_try_nid_narrow_range_check();1222 alloc_nid_narrow_range_check();
1212 alloc_try_nid_reserved_with_space_check();1223 alloc_nid_reserved_with_space_check();
1213 alloc_try_nid_reserved_no_space_check();1224 alloc_nid_reserved_no_space_check();
1214 alloc_try_nid_cap_max_check();1225 alloc_nid_cap_max_check();
1215 alloc_try_nid_cap_min_check();1226 alloc_nid_cap_min_check();
1216 1227
1217 alloc_try_nid_min_reserved_check();1228 alloc_nid_min_reserved_check();
1218 alloc_try_nid_max_reserved_check();1229 alloc_nid_max_reserved_check();
1219 alloc_try_nid_exact_address_check();1230 alloc_nid_exact_address_check();
1220 alloc_try_nid_reserved_full_merge_check();1231 alloc_nid_reserved_full_merge_check();
1221 alloc_try_nid_reserved_all_check();1232 alloc_nid_reserved_all_check();
1222 alloc_try_nid_low_max_check();1233 alloc_nid_low_max_check();
1223 1234
1224 return 0;1235 return 0;
1225}1236}
@@ -1229,7 +1240,7 @@ static int memblock_alloc_nid_range_checks(void) · 3 unmodified lines
1229 * has enough memory to allocate a region of the requested size.1240 * has enough memory to allocate a region of the requested size.
1230 * Expect to allocate an aligned region at the end of the requested node.1241 * Expect to allocate an aligned region at the end of the requested node.
1231 */1242 */
1232static int alloc_try_nid_top_down_numa_simple_check(void)1243static int alloc_nid_top_down_numa_simple_check(void)
1233{1244{
1234 int nid_req = 3;1245 int nid_req = 3;
1235 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1246 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1247,8 +1258,8 @@ static int alloc_try_nid_top_down_numa_simple_check(void) · 11 unmodified lines
1247 min_addr = memblock_start_of_DRAM();1258 min_addr = memblock_start_of_DRAM();
1248 max_addr = memblock_end_of_DRAM();1259 max_addr = memblock_end_of_DRAM();
1249 1260
1250 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1261 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1251 min_addr, max_addr, nid_req);1262 min_addr, max_addr, nid_req);
1252 1263
1253 ASSERT_NE(allocated_ptr, NULL);1264 ASSERT_NE(allocated_ptr, NULL);
1254 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1265 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1280,7 +1291,7 @@ static int alloc_try_nid_top_down_numa_simple_check(void) · 25 unmodified lines
1280 * Expect to allocate an aligned region at the end of the last node that has1291 * Expect to allocate an aligned region at the end of the last node that has
1281 * enough memory (in this case, nid = 6) after falling back to NUMA_NO_NODE.1292 * enough memory (in this case, nid = 6) after falling back to NUMA_NO_NODE.
1282 */1293 */
1283static int alloc_try_nid_top_down_numa_small_node_check(void)1294static int alloc_nid_top_down_numa_small_node_check(void)
1284{1295{
1285 int nid_req = 1;1296 int nid_req = 1;
1286 int nid_exp = 6;1297 int nid_exp = 6;
@@ -1299,8 +1310,8 @@ static int alloc_try_nid_top_down_numa_small_node_check(void) · 12 unmodified lines
1299 min_addr = memblock_start_of_DRAM();1310 min_addr = memblock_start_of_DRAM();
1300 max_addr = memblock_end_of_DRAM();1311 max_addr = memblock_end_of_DRAM();
1301 1312
1302 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1313 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1303 min_addr, max_addr, nid_req);1314 min_addr, max_addr, nid_req);
1304 1315
1305 ASSERT_NE(allocated_ptr, NULL);1316 ASSERT_NE(allocated_ptr, NULL);
1306 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1317 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1333,7 +1344,7 @@ static int alloc_try_nid_top_down_numa_small_node_check(void) · 26 unmodified lines
1333 * large enough and has enough unreserved memory (in this case, nid = 6) after1344 * large enough and has enough unreserved memory (in this case, nid = 6) after
1334 * falling back to NUMA_NO_NODE. The region count and total size get updated.1345 * falling back to NUMA_NO_NODE. The region count and total size get updated.
1335 */1346 */
1336static int alloc_try_nid_top_down_numa_node_reserved_check(void)1347static int alloc_nid_top_down_numa_node_reserved_check(void)
1337{1348{
1338 int nid_req = 2;1349 int nid_req = 2;
1339 int nid_exp = 6;1350 int nid_exp = 6;
@@ -1353,8 +1364,8 @@ static int alloc_try_nid_top_down_numa_node_reserved_check(void) · 13 unmodified lines
1353 max_addr = memblock_end_of_DRAM();1364 max_addr = memblock_end_of_DRAM();
1354 1365
1355 memblock_reserve(req_node->base, req_node->size);1366 memblock_reserve(req_node->base, req_node->size);
1356 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1367 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1357 min_addr, max_addr, nid_req);1368 min_addr, max_addr, nid_req);
1358 1369
1359 ASSERT_NE(allocated_ptr, NULL);1370 ASSERT_NE(allocated_ptr, NULL);
1360 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1371 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1386,7 +1397,7 @@ static int alloc_try_nid_top_down_numa_node_reserved_check(void) · 25 unmodified lines
1386 * Expect to allocate an aligned region at the end of the requested node. The1397 * Expect to allocate an aligned region at the end of the requested node. The
1387 * region count and total size get updated.1398 * region count and total size get updated.
1388 */1399 */
1389static int alloc_try_nid_top_down_numa_part_reserved_check(void)1400static int alloc_nid_top_down_numa_part_reserved_check(void)
1390{1401{
1391 int nid_req = 4;1402 int nid_req = 4;
1392 struct memblock_region *new_rgn = &memblock.reserved.regions[1];1403 struct memblock_region *new_rgn = &memblock.reserved.regions[1];
@@ -1408,8 +1419,8 @@ static int alloc_try_nid_top_down_numa_part_reserved_check(void) · 15 unmodified lines
1408 max_addr = memblock_end_of_DRAM();1419 max_addr = memblock_end_of_DRAM();
1409 1420
1410 memblock_reserve(r1.base, r1.size);1421 memblock_reserve(r1.base, r1.size);
1411 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1422 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1412 min_addr, max_addr, nid_req);1423 min_addr, max_addr, nid_req);
1413 1424
1414 ASSERT_NE(allocated_ptr, NULL);1425 ASSERT_NE(allocated_ptr, NULL);
1415 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1426 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1444,7 +1455,7 @@ static int alloc_try_nid_top_down_numa_part_reserved_check(void) · 28 unmodified lines
1444 * nid = NUMA_NODES - 1) after falling back to NUMA_NO_NODE. The region count1455 * nid = NUMA_NODES - 1) after falling back to NUMA_NO_NODE. The region count
1445 * and total size get updated.1456 * and total size get updated.
1446 */1457 */
1447static int alloc_try_nid_top_down_numa_part_reserved_fallback_check(void)1458static int alloc_nid_top_down_numa_part_reserved_fallback_check(void)
1448{1459{
1449 int nid_req = 4;1460 int nid_req = 4;
1450 int nid_exp = NUMA_NODES - 1;1461 int nid_exp = NUMA_NODES - 1;
@@ -1469,8 +1480,8 @@ static int alloc_try_nid_top_down_numa_part_reserved_fallback_check(void) · 18 unmodified lines
1469 max_addr = memblock_end_of_DRAM();1480 max_addr = memblock_end_of_DRAM();
1470 1481
1471 memblock_reserve(r1.base, r1.size);1482 memblock_reserve(r1.base, r1.size);
1472 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1483 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1473 min_addr, max_addr, nid_req);1484 min_addr, max_addr, nid_req);
1474 1485
1475 ASSERT_NE(allocated_ptr, NULL);1486 ASSERT_NE(allocated_ptr, NULL);
1476 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1487 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1507,7 +1518,7 @@ static int alloc_try_nid_top_down_numa_part_reserved_fallback_check(void) · 30 unmodified lines
1507 * Expect to drop the lower limit and allocate a memory region that ends at1518 * Expect to drop the lower limit and allocate a memory region that ends at
1508 * the end of the requested node.1519 * the end of the requested node.
1509 */1520 */
1510static int alloc_try_nid_top_down_numa_split_range_low_check(void)1521static int alloc_nid_top_down_numa_split_range_low_check(void)
1511{1522{
1512 int nid_req = 2;1523 int nid_req = 2;
1513 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1524 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1525,8 +1536,8 @@ static int alloc_try_nid_top_down_numa_split_range_low_check(void) · 11 unmodified lines
1525 min_addr = req_node_end - SZ_256;1536 min_addr = req_node_end - SZ_256;
1526 max_addr = min_addr + size;1537 max_addr = min_addr + size;
1527 1538
1528 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1539 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1529 min_addr, max_addr, nid_req);1540 min_addr, max_addr, nid_req);
1530 1541
1531 ASSERT_NE(allocated_ptr, NULL);1542 ASSERT_NE(allocated_ptr, NULL);
1532 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1543 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1563,7 +1574,7 @@ static int alloc_try_nid_top_down_numa_split_range_low_check(void) · 30 unmodified lines
1563 * Expect to drop the lower limit and allocate a memory region that1574 * Expect to drop the lower limit and allocate a memory region that
1564 * ends at the end of the first node that overlaps with the range.1575 * ends at the end of the first node that overlaps with the range.
1565 */1576 */
1566static int alloc_try_nid_top_down_numa_split_range_high_check(void)1577static int alloc_nid_top_down_numa_split_range_high_check(void)
1567{1578{
1568 int nid_req = 3;1579 int nid_req = 3;
1569 int nid_exp = nid_req - 1;1580 int nid_exp = nid_req - 1;
@@ -1582,8 +1593,8 @@ static int alloc_try_nid_top_down_numa_split_range_high_check(void) · 12 unmodified lines
1582 min_addr = exp_node_end - SZ_256;1593 min_addr = exp_node_end - SZ_256;
1583 max_addr = min_addr + size;1594 max_addr = min_addr + size;
1584 1595
1585 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1596 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1586 min_addr, max_addr, nid_req);1597 min_addr, max_addr, nid_req);
1587 1598
1588 ASSERT_NE(allocated_ptr, NULL);1599 ASSERT_NE(allocated_ptr, NULL);
1589 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1600 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1620,7 +1631,7 @@ static int alloc_try_nid_top_down_numa_split_range_high_check(void) · 30 unmodified lines
1620 * Expect to drop the lower limit and allocate a memory region that ends at1631 * Expect to drop the lower limit and allocate a memory region that ends at
1621 * the end of the requested node.1632 * the end of the requested node.
1622 */1633 */
1623static int alloc_try_nid_top_down_numa_no_overlap_split_check(void)1634static int alloc_nid_top_down_numa_no_overlap_split_check(void)
1624{1635{
1625 int nid_req = 2;1636 int nid_req = 2;
1626 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1637 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1638,8 +1649,8 @@ static int alloc_try_nid_top_down_numa_no_overlap_split_check(void) · 11 unmodified lines
1638 min_addr = node2->base - SZ_256;1649 min_addr = node2->base - SZ_256;
1639 max_addr = min_addr + size;1650 max_addr = min_addr + size;
1640 1651
1641 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1652 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1642 min_addr, max_addr, nid_req);1653 min_addr, max_addr, nid_req);
1643 1654
1644 ASSERT_NE(allocated_ptr, NULL);1655 ASSERT_NE(allocated_ptr, NULL);
1645 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1656 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1677,7 +1688,7 @@ static int alloc_try_nid_top_down_numa_no_overlap_split_check(void) · 31 unmodified lines
1677 * Expect to allocate a memory region at the end of the final node in1688 * Expect to allocate a memory region at the end of the final node in
1678 * the range after falling back to NUMA_NO_NODE.1689 * the range after falling back to NUMA_NO_NODE.
1679 */1690 */
1680static int alloc_try_nid_top_down_numa_no_overlap_low_check(void)1691static int alloc_nid_top_down_numa_no_overlap_low_check(void)
1681{1692{
1682 int nid_req = 0;1693 int nid_req = 0;
1683 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1694 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1694,8 +1705,8 @@ static int alloc_try_nid_top_down_numa_no_overlap_low_check(void) · 10 unmodified lines
1694 min_addr = min_node->base;1705 min_addr = min_node->base;
1695 max_addr = region_end(max_node);1706 max_addr = region_end(max_node);
1696 1707
1697 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1708 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1698 min_addr, max_addr, nid_req);1709 min_addr, max_addr, nid_req);
1699 1710
1700 ASSERT_NE(allocated_ptr, NULL);1711 ASSERT_NE(allocated_ptr, NULL);
1701 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1712 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1733,7 +1744,7 @@ static int alloc_try_nid_top_down_numa_no_overlap_low_check(void) · 31 unmodified lines
1733 * Expect to allocate a memory region at the end of the final node in1744 * Expect to allocate a memory region at the end of the final node in
1734 * the range after falling back to NUMA_NO_NODE.1745 * the range after falling back to NUMA_NO_NODE.
1735 */1746 */
1736static int alloc_try_nid_top_down_numa_no_overlap_high_check(void)1747static int alloc_nid_top_down_numa_no_overlap_high_check(void)
1737{1748{
1738 int nid_req = 7;1749 int nid_req = 7;
1739 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1750 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1750,8 +1761,8 @@ static int alloc_try_nid_top_down_numa_no_overlap_high_check(void) · 10 unmodified lines
1750 min_addr = min_node->base;1761 min_addr = min_node->base;
1751 max_addr = region_end(max_node);1762 max_addr = region_end(max_node);
1752 1763
1753 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1764 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1754 min_addr, max_addr, nid_req);1765 min_addr, max_addr, nid_req);
1755 1766
1756 ASSERT_NE(allocated_ptr, NULL);1767 ASSERT_NE(allocated_ptr, NULL);
1757 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1768 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1773,7 +1784,7 @@ static int alloc_try_nid_top_down_numa_no_overlap_high_check(void) · 15 unmodified lines
1773 * has enough memory to allocate a region of the requested size.1784 * has enough memory to allocate a region of the requested size.
1774 * Expect to allocate an aligned region at the beginning of the requested node.1785 * Expect to allocate an aligned region at the beginning of the requested node.
1775 */1786 */
1776static int alloc_try_nid_bottom_up_numa_simple_check(void)1787static int alloc_nid_bottom_up_numa_simple_check(void)
1777{1788{
1778 int nid_req = 3;1789 int nid_req = 3;
1779 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1790 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1791,8 +1802,8 @@ static int alloc_try_nid_bottom_up_numa_simple_check(void) · 11 unmodified lines
1791 min_addr = memblock_start_of_DRAM();1802 min_addr = memblock_start_of_DRAM();
1792 max_addr = memblock_end_of_DRAM();1803 max_addr = memblock_end_of_DRAM();
1793 1804
1794 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1805 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1795 min_addr, max_addr, nid_req);1806 min_addr, max_addr, nid_req);
1796 1807
1797 ASSERT_NE(allocated_ptr, NULL);1808 ASSERT_NE(allocated_ptr, NULL);
1798 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1809 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1824,7 +1835,7 @@ static int alloc_try_nid_bottom_up_numa_simple_check(void) · 25 unmodified lines
1824 * Expect to allocate an aligned region at the beginning of the first node that1835 * Expect to allocate an aligned region at the beginning of the first node that
1825 * has enough memory (in this case, nid = 0) after falling back to NUMA_NO_NODE.1836 * has enough memory (in this case, nid = 0) after falling back to NUMA_NO_NODE.
1826 */1837 */
1827static int alloc_try_nid_bottom_up_numa_small_node_check(void)1838static int alloc_nid_bottom_up_numa_small_node_check(void)
1828{1839{
1829 int nid_req = 1;1840 int nid_req = 1;
1830 int nid_exp = 0;1841 int nid_exp = 0;
@@ -1843,8 +1854,8 @@ static int alloc_try_nid_bottom_up_numa_small_node_check(void) · 12 unmodified lines
1843 min_addr = memblock_start_of_DRAM();1854 min_addr = memblock_start_of_DRAM();
1844 max_addr = memblock_end_of_DRAM();1855 max_addr = memblock_end_of_DRAM();
1845 1856
1846 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1857 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1847 min_addr, max_addr, nid_req);1858 min_addr, max_addr, nid_req);
1848 1859
1849 ASSERT_NE(allocated_ptr, NULL);1860 ASSERT_NE(allocated_ptr, NULL);
1850 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1861 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1878,7 +1889,7 @@ static int alloc_try_nid_bottom_up_numa_small_node_check(void) · 27 unmodified lines
1878 * after falling back to NUMA_NO_NODE. The region count and total size get1889 * after falling back to NUMA_NO_NODE. The region count and total size get
1879 * updated.1890 * updated.
1880 */1891 */
1881static int alloc_try_nid_bottom_up_numa_node_reserved_check(void)1892static int alloc_nid_bottom_up_numa_node_reserved_check(void)
1882{1893{
1883 int nid_req = 2;1894 int nid_req = 2;
1884 int nid_exp = 0;1895 int nid_exp = 0;
@@ -1898,8 +1909,8 @@ static int alloc_try_nid_bottom_up_numa_node_reserved_check(void) · 13 unmodified lines
1898 max_addr = memblock_end_of_DRAM();1909 max_addr = memblock_end_of_DRAM();
1899 1910
1900 memblock_reserve(req_node->base, req_node->size);1911 memblock_reserve(req_node->base, req_node->size);
1901 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1912 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1902 min_addr, max_addr, nid_req);1913 min_addr, max_addr, nid_req);
1903 1914
1904 ASSERT_NE(allocated_ptr, NULL);1915 ASSERT_NE(allocated_ptr, NULL);
1905 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1916 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1931,7 +1942,7 @@ static int alloc_try_nid_bottom_up_numa_node_reserved_check(void) · 25 unmodified lines
1931 * Expect to allocate an aligned region in the requested node that merges with1942 * Expect to allocate an aligned region in the requested node that merges with
1932 * the existing reserved region. The total size gets updated.1943 * the existing reserved region. The total size gets updated.
1933 */1944 */
1934static int alloc_try_nid_bottom_up_numa_part_reserved_check(void)1945static int alloc_nid_bottom_up_numa_part_reserved_check(void)
1935{1946{
1936 int nid_req = 4;1947 int nid_req = 4;
1937 struct memblock_region *new_rgn = &memblock.reserved.regions[0];1948 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -1955,8 +1966,8 @@ static int alloc_try_nid_bottom_up_numa_part_reserved_check(void) · 17 unmodified lines
1955 total_size = size + r1.size;1966 total_size = size + r1.size;
1956 1967
1957 memblock_reserve(r1.base, r1.size);1968 memblock_reserve(r1.base, r1.size);
1958 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,1969 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
1959 min_addr, max_addr, nid_req);1970 min_addr, max_addr, nid_req);
1960 1971
1961 ASSERT_NE(allocated_ptr, NULL);1972 ASSERT_NE(allocated_ptr, NULL);
1962 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);1973 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -1991,7 +2002,7 @@ static int alloc_try_nid_bottom_up_numa_part_reserved_check(void) · 28 unmodified lines
1991 * nid = 0) after falling back to NUMA_NO_NODE. The region count and total size2002 * nid = 0) after falling back to NUMA_NO_NODE. The region count and total size
1992 * get updated.2003 * get updated.
1993 */2004 */
1994static int alloc_try_nid_bottom_up_numa_part_reserved_fallback_check(void)2005static int alloc_nid_bottom_up_numa_part_reserved_fallback_check(void)
1995{2006{
1996 int nid_req = 4;2007 int nid_req = 4;
1997 int nid_exp = 0;2008 int nid_exp = 0;
@@ -2016,8 +2027,8 @@ static int alloc_try_nid_bottom_up_numa_part_reserved_fallback_check(void) · 18 unmodified lines
2016 max_addr = memblock_end_of_DRAM();2027 max_addr = memblock_end_of_DRAM();
2017 2028
2018 memblock_reserve(r1.base, r1.size);2029 memblock_reserve(r1.base, r1.size);
2019 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2030 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2020 min_addr, max_addr, nid_req);2031 min_addr, max_addr, nid_req);
2021 2032
2022 ASSERT_NE(allocated_ptr, NULL);2033 ASSERT_NE(allocated_ptr, NULL);
2023 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2034 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2054,7 +2065,7 @@ static int alloc_try_nid_bottom_up_numa_part_reserved_fallback_check(void) · 30 unmodified lines
2054 * Expect to drop the lower limit and allocate a memory region at the beginning2065 * Expect to drop the lower limit and allocate a memory region at the beginning
2055 * of the requested node.2066 * of the requested node.
2056 */2067 */
2057static int alloc_try_nid_bottom_up_numa_split_range_low_check(void)2068static int alloc_nid_bottom_up_numa_split_range_low_check(void)
2058{2069{
2059 int nid_req = 2;2070 int nid_req = 2;
2060 struct memblock_region *new_rgn = &memblock.reserved.regions[0];2071 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -2072,8 +2083,8 @@ static int alloc_try_nid_bottom_up_numa_split_range_low_check(void) · 11 unmodified lines
2072 min_addr = req_node_end - SZ_256;2083 min_addr = req_node_end - SZ_256;
2073 max_addr = min_addr + size;2084 max_addr = min_addr + size;
2074 2085
2075 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2086 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2076 min_addr, max_addr, nid_req);2087 min_addr, max_addr, nid_req);
2077 2088
2078 ASSERT_NE(allocated_ptr, NULL);2089 ASSERT_NE(allocated_ptr, NULL);
2079 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2090 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2110,7 +2121,7 @@ static int alloc_try_nid_bottom_up_numa_split_range_low_check(void) · 30 unmodified lines
2110 * Expect to drop the lower limit and allocate a memory region at the beginning2121 * Expect to drop the lower limit and allocate a memory region at the beginning
2111 * of the first node that has enough memory.2122 * of the first node that has enough memory.
2112 */2123 */
2113static int alloc_try_nid_bottom_up_numa_split_range_high_check(void)2124static int alloc_nid_bottom_up_numa_split_range_high_check(void)
2114{2125{
2115 int nid_req = 3;2126 int nid_req = 3;
2116 int nid_exp = 0;2127 int nid_exp = 0;
@@ -2130,8 +2141,8 @@ static int alloc_try_nid_bottom_up_numa_split_range_high_check(void) · 13 unmodified lines
2130 min_addr = req_node->base - SZ_256;2141 min_addr = req_node->base - SZ_256;
2131 max_addr = min_addr + size;2142 max_addr = min_addr + size;
2132 2143
2133 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2144 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2134 min_addr, max_addr, nid_req);2145 min_addr, max_addr, nid_req);
2135 2146
2136 ASSERT_NE(allocated_ptr, NULL);2147 ASSERT_NE(allocated_ptr, NULL);
2137 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2148 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2168,7 +2179,7 @@ static int alloc_try_nid_bottom_up_numa_split_range_high_check(void) · 30 unmodified lines
2168 * Expect to drop the lower limit and allocate a memory region that starts at2179 * Expect to drop the lower limit and allocate a memory region that starts at
2169 * the beginning of the requested node.2180 * the beginning of the requested node.
2170 */2181 */
2171static int alloc_try_nid_bottom_up_numa_no_overlap_split_check(void)2182static int alloc_nid_bottom_up_numa_no_overlap_split_check(void)
2172{2183{
2173 int nid_req = 2;2184 int nid_req = 2;
2174 struct memblock_region *new_rgn = &memblock.reserved.regions[0];2185 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -2186,8 +2197,8 @@ static int alloc_try_nid_bottom_up_numa_no_overlap_split_check(void) · 11 unmodified lines
2186 min_addr = node2->base - SZ_256;2197 min_addr = node2->base - SZ_256;
2187 max_addr = min_addr + size;2198 max_addr = min_addr + size;
2188 2199
2189 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2200 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2190 min_addr, max_addr, nid_req);2201 min_addr, max_addr, nid_req);
2191 2202
2192 ASSERT_NE(allocated_ptr, NULL);2203 ASSERT_NE(allocated_ptr, NULL);
2193 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2204 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2225,7 +2236,7 @@ static int alloc_try_nid_bottom_up_numa_no_overlap_split_check(void) · 31 unmodified lines
2225 * Expect to allocate a memory region at the beginning of the first node2236 * Expect to allocate a memory region at the beginning of the first node
2226 * in the range after falling back to NUMA_NO_NODE.2237 * in the range after falling back to NUMA_NO_NODE.
2227 */2238 */
2228static int alloc_try_nid_bottom_up_numa_no_overlap_low_check(void)2239static int alloc_nid_bottom_up_numa_no_overlap_low_check(void)
2229{2240{
2230 int nid_req = 0;2241 int nid_req = 0;
2231 struct memblock_region *new_rgn = &memblock.reserved.regions[0];2242 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -2242,8 +2253,8 @@ static int alloc_try_nid_bottom_up_numa_no_overlap_low_check(void) · 10 unmodified lines
2242 min_addr = min_node->base;2253 min_addr = min_node->base;
2243 max_addr = region_end(max_node);2254 max_addr = region_end(max_node);
2244 2255
2245 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2256 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2246 min_addr, max_addr, nid_req);2257 min_addr, max_addr, nid_req);
2247 2258
2248 ASSERT_NE(allocated_ptr, NULL);2259 ASSERT_NE(allocated_ptr, NULL);
2249 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2260 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2281,7 +2292,7 @@ static int alloc_try_nid_bottom_up_numa_no_overlap_low_check(void) · 31 unmodified lines
2281 * Expect to allocate a memory region at the beginning of the first node2292 * Expect to allocate a memory region at the beginning of the first node
2282 * in the range after falling back to NUMA_NO_NODE.2293 * in the range after falling back to NUMA_NO_NODE.
2283 */2294 */
2284static int alloc_try_nid_bottom_up_numa_no_overlap_high_check(void)2295static int alloc_nid_bottom_up_numa_no_overlap_high_check(void)
2285{2296{
2286 int nid_req = 7;2297 int nid_req = 7;
2287 struct memblock_region *new_rgn = &memblock.reserved.regions[0];2298 struct memblock_region *new_rgn = &memblock.reserved.regions[0];
@@ -2298,8 +2309,8 @@ static int alloc_try_nid_bottom_up_numa_no_overlap_high_check(void) · 10 unmodified lines
2298 min_addr = min_node->base;2309 min_addr = min_node->base;
2299 max_addr = region_end(max_node);2310 max_addr = region_end(max_node);
2300 2311
2301 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2312 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2302 min_addr, max_addr, nid_req);2313 min_addr, max_addr, nid_req);
2303 2314
2304 ASSERT_NE(allocated_ptr, NULL);2315 ASSERT_NE(allocated_ptr, NULL);
2305 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2316 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2330,7 +2341,7 @@ static int alloc_try_nid_bottom_up_numa_no_overlap_high_check(void) · 24 unmodified lines
2330 *2341 *
2331 * Expect no allocation to happen.2342 * Expect no allocation to happen.
2332 */2343 */
2333static int alloc_try_nid_numa_large_region_generic_check(void)2344static int alloc_nid_numa_large_region_generic_check(void)
2334{2345{
2335 int nid_req = 3;2346 int nid_req = 3;
2336 void *allocated_ptr = NULL;2347 void *allocated_ptr = NULL;
@@ -2344,8 +2355,8 @@ static int alloc_try_nid_numa_large_region_generic_check(void) · 7 unmodified lines
2344 min_addr = memblock_start_of_DRAM();2355 min_addr = memblock_start_of_DRAM();
2345 max_addr = memblock_end_of_DRAM();2356 max_addr = memblock_end_of_DRAM();
2346 2357
2347 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2358 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2348 min_addr, max_addr, nid_req);2359 min_addr, max_addr, nid_req);
2349 ASSERT_EQ(allocated_ptr, NULL);2360 ASSERT_EQ(allocated_ptr, NULL);
2350 2361
2351 test_pass_pop();2362 test_pass_pop();
@@ -2374,7 +2385,7 @@ static int alloc_try_nid_numa_large_region_generic_check(void) · 22 unmodified lines
2374 * Expect to merge all of the regions into one. The region counter and total2385 * Expect to merge all of the regions into one. The region counter and total
2375 * size fields get updated.2386 * size fields get updated.
2376 */2387 */
2377static int alloc_try_nid_numa_reserved_full_merge_generic_check(void)2388static int alloc_nid_numa_reserved_full_merge_generic_check(void)
2378{2389{
2379 int nid_req = 6;2390 int nid_req = 6;
2380 int nid_next = nid_req + 1;2391 int nid_next = nid_req + 1;
@@ -2404,8 +2415,8 @@ static int alloc_try_nid_numa_reserved_full_merge_generic_check(void) · 23 unmodified lines
2404 memblock_reserve(r1.base, r1.size);2415 memblock_reserve(r1.base, r1.size);
2405 memblock_reserve(r2.base, r2.size);2416 memblock_reserve(r2.base, r2.size);
2406 2417
2407 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2418 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2408 min_addr, max_addr, nid_req);2419 min_addr, max_addr, nid_req);
2409 2420
2410 ASSERT_NE(allocated_ptr, NULL);2421 ASSERT_NE(allocated_ptr, NULL);
2411 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);2422 assert_mem_content(allocated_ptr, size, alloc_nid_test_flags);
@@ -2448,7 +2459,7 @@ static int alloc_try_nid_numa_reserved_full_merge_generic_check(void) · 36 unmodified lines
2448 *2459 *
2449 * Expect no allocation to happen.2460 * Expect no allocation to happen.
2450 */2461 */
2451static int alloc_try_nid_numa_split_all_reserved_generic_check(void)2462static int alloc_nid_numa_split_all_reserved_generic_check(void)
2452{2463{
2453 void *allocated_ptr = NULL;2464 void *allocated_ptr = NULL;
2454 struct memblock_region *next_node = &memblock.memory.regions[7];2465 struct memblock_region *next_node = &memblock.memory.regions[7];
@@ -2472,9 +2483,9 @@ static int alloc_try_nid_numa_split_all_reserved_generic_check(void) · 17 unmodified lines
2472 memblock_reserve(r1.base, r1.size);2483 memblock_reserve(r1.base, r1.size);
2473 memblock_reserve(r2.base, r2.size);2484 memblock_reserve(r2.base, r2.size);
2474 2485
2475 allocated_ptr = run_memblock_alloc_try_nid(size, SMP_CACHE_BYTES,2486 allocated_ptr = run_memblock_alloc_nid(size, SMP_CACHE_BYTES,
2476 min_addr, max_addr,2487 min_addr, max_addr,
2477 NUMA_NO_NODE);2488 NUMA_NO_NODE);
2478 2489
2479 ASSERT_EQ(allocated_ptr, NULL);2490 ASSERT_EQ(allocated_ptr, NULL);
2480 2491
@@ -2484,139 +2495,139 @@ static int alloc_try_nid_numa_split_all_reserved_generic_check(void) · 3 unmodified lines
2484}2495}
2485 2496
2486/* Test case wrappers for NUMA tests */2497/* Test case wrappers for NUMA tests */
2487static int alloc_try_nid_numa_simple_check(void)2498static int alloc_nid_numa_simple_check(void)
2488{2499{
2489 test_print("\tRunning %s...\n", __func__);2500 test_print("\tRunning %s...\n", __func__);
2490 memblock_set_bottom_up(false);2501 memblock_set_bottom_up(false);
2491 alloc_try_nid_top_down_numa_simple_check();2502 alloc_nid_top_down_numa_simple_check();
2492 memblock_set_bottom_up(true);2503 memblock_set_bottom_up(true);
2493 alloc_try_nid_bottom_up_numa_simple_check();2504 alloc_nid_bottom_up_numa_simple_check();
2494 2505
2495 return 0;2506 return 0;
2496}2507}
2497 2508
2498static int alloc_try_nid_numa_small_node_check(void)2509static int alloc_nid_numa_small_node_check(void)
2499{2510{
2500 test_print("\tRunning %s...\n", __func__);2511 test_print("\tRunning %s...\n", __func__);
2501 memblock_set_bottom_up(false);2512 memblock_set_bottom_up(false);
2502 alloc_try_nid_top_down_numa_small_node_check();2513 alloc_nid_top_down_numa_small_node_check();
2503 memblock_set_bottom_up(true);2514 memblock_set_bottom_up(true);
2504 alloc_try_nid_bottom_up_numa_small_node_check();2515 alloc_nid_bottom_up_numa_small_node_check();
2505 2516
2506 return 0;2517 return 0;
2507}2518}
2508 2519
2509static int alloc_try_nid_numa_node_reserved_check(void)2520static int alloc_nid_numa_node_reserved_check(void)
2510{2521{
2511 test_print("\tRunning %s...\n", __func__);2522 test_print("\tRunning %s...\n", __func__);
2512 memblock_set_bottom_up(false);2523 memblock_set_bottom_up(false);
2513 alloc_try_nid_top_down_numa_node_reserved_check();2524 alloc_nid_top_down_numa_node_reserved_check();
2514 memblock_set_bottom_up(true);2525 memblock_set_bottom_up(true);
2515 alloc_try_nid_bottom_up_numa_node_reserved_check();2526 alloc_nid_bottom_up_numa_node_reserved_check();
2516 2527
2517 return 0;2528 return 0;
2518}2529}
2519 2530
2520static int alloc_try_nid_numa_part_reserved_check(void)2531static int alloc_nid_numa_part_reserved_check(void)
2521{2532{
2522 test_print("\tRunning %s...\n", __func__);2533 test_print("\tRunning %s...\n", __func__);
2523 memblock_set_bottom_up(false);2534 memblock_set_bottom_up(false);
2524 alloc_try_nid_top_down_numa_part_reserved_check();2535 alloc_nid_top_down_numa_part_reserved_check();
2525 memblock_set_bottom_up(true);2536 memblock_set_bottom_up(true);
2526 alloc_try_nid_bottom_up_numa_part_reserved_check();2537 alloc_nid_bottom_up_numa_part_reserved_check();
2527 2538
2528 return 0;2539 return 0;
2529}2540}
2530 2541
2531static int alloc_try_nid_numa_part_reserved_fallback_check(void)2542static int alloc_nid_numa_part_reserved_fallback_check(void)
2532{2543{
2533 test_print("\tRunning %s...\n", __func__);2544 test_print("\tRunning %s...\n", __func__);
2534 memblock_set_bottom_up(false);2545 memblock_set_bottom_up(false);
2535 alloc_try_nid_top_down_numa_part_reserved_fallback_check();2546 alloc_nid_top_down_numa_part_reserved_fallback_check();
2536 memblock_set_bottom_up(true);2547 memblock_set_bottom_up(true);
2537 alloc_try_nid_bottom_up_numa_part_reserved_fallback_check();2548 alloc_nid_bottom_up_numa_part_reserved_fallback_check();
2538 2549
2539 return 0;2550 return 0;
2540}2551}
2541 2552
2542static int alloc_try_nid_numa_split_range_low_check(void)2553static int alloc_nid_numa_split_range_low_check(void)
2543{2554{
2544 test_print("\tRunning %s...\n", __func__);2555 test_print("\tRunning %s...\n", __func__);
2545 memblock_set_bottom_up(false);2556 memblock_set_bottom_up(false);
2546 alloc_try_nid_top_down_numa_split_range_low_check();2557 alloc_nid_top_down_numa_split_range_low_check();
2547 memblock_set_bottom_up(true);2558 memblock_set_bottom_up(true);
2548 alloc_try_nid_bottom_up_numa_split_range_low_check();2559 alloc_nid_bottom_up_numa_split_range_low_check();
2549 2560
2550 return 0;2561 return 0;
2551}2562}
2552 2563
2553static int alloc_try_nid_numa_split_range_high_check(void)2564static int alloc_nid_numa_split_range_high_check(void)
2554{2565{
2555 test_print("\tRunning %s...\n", __func__);2566 test_print("\tRunning %s...\n", __func__);
2556 memblock_set_bottom_up(false);2567 memblock_set_bottom_up(false);
2557 alloc_try_nid_top_down_numa_split_range_high_check();2568 alloc_nid_top_down_numa_split_range_high_check();
2558 memblock_set_bottom_up(true);2569 memblock_set_bottom_up(true);
2559 alloc_try_nid_bottom_up_numa_split_range_high_check();2570 alloc_nid_bottom_up_numa_split_range_high_check();
2560 2571
2561 return 0;2572 return 0;
2562}2573}
2563 2574
2564static int alloc_try_nid_numa_no_overlap_split_check(void)2575static int alloc_nid_numa_no_overlap_split_check(void)
2565{2576{
2566 test_print("\tRunning %s...\n", __func__);2577 test_print("\tRunning %s...\n", __func__);
2567 memblock_set_bottom_up(false);2578 memblock_set_bottom_up(false);
2568 alloc_try_nid_top_down_numa_no_overlap_split_check();2579 alloc_nid_top_down_numa_no_overlap_split_check();
2569 memblock_set_bottom_up(true);2580 memblock_set_bottom_up(true);
2570 alloc_try_nid_bottom_up_numa_no_overlap_split_check();2581 alloc_nid_bottom_up_numa_no_overlap_split_check();
2571 2582
2572 return 0;2583 return 0;
2573}2584}
2574 2585
2575static int alloc_try_nid_numa_no_overlap_low_check(void)2586static int alloc_nid_numa_no_overlap_low_check(void)
2576{2587{
2577 test_print("\tRunning %s...\n", __func__);2588 test_print("\tRunning %s...\n", __func__);
2578 memblock_set_bottom_up(false);2589 memblock_set_bottom_up(false);
2579 alloc_try_nid_top_down_numa_no_overlap_low_check();2590 alloc_nid_top_down_numa_no_overlap_low_check();
2580 memblock_set_bottom_up(true);2591 memblock_set_bottom_up(true);
2581 alloc_try_nid_bottom_up_numa_no_overlap_low_check();2592 alloc_nid_bottom_up_numa_no_overlap_low_check();
2582 2593
2583 return 0;2594 return 0;
2584}2595}
2585 2596
2586static int alloc_try_nid_numa_no_overlap_high_check(void)2597static int alloc_nid_numa_no_overlap_high_check(void)
2587{2598{
2588 test_print("\tRunning %s...\n", __func__);2599 test_print("\tRunning %s...\n", __func__);
2589 memblock_set_bottom_up(false);2600 memblock_set_bottom_up(false);
2590 alloc_try_nid_top_down_numa_no_overlap_high_check();2601 alloc_nid_top_down_numa_no_overlap_high_check();
2591 memblock_set_bottom_up(true);2602 memblock_set_bottom_up(true);
2592 alloc_try_nid_bottom_up_numa_no_overlap_high_check();2603 alloc_nid_bottom_up_numa_no_overlap_high_check();
2593 2604
2594 return 0;2605 return 0;
2595}2606}
2596 2607
2597static int alloc_try_nid_numa_large_region_check(void)2608static int alloc_nid_numa_large_region_check(void)
2598{2609{
2599 test_print("\tRunning %s...\n", __func__);2610 test_print("\tRunning %s...\n", __func__);
2600 run_top_down(alloc_try_nid_numa_large_region_generic_check);2611 run_top_down(alloc_nid_numa_large_region_generic_check);
2601 run_bottom_up(alloc_try_nid_numa_large_region_generic_check);2612 run_bottom_up(alloc_nid_numa_large_region_generic_check);
2602 2613
2603 return 0;2614 return 0;
2604}2615}
2605 2616
2606static int alloc_try_nid_numa_reserved_full_merge_check(void)2617static int alloc_nid_numa_reserved_full_merge_check(void)
2607{2618{
2608 test_print("\tRunning %s...\n", __func__);2619 test_print("\tRunning %s...\n", __func__);
2609 run_top_down(alloc_try_nid_numa_reserved_full_merge_generic_check);2620 run_top_down(alloc_nid_numa_reserved_full_merge_generic_check);
2610 run_bottom_up(alloc_try_nid_numa_reserved_full_merge_generic_check);2621 run_bottom_up(alloc_nid_numa_reserved_full_merge_generic_check);
2611 2622
2612 return 0;2623 return 0;
2613}2624}
2614 2625
2615static int alloc_try_nid_numa_split_all_reserved_check(void)2626static int alloc_nid_numa_split_all_reserved_check(void)
2616{2627{
2617 test_print("\tRunning %s...\n", __func__);2628 test_print("\tRunning %s...\n", __func__);
2618 run_top_down(alloc_try_nid_numa_split_all_reserved_generic_check);2629 run_top_down(alloc_nid_numa_split_all_reserved_generic_check);
2619 run_bottom_up(alloc_try_nid_numa_split_all_reserved_generic_check);2630 run_bottom_up(alloc_nid_numa_split_all_reserved_generic_check);
2620 2631
2621 return 0;2632 return 0;
2622}2633}
@@ -2624,22 +2635,22 @@ static int alloc_try_nid_numa_split_all_reserved_check(void) · 1 unmodified line
2624int __memblock_alloc_nid_numa_checks(void)2635int __memblock_alloc_nid_numa_checks(void)
2625{2636{
2626 test_print("Running %s NUMA tests...\n",2637 test_print("Running %s NUMA tests...\n",
2627 get_memblock_alloc_try_nid_name(alloc_nid_test_flags));2638 get_memblock_alloc_nid_name(alloc_nid_test_flags));
2628 2639
2629 alloc_try_nid_numa_simple_check();2640 alloc_nid_numa_simple_check();
2630 alloc_try_nid_numa_small_node_check();2641 alloc_nid_numa_small_node_check();
2631 alloc_try_nid_numa_node_reserved_check();2642 alloc_nid_numa_node_reserved_check();
2632 alloc_try_nid_numa_part_reserved_check();2643 alloc_nid_numa_part_reserved_check();
2633 alloc_try_nid_numa_part_reserved_fallback_check();2644 alloc_nid_numa_part_reserved_fallback_check();
2634 alloc_try_nid_numa_split_range_low_check();2645 alloc_nid_numa_split_range_low_check();
2635 alloc_try_nid_numa_split_range_high_check();2646 alloc_nid_numa_split_range_high_check();
2636 2647
2637 alloc_try_nid_numa_no_overlap_split_check();2648 alloc_nid_numa_no_overlap_split_check();
2638 alloc_try_nid_numa_no_overlap_low_check();2649 alloc_nid_numa_no_overlap_low_check();
2639 alloc_try_nid_numa_no_overlap_high_check();2650 alloc_nid_numa_no_overlap_high_check();
2640 alloc_try_nid_numa_large_region_check();2651 alloc_nid_numa_large_region_check();
2641 alloc_try_nid_numa_reserved_full_merge_check();2652 alloc_nid_numa_reserved_full_merge_check();
2642 alloc_try_nid_numa_split_all_reserved_check();2653 alloc_nid_numa_split_all_reserved_check();
2643 2654
2644 return 0;2655 return 0;
2645}2656}
@@ -2649,7 +2660,7 @@ static int memblock_alloc_nid_checks_internal(int flags) · 3 unmodified lines
2649 alloc_nid_test_flags = flags;2660 alloc_nid_test_flags = flags;
2650 2661
2651 prefix_reset();2662 prefix_reset();
2652 prefix_push(get_memblock_alloc_try_nid_name(flags));2663 prefix_push(get_memblock_alloc_nid_name(flags));
2653 2664
2654 reset_memblock_attributes();2665 reset_memblock_attributes();
2655 dummy_physical_memory_init();2666 dummy_physical_memory_init();
@@ -2671,3 +2682,12 @@ int memblock_alloc_nid_checks(void) · 15 unmodified lines
2671 2682
2672 return 0;2683 return 0;
2673}2684}
2685
2686int memblock_alloc_exact_nid_range_checks(void)
2687{
2688 alloc_nid_test_flags = (TEST_F_RAW | TEST_F_EXACT);
2689
2690 memblock_alloc_nid_range_checks();
2691
2692 return 0;
2693}
tools/testing/memblock/tests/alloc_nid_api.h+1−0
@@ -5,6 +5,7 @@ · 4 unmodified lines
5#include "common.h"5#include "common.h"
6 6
7int memblock_alloc_nid_checks(void);7int memblock_alloc_nid_checks(void);
8int memblock_alloc_exact_nid_range_checks(void);
8int __memblock_alloc_nid_numa_checks(void);9int __memblock_alloc_nid_numa_checks(void);
9 10
10#ifdef CONFIG_NUMA11#ifdef CONFIG_NUMA
tools/testing/memblock/tests/basic_api.c+184−0
@@ -423,6 +423,98 @@ static int memblock_add_near_max_check(void) · 422 unmodified lines
423 return 0;423 return 0;
424}424}
425 425
426/*
427 * A test that trying to add the 129th memory block.
428 * Expect to trigger memblock_double_array() to double the
429 * memblock.memory.max, find a new valid memory as
430 * memory.regions.
431 */
432static int memblock_add_many_check(void)
433{
434 int i;
435 void *orig_region;
436 struct region r = {
437 .base = SZ_16K,
438 .size = SZ_16K,
439 };
440 phys_addr_t new_memory_regions_size;
441 phys_addr_t base, size = SZ_64;
442 phys_addr_t gap_size = SZ_64;
443
444 PREFIX_PUSH();
445
446 reset_memblock_regions();
447 memblock_allow_resize();
448
449 dummy_physical_memory_init();
450 /*
451 * We allocated enough memory by using dummy_physical_memory_init(), and
452 * split it into small block. First we split a large enough memory block
453 * as the memory region which will be choosed by memblock_double_array().
454 */
455 base = PAGE_ALIGN(dummy_physical_memory_base());
456 new_memory_regions_size = PAGE_ALIGN(INIT_MEMBLOCK_REGIONS * 2 *
457 sizeof(struct memblock_region));
458 memblock_add(base, new_memory_regions_size);
459
460 /* This is the base of small memory block. */
461 base += new_memory_regions_size + gap_size;
462
463 orig_region = memblock.memory.regions;
464
465 for (i = 0; i < INIT_MEMBLOCK_REGIONS; i++) {
466 /*
467 * Add these small block to fulfill the memblock. We keep a
468 * gap between the nearby memory to avoid being merged.
469 */
470 memblock_add(base, size);
471 base += size + gap_size;
472
473 ASSERT_EQ(memblock.memory.cnt, i + 2);
474 ASSERT_EQ(memblock.memory.total_size, new_memory_regions_size +
475 (i + 1) * size);
476 }
477
478 /*
479 * At there, memblock_double_array() has been succeed, check if it
480 * update the memory.max.
481 */
482 ASSERT_EQ(memblock.memory.max, INIT_MEMBLOCK_REGIONS * 2);
483
484 /* memblock_double_array() will reserve the memory it used. Check it. */
485 ASSERT_EQ(memblock.reserved.cnt, 1);
486 ASSERT_EQ(memblock.reserved.total_size, new_memory_regions_size);
487
488 /*
489 * Now memblock_double_array() works fine. Let's check after the
490 * double_array(), the memblock_add() still works as normal.
491 */
492 memblock_add(r.base, r.size);
493 ASSERT_EQ(memblock.memory.regions[0].base, r.base);
494 ASSERT_EQ(memblock.memory.regions[0].size, r.size);
495
496 ASSERT_EQ(memblock.memory.cnt, INIT_MEMBLOCK_REGIONS + 2);
497 ASSERT_EQ(memblock.memory.total_size, INIT_MEMBLOCK_REGIONS * size +
498 new_memory_regions_size +
499 r.size);
500 ASSERT_EQ(memblock.memory.max, INIT_MEMBLOCK_REGIONS * 2);
501
502 dummy_physical_memory_cleanup();
503
504 /*
505 * The current memory.regions is occupying a range of memory that
506 * allocated from dummy_physical_memory_init(). After free the memory,
507 * we must not use it. So restore the origin memory region to make sure
508 * the tests can run as normal and not affected by the double array.
509 */
510 memblock.memory.regions = orig_region;
511 memblock.memory.cnt = INIT_MEMBLOCK_REGIONS;
512
513 test_pass_pop();
514
515 return 0;
516}
517
426static int memblock_add_checks(void)518static int memblock_add_checks(void)
427{519{
428 prefix_reset();520 prefix_reset();
@@ -438,6 +530,7 @@ static int memblock_add_checks(void) · 9 unmodified lines
438 memblock_add_twice_check();530 memblock_add_twice_check();
439 memblock_add_between_check();531 memblock_add_between_check();
440 memblock_add_near_max_check();532 memblock_add_near_max_check();
533 memblock_add_many_check();
441 534
442 prefix_pop();535 prefix_pop();
443 536
@@ -799,6 +892,96 @@ static int memblock_reserve_near_max_check(void) · 355 unmodified lines
799 return 0;892 return 0;
800}893}
801 894
895/*
896 * A test that trying to reserve the 129th memory block.
897 * Expect to trigger memblock_double_array() to double the
898 * memblock.memory.max, find a new valid memory as
899 * reserved.regions.
900 */
901static int memblock_reserve_many_check(void)
902{
903 int i;
904 void *orig_region;
905 struct region r = {
906 .base = SZ_16K,
907 .size = SZ_16K,
908 };
909 phys_addr_t memory_base = SZ_128K;
910 phys_addr_t new_reserved_regions_size;
911
912 PREFIX_PUSH();
913
914 reset_memblock_regions();
915 memblock_allow_resize();
916
917 /* Add a valid memory region used by double_array(). */
918 dummy_physical_memory_init();
919 memblock_add(dummy_physical_memory_base(), MEM_SIZE);
920
921 for (i = 0; i < INIT_MEMBLOCK_REGIONS; i++) {
922 /* Reserve some fakes memory region to fulfill the memblock. */
923 memblock_reserve(memory_base, MEM_SIZE);
924
925 ASSERT_EQ(memblock.reserved.cnt, i + 1);
926 ASSERT_EQ(memblock.reserved.total_size, (i + 1) * MEM_SIZE);
927
928 /* Keep the gap so these memory region will not be merged. */
929 memory_base += MEM_SIZE * 2;
930 }
931
932 orig_region = memblock.reserved.regions;
933
934 /* This reserve the 129 memory_region, and makes it double array. */
935 memblock_reserve(memory_base, MEM_SIZE);
936
937 /*
938 * This is the memory region size used by the doubled reserved.regions,
939 * and it has been reserved due to it has been used. The size is used to
940 * calculate the total_size that the memblock.reserved have now.
941 */
942 new_reserved_regions_size = PAGE_ALIGN((INIT_MEMBLOCK_REGIONS * 2) *
943 sizeof(struct memblock_region));
944 /*
945 * The double_array() will find a free memory region as the new
946 * reserved.regions, and the used memory region will be reserved, so
947 * there will be one more region exist in the reserved memblock. And the
948 * one more reserved region's size is new_reserved_regions_size.
949 */
950 ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 2);
951 ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE +
952 new_reserved_regions_size);
953 ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2);
954
955 /*
956 * Now memblock_double_array() works fine. Let's check after the
957 * double_array(), the memblock_reserve() still works as normal.
958 */
959 memblock_reserve(r.base, r.size);
960 ASSERT_EQ(memblock.reserved.regions[0].base, r.base);
961 ASSERT_EQ(memblock.reserved.regions[0].size, r.size);
962
963 ASSERT_EQ(memblock.reserved.cnt, INIT_MEMBLOCK_REGIONS + 3);
964 ASSERT_EQ(memblock.reserved.total_size, (INIT_MEMBLOCK_REGIONS + 1) * MEM_SIZE +
965 new_reserved_regions_size +
966 r.size);
967 ASSERT_EQ(memblock.reserved.max, INIT_MEMBLOCK_REGIONS * 2);
968
969 dummy_physical_memory_cleanup();
970
971 /*
972 * The current reserved.regions is occupying a range of memory that
973 * allocated from dummy_physical_memory_init(). After free the memory,
974 * we must not use it. So restore the origin memory region to make sure
975 * the tests can run as normal and not affected by the double array.
976 */
977 memblock.reserved.regions = orig_region;
978 memblock.reserved.cnt = INIT_MEMBLOCK_RESERVED_REGIONS;
979
980 test_pass_pop();
981
982 return 0;
983}
984
802static int memblock_reserve_checks(void)985static int memblock_reserve_checks(void)
803{986{
804 prefix_reset();987 prefix_reset();
@@ -813,6 +996,7 @@ static int memblock_reserve_checks(void) · 8 unmodified lines
813 memblock_reserve_twice_check();996 memblock_reserve_twice_check();
814 memblock_reserve_between_check();997 memblock_reserve_between_check();
815 memblock_reserve_near_max_check();998 memblock_reserve_near_max_check();
999 memblock_reserve_many_check();
816 1000
817 prefix_pop();1001 prefix_pop();
818 1002
tools/testing/memblock/tests/common.c+5−2
@@ -5,8 +5,6 @@ · 4 unmodified lines
5#include <linux/memory_hotplug.h>5#include <linux/memory_hotplug.h>
6#include <linux/build_bug.h>6#include <linux/build_bug.h>
7 7
8#define INIT_MEMBLOCK_REGIONS 128
9#define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS
10#define PREFIXES_MAX 158#define PREFIXES_MAX 15
11#define DELIM ": "9#define DELIM ": "
12#define BASIS 1000010#define BASIS 10000
@@ -115,6 +113,11 @@ void dummy_physical_memory_cleanup(void) · 102 unmodified lines
115 free(memory_block.base);113 free(memory_block.base);
116}114}
117 115
116phys_addr_t dummy_physical_memory_base(void)
117{
118 return (phys_addr_t)memory_block.base;
119}
120
118static void usage(const char *prog)121static void usage(const char *prog)
119{122{
120 BUILD_BUG_ON(ARRAY_SIZE(help_opts) != ARRAY_SIZE(long_opts) - 1);123 BUILD_BUG_ON(ARRAY_SIZE(help_opts) != ARRAY_SIZE(long_opts) - 1);
tools/testing/memblock/tests/common.h+7−1
@@ -10,14 +10,19 @@ · 9 unmodified lines
10#include <linux/printk.h>10#include <linux/printk.h>
11#include <../selftests/kselftest.h>11#include <../selftests/kselftest.h>
12 12
13#define MEM_SIZE SZ_16K13#define MEM_SIZE SZ_32K
14#define NUMA_NODES 814#define NUMA_NODES 8
15 15
16#define INIT_MEMBLOCK_REGIONS 128
17#define INIT_MEMBLOCK_RESERVED_REGIONS INIT_MEMBLOCK_REGIONS
18
16enum test_flags {19enum test_flags {
17 /* No special request. */20 /* No special request. */
18 TEST_F_NONE = 0x0,21 TEST_F_NONE = 0x0,
19 /* Perform raw allocations (no zeroing of memory). */22 /* Perform raw allocations (no zeroing of memory). */
20 TEST_F_RAW = 0x1,23 TEST_F_RAW = 0x1,
24 /* Perform allocations on the exact node specified. */
25 TEST_F_EXACT = 0x2
21};26};
22 27
23/**28/**
@@ -124,6 +129,7 @@ void setup_memblock(void); · 100 unmodified lines
124void setup_numa_memblock(const unsigned int node_fracs[]);129void setup_numa_memblock(const unsigned int node_fracs[]);
125void dummy_physical_memory_init(void);130void dummy_physical_memory_init(void);
126void dummy_physical_memory_cleanup(void);131void dummy_physical_memory_cleanup(void);
132phys_addr_t dummy_physical_memory_base(void);
127void parse_args(int argc, char **argv);133void parse_args(int argc, char **argv);
128 134
129void test_fail(void);135void test_fail(void);