Commit | Line | Data |
---|---|---|
e900a918 DW |
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 | #include <linux/jump_label.h> | |
6 | ||
7 | /* | |
8 | * SHUFFLE_ENABLE is called from the command line enabling path, or by | |
9 | * platform-firmware enabling that indicates the presence of a | |
10 | * direct-mapped memory-side-cache. SHUFFLE_FORCE_DISABLE is called from | |
11 | * the command line path and overrides any previous or future | |
12 | * SHUFFLE_ENABLE. | |
13 | */ | |
14 | enum mm_shuffle_ctl { | |
15 | SHUFFLE_ENABLE, | |
16 | SHUFFLE_FORCE_DISABLE, | |
17 | }; | |
18 | ||
19 | #define SHUFFLE_ORDER (MAX_ORDER-1) | |
20 | ||
21 | #ifdef CONFIG_SHUFFLE_PAGE_ALLOCATOR | |
22 | DECLARE_STATIC_KEY_FALSE(page_alloc_shuffle_key); | |
23 | extern void page_alloc_shuffle(enum mm_shuffle_ctl ctl); | |
24 | extern void __shuffle_free_memory(pg_data_t *pgdat); | |
25 | static inline void shuffle_free_memory(pg_data_t *pgdat) | |
26 | { | |
27 | if (!static_branch_unlikely(&page_alloc_shuffle_key)) | |
28 | return; | |
29 | __shuffle_free_memory(pgdat); | |
30 | } | |
31 | ||
32 | extern void __shuffle_zone(struct zone *z); | |
33 | static inline void shuffle_zone(struct zone *z) | |
34 | { | |
35 | if (!static_branch_unlikely(&page_alloc_shuffle_key)) | |
36 | return; | |
37 | __shuffle_zone(z); | |
38 | } | |
97500a4a DW |
39 | |
40 | static inline bool is_shuffle_order(int order) | |
41 | { | |
42 | if (!static_branch_unlikely(&page_alloc_shuffle_key)) | |
43 | return false; | |
44 | return order >= SHUFFLE_ORDER; | |
45 | } | |
e900a918 DW |
46 | #else |
47 | static inline void shuffle_free_memory(pg_data_t *pgdat) | |
48 | { | |
49 | } | |
50 | ||
51 | static inline void shuffle_zone(struct zone *z) | |
52 | { | |
53 | } | |
54 | ||
55 | static inline void page_alloc_shuffle(enum mm_shuffle_ctl ctl) | |
56 | { | |
57 | } | |
97500a4a DW |
58 | |
59 | static inline bool is_shuffle_order(int order) | |
60 | { | |
61 | return false; | |
62 | } | |
e900a918 DW |
63 | #endif |
64 | #endif /* _MM_SHUFFLE_H */ |