]>
Commit | Line | Data |
---|---|---|
748446bb MG |
1 | #ifndef _LINUX_COMPACTION_H |
2 | #define _LINUX_COMPACTION_H | |
3 | ||
56de7263 | 4 | /* Return values for compact_zone() and try_to_compact_pages() */ |
fa6c7b46 | 5 | /* When adding new states, please adjust include/trace/events/compaction.h */ |
ea7ab982 | 6 | enum compact_result { |
ea7ab982 MH |
7 | /* |
8 | * compaction didn't start as it was not possible or direct reclaim | |
9 | * was more suitable | |
10 | */ | |
11 | COMPACT_SKIPPED, | |
1d4746d3 MH |
12 | /* compaction didn't start as it was deferred due to past failures */ |
13 | COMPACT_DEFERRED, | |
14 | /* compaction not active last round */ | |
15 | COMPACT_INACTIVE = COMPACT_DEFERRED, | |
16 | ||
ea7ab982 MH |
17 | /* compaction should continue to another pageblock */ |
18 | COMPACT_CONTINUE, | |
19 | /* | |
20 | * direct compaction partially compacted a zone and there are suitable | |
21 | * pages | |
22 | */ | |
23 | COMPACT_PARTIAL, | |
24 | /* The full zone was compacted */ | |
25 | COMPACT_COMPLETE, | |
26 | /* For more detailed tracepoint output */ | |
27 | COMPACT_NO_SUITABLE_PAGE, | |
28 | COMPACT_NOT_SUITABLE_ZONE, | |
29 | COMPACT_CONTENDED, | |
30 | }; | |
748446bb | 31 | |
1f9efdef VB |
32 | /* Used to signal whether compaction detected need_sched() or lock contention */ |
33 | /* No contention detected */ | |
34 | #define COMPACT_CONTENDED_NONE 0 | |
35 | /* Either need_sched() was true or fatal signal pending */ | |
36 | #define COMPACT_CONTENDED_SCHED 1 | |
37 | /* Zone lock or lru_lock was contended in async compaction */ | |
38 | #define COMPACT_CONTENDED_LOCK 2 | |
39 | ||
1a6d53a1 VB |
40 | struct alloc_context; /* in mm/internal.h */ |
41 | ||
76ab0f53 MG |
42 | #ifdef CONFIG_COMPACTION |
43 | extern int sysctl_compact_memory; | |
44 | extern int sysctl_compaction_handler(struct ctl_table *table, int write, | |
45 | void __user *buffer, size_t *length, loff_t *ppos); | |
5e771905 MG |
46 | extern int sysctl_extfrag_threshold; |
47 | extern int sysctl_extfrag_handler(struct ctl_table *table, int write, | |
48 | void __user *buffer, size_t *length, loff_t *ppos); | |
5bbe3547 | 49 | extern int sysctl_compact_unevictable_allowed; |
56de7263 MG |
50 | |
51 | extern int fragmentation_index(struct zone *zone, unsigned int order); | |
ea7ab982 MH |
52 | extern enum compact_result try_to_compact_pages(gfp_t gfp_mask, |
53 | unsigned int order, | |
c603844b MG |
54 | unsigned int alloc_flags, const struct alloc_context *ac, |
55 | enum migrate_mode mode, int *contended); | |
7103f16d | 56 | extern void compact_pgdat(pg_data_t *pgdat, int order); |
62997027 | 57 | extern void reset_isolation_suitable(pg_data_t *pgdat); |
ea7ab982 | 58 | extern enum compact_result compaction_suitable(struct zone *zone, int order, |
c603844b | 59 | unsigned int alloc_flags, int classzone_idx); |
4f92e258 | 60 | |
24e2716f JK |
61 | extern void defer_compaction(struct zone *zone, int order); |
62 | extern bool compaction_deferred(struct zone *zone, int order); | |
63 | extern void compaction_defer_reset(struct zone *zone, int order, | |
64 | bool alloc_success); | |
65 | extern bool compaction_restarting(struct zone *zone, int order); | |
62997027 | 66 | |
698b1b30 VB |
67 | extern int kcompactd_run(int nid); |
68 | extern void kcompactd_stop(int nid); | |
69 | extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx); | |
70 | ||
56de7263 | 71 | #else |
ea7ab982 | 72 | static inline enum compact_result try_to_compact_pages(gfp_t gfp_mask, |
1a6d53a1 VB |
73 | unsigned int order, int alloc_flags, |
74 | const struct alloc_context *ac, | |
75 | enum migrate_mode mode, int *contended) | |
56de7263 MG |
76 | { |
77 | return COMPACT_CONTINUE; | |
78 | } | |
79 | ||
7103f16d | 80 | static inline void compact_pgdat(pg_data_t *pgdat, int order) |
7be62de9 | 81 | { |
7be62de9 RR |
82 | } |
83 | ||
62997027 MG |
84 | static inline void reset_isolation_suitable(pg_data_t *pgdat) |
85 | { | |
86 | } | |
87 | ||
ea7ab982 | 88 | static inline enum compact_result compaction_suitable(struct zone *zone, int order, |
ebff3980 | 89 | int alloc_flags, int classzone_idx) |
3e7d3449 MG |
90 | { |
91 | return COMPACT_SKIPPED; | |
92 | } | |
93 | ||
aff62249 | 94 | static inline void defer_compaction(struct zone *zone, int order) |
4f92e258 MG |
95 | { |
96 | } | |
97 | ||
aff62249 | 98 | static inline bool compaction_deferred(struct zone *zone, int order) |
4f92e258 | 99 | { |
c59e2610 | 100 | return true; |
4f92e258 MG |
101 | } |
102 | ||
698b1b30 VB |
103 | static inline int kcompactd_run(int nid) |
104 | { | |
105 | return 0; | |
106 | } | |
107 | static inline void kcompactd_stop(int nid) | |
108 | { | |
109 | } | |
110 | ||
111 | static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx) | |
112 | { | |
113 | } | |
114 | ||
76ab0f53 MG |
115 | #endif /* CONFIG_COMPACTION */ |
116 | ||
ed4a6d7f MG |
117 | #if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) |
118 | extern int compaction_register_node(struct node *node); | |
119 | extern void compaction_unregister_node(struct node *node); | |
120 | ||
121 | #else | |
122 | ||
123 | static inline int compaction_register_node(struct node *node) | |
124 | { | |
125 | return 0; | |
126 | } | |
127 | ||
128 | static inline void compaction_unregister_node(struct node *node) | |
129 | { | |
130 | } | |
131 | #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */ | |
132 | ||
748446bb | 133 | #endif /* _LINUX_COMPACTION_H */ |