9b37f9d3f7a8b0b2d62a437a20c0653516a9fc5d
[linux-2.6-microblaze.git] / include / linux / compaction.h
1 #ifndef _LINUX_COMPACTION_H
2 #define _LINUX_COMPACTION_H
3
4 /* Return values for compact_zone() and try_to_compact_pages() */
5 /* When adding new states, please adjust include/trace/events/compaction.h */
6 enum compact_result {
7         /*
8          * compaction didn't start as it was not possible or direct reclaim
9          * was more suitable
10          */
11         COMPACT_SKIPPED,
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
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         /*
25          * direct compaction has scanned part of the zone but wasn't successfull
26          * to compact suitable pages.
27          */
28         COMPACT_PARTIAL_SKIPPED,
29         /*
30          * The full zone was compacted scanned but wasn't successfull to compact
31          * suitable pages.
32          */
33         COMPACT_COMPLETE,
34         /* For more detailed tracepoint output */
35         COMPACT_NO_SUITABLE_PAGE,
36         COMPACT_NOT_SUITABLE_ZONE,
37         COMPACT_CONTENDED,
38 };
39
40 /* Used to signal whether compaction detected need_sched() or lock contention */
41 /* No contention detected */
42 #define COMPACT_CONTENDED_NONE  0
43 /* Either need_sched() was true or fatal signal pending */
44 #define COMPACT_CONTENDED_SCHED 1
45 /* Zone lock or lru_lock was contended in async compaction */
46 #define COMPACT_CONTENDED_LOCK  2
47
48 struct alloc_context; /* in mm/internal.h */
49
50 #ifdef CONFIG_COMPACTION
51 extern int sysctl_compact_memory;
52 extern int sysctl_compaction_handler(struct ctl_table *table, int write,
53                         void __user *buffer, size_t *length, loff_t *ppos);
54 extern int sysctl_extfrag_threshold;
55 extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
56                         void __user *buffer, size_t *length, loff_t *ppos);
57 extern int sysctl_compact_unevictable_allowed;
58
59 extern int fragmentation_index(struct zone *zone, unsigned int order);
60 extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
61                         unsigned int order,
62                 unsigned int alloc_flags, const struct alloc_context *ac,
63                 enum migrate_mode mode, int *contended);
64 extern void compact_pgdat(pg_data_t *pgdat, int order);
65 extern void reset_isolation_suitable(pg_data_t *pgdat);
66 extern enum compact_result compaction_suitable(struct zone *zone, int order,
67                 unsigned int alloc_flags, int classzone_idx);
68
69 extern void defer_compaction(struct zone *zone, int order);
70 extern bool compaction_deferred(struct zone *zone, int order);
71 extern void compaction_defer_reset(struct zone *zone, int order,
72                                 bool alloc_success);
73 extern bool compaction_restarting(struct zone *zone, int order);
74
75 extern int kcompactd_run(int nid);
76 extern void kcompactd_stop(int nid);
77 extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx);
78
79 #else
80 static inline enum compact_result try_to_compact_pages(gfp_t gfp_mask,
81                         unsigned int order, int alloc_flags,
82                         const struct alloc_context *ac,
83                         enum migrate_mode mode, int *contended)
84 {
85         return COMPACT_CONTINUE;
86 }
87
88 static inline void compact_pgdat(pg_data_t *pgdat, int order)
89 {
90 }
91
92 static inline void reset_isolation_suitable(pg_data_t *pgdat)
93 {
94 }
95
96 static inline enum compact_result compaction_suitable(struct zone *zone, int order,
97                                         int alloc_flags, int classzone_idx)
98 {
99         return COMPACT_SKIPPED;
100 }
101
102 static inline void defer_compaction(struct zone *zone, int order)
103 {
104 }
105
106 static inline bool compaction_deferred(struct zone *zone, int order)
107 {
108         return true;
109 }
110
111 static inline int kcompactd_run(int nid)
112 {
113         return 0;
114 }
115 static inline void kcompactd_stop(int nid)
116 {
117 }
118
119 static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
120 {
121 }
122
123 #endif /* CONFIG_COMPACTION */
124
125 #if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
126 extern int compaction_register_node(struct node *node);
127 extern void compaction_unregister_node(struct node *node);
128
129 #else
130
131 static inline int compaction_register_node(struct node *node)
132 {
133         return 0;
134 }
135
136 static inline void compaction_unregister_node(struct node *node)
137 {
138 }
139 #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
140
141 #endif /* _LINUX_COMPACTION_H */