Skip to content

Commit 02f9a04

Browse files
committed
Merge tag 'memblock-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock
Pull memblock updates from Mike Rapoport: "Test suite and a small cleanup: - A small cleanup of unused variable in __next_mem_pfn_range_in_zone - Initial test suite to simulate memblock behaviour in userspace" * tag 'memblock-v5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rppt/memblock: (27 commits) memblock tests: Add TODO and README files memblock tests: Add memblock_alloc_try_nid tests for bottom up memblock tests: Add memblock_alloc_try_nid tests for top down memblock tests: Add memblock_alloc_from tests for bottom up memblock tests: Add memblock_alloc_from tests for top down memblock tests: Add memblock_alloc tests for bottom up memblock tests: Add memblock_alloc tests for top down memblock tests: Add simulation of physical memory memblock tests: Split up reset_memblock function memblock tests: Fix testing with 32-bit physical addresses memblock: __next_mem_pfn_range_in_zone: remove unneeded local variable nid memblock tests: Add memblock_free tests memblock tests: Add memblock_add_node test memblock tests: Add memblock_remove tests memblock tests: Add memblock_reserve tests memblock tests: Add memblock_add tests memblock tests: Add memblock reset function memblock tests: Add skeleton of the memblock simulator tools/include: Add debugfs.h stub tools/include: Add pfn.h stub ...
2 parents 88b3be5 + 58ffc34 commit 02f9a04

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+3934
-71
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12550,6 +12550,7 @@ S: Maintained
1255012550
F: Documentation/core-api/boot-time-mm.rst
1255112551
F: include/linux/memblock.h
1255212552
F: mm/memblock.c
12553+
F: tools/testing/memblock/
1255312554

1255412555
MEMORY CONTROLLER DRIVERS
1255512556
M: Krzysztof Kozlowski <krzk@kernel.org>

mm/memblock.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1284,11 +1284,10 @@ __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone,
12841284
{
12851285
int zone_nid = zone_to_nid(zone);
12861286
phys_addr_t spa, epa;
1287-
int nid;
12881287

12891288
__next_mem_range(idx, zone_nid, MEMBLOCK_NONE,
12901289
&memblock.memory, &memblock.reserved,
1291-
&spa, &epa, &nid);
1290+
&spa, &epa, NULL);
12921291

12931292
while (*idx != U64_MAX) {
12941293
unsigned long epfn = PFN_DOWN(epa);
@@ -1315,7 +1314,7 @@ __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone,
13151314

13161315
__next_mem_range(idx, zone_nid, MEMBLOCK_NONE,
13171316
&memblock.memory, &memblock.reserved,
1318-
&spa, &epa, &nid);
1317+
&spa, &epa, NULL);
13191318
}
13201319

13211320
/* signal end of iteration */

tools/include/linux/atomic.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include <asm/atomic.h>
66

7+
void atomic_long_set(atomic_long_t *v, long i);
8+
79
/* atomic_cmpxchg_relaxed */
810
#ifndef atomic_cmpxchg_relaxed
911
#define atomic_cmpxchg_relaxed atomic_cmpxchg

tools/include/linux/cache.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _TOOLS_LINUX_CACHE_H
3+
#define _TOOLS_LINUX_CACHE_H
4+
5+
#define L1_CACHE_SHIFT 5
6+
#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7+
8+
#define SMP_CACHE_BYTES L1_CACHE_BYTES
9+
10+
#endif

tools/include/linux/debugfs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _TOOLS_DEBUGFS_H
3+
#define _TOOLS_DEBUGFS_H
4+
5+
#endif

tools/include/linux/gfp.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,32 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
12
#ifndef _TOOLS_INCLUDE_LINUX_GFP_H
23
#define _TOOLS_INCLUDE_LINUX_GFP_H
34

5+
#include <linux/types.h>
6+
7+
#define __GFP_BITS_SHIFT 26
8+
#define __GFP_BITS_MASK ((gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
9+
10+
#define __GFP_HIGH 0x20u
11+
#define __GFP_IO 0x40u
12+
#define __GFP_FS 0x80u
13+
#define __GFP_NOWARN 0x200u
14+
#define __GFP_ZERO 0x8000u
15+
#define __GFP_ATOMIC 0x80000u
16+
#define __GFP_ACCOUNT 0x100000u
17+
#define __GFP_DIRECT_RECLAIM 0x400000u
18+
#define __GFP_KSWAPD_RECLAIM 0x2000000u
19+
20+
#define __GFP_RECLAIM (__GFP_DIRECT_RECLAIM | __GFP_KSWAPD_RECLAIM)
21+
22+
#define GFP_ZONEMASK 0x0fu
23+
#define GFP_ATOMIC (__GFP_HIGH | __GFP_ATOMIC | __GFP_KSWAPD_RECLAIM)
24+
#define GFP_KERNEL (__GFP_RECLAIM | __GFP_IO | __GFP_FS)
25+
#define GFP_NOWAIT (__GFP_KSWAPD_RECLAIM)
26+
27+
static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
28+
{
29+
return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
30+
}
31+
432
#endif /* _TOOLS_INCLUDE_LINUX_GFP_H */

tools/include/linux/io.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _TOOLS_IO_H
3+
#define _TOOLS_IO_H
4+
5+
#endif

tools/include/linux/kernel.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#define UINT_MAX (~0U)
1616
#endif
1717

18+
#define _RET_IP_ ((unsigned long)__builtin_return_address(0))
19+
1820
#define PERF_ALIGN(x, a) __PERF_ALIGN_MASK(x, (typeof(x))(a)-1)
1921
#define __PERF_ALIGN_MASK(x, mask) (((x)+(mask))&~(mask))
2022

@@ -51,6 +53,10 @@
5153
_min1 < _min2 ? _min1 : _min2; })
5254
#endif
5355

56+
#define max_t(type, x, y) max((type)x, (type)y)
57+
#define min_t(type, x, y) min((type)x, (type)y)
58+
#define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi)
59+
5460
#ifndef BUG_ON
5561
#ifdef NDEBUG
5662
#define BUG_ON(cond) do { if (cond) {} } while (0)

tools/include/linux/mm.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _TOOLS_LINUX_MM_H
3+
#define _TOOLS_LINUX_MM_H
4+
5+
#include <linux/mmzone.h>
6+
#include <uapi/linux/const.h>
7+
8+
#define PAGE_SHIFT 12
9+
#define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10+
#define PAGE_MASK (~(PAGE_SIZE - 1))
11+
12+
#define PHYS_ADDR_MAX (~(phys_addr_t)0)
13+
14+
#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
15+
#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask))
16+
#define ALIGN(x, a) __ALIGN_KERNEL((x), (a))
17+
#define ALIGN_DOWN(x, a) __ALIGN_KERNEL((x) - ((a) - 1), (a))
18+
19+
#define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE)
20+
21+
#define __va(x) ((void *)((unsigned long)(x)))
22+
#define __pa(x) ((unsigned long)(x))
23+
24+
#define pfn_to_page(pfn) ((void *)((pfn) * PAGE_SIZE))
25+
26+
#define phys_to_virt phys_to_virt
27+
static inline void *phys_to_virt(unsigned long address)
28+
{
29+
return __va(address);
30+
}
31+
32+
void reserve_bootmem_region(phys_addr_t start, phys_addr_t end);
33+
34+
static inline void totalram_pages_inc(void)
35+
{
36+
}
37+
38+
static inline void totalram_pages_add(long count)
39+
{
40+
}
41+
42+
#endif

tools/include/linux/pfn.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _TOOLS_LINUX_PFN_H_
3+
#define _TOOLS_LINUX_PFN_H_
4+
5+
#include <linux/mm.h>
6+
7+
#define PFN_UP(x) (((x) + PAGE_SIZE - 1) >> PAGE_SHIFT)
8+
#define PFN_DOWN(x) ((x) >> PAGE_SHIFT)
9+
#define PFN_PHYS(x) ((phys_addr_t)(x) << PAGE_SHIFT)
10+
#endif

0 commit comments

Comments
 (0)