xref: /linux/mm/shuffle.h (revision 18fbf5151d2c0bfe433c7428eef03cabf5fdb2fa)
1 // SPDX-License-Identifier: GPL-2.0
2 // Copyright(c) 2018 Intel Corporation. All rights reserved.
3 #ifndef _MM_SHUFFLE_H
4 #define _MM_SHUFFLE_H
5 
6 #include <linux/jump_label.h>
7 #include <linux/mmzone.h>
8 
9 #define SHUFFLE_ORDER MAX_PAGE_ORDER
10 
11 #ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR
12 DECLARE_STATIC_KEY_FALSE(page_alloc_shuffle_key);
13 extern void __shuffle_free_memory(pg_data_t *pgdat);
14 extern bool shuffle_pick_tail(void);
15 static inline void __meminit shuffle_free_memory(pg_data_t *pgdat)
16 {
17 	if (!static_branch_unlikely(&page_alloc_shuffle_key))
18 		return;
19 	__shuffle_free_memory(pgdat);
20 }
21 
22 extern void __shuffle_zone(struct zone *z);
23 static inline void __meminit shuffle_zone(struct zone *z)
24 {
25 	if (!static_branch_unlikely(&page_alloc_shuffle_key))
26 		return;
27 	__shuffle_zone(z);
28 }
29 
30 static inline bool is_shuffle_order(int order)
31 {
32 	if (!static_branch_unlikely(&page_alloc_shuffle_key))
33 		return false;
34 	return order >= SHUFFLE_ORDER;
35 }
36 #else
37 static inline bool shuffle_pick_tail(void)
38 {
39 	return false;
40 }
41 
42 static inline void shuffle_free_memory(pg_data_t *pgdat)
43 {
44 }
45 
46 static inline void shuffle_zone(struct zone *z)
47 {
48 }
49 
50 static inline bool is_shuffle_order(int order)
51 {
52 	return false;
53 }
54 #endif
55 #endif /* _MM_SHUFFLE_H */
56