mm, compaction: change COMPACT_ constants into enum
[linux-2.6-block.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         /* compaction didn't start as it was deferred due to past failures */
8         COMPACT_DEFERRED,
9         /*
10          * compaction didn't start as it was not possible or direct reclaim
11          * was more suitable
12          */
13         COMPACT_SKIPPED,
14         /* compaction should continue to another pageblock */
15         COMPACT_CONTINUE,
16         /*
17          * direct compaction partially compacted a zone and there are suitable
18          * pages
19          */
20         COMPACT_PARTIAL,
21         /* The full zone was compacted */
22         COMPACT_COMPLETE,
23         /* For more detailed tracepoint output */
24         COMPACT_NO_SUITABLE_PAGE,
25         COMPACT_NOT_SUITABLE_ZONE,
26         COMPACT_CONTENDED,
27 };
28
29 /* Used to signal whether compaction detected need_sched() or lock contention */
30 /* No contention detected */
31 #define COMPACT_CONTENDED_NONE  0
32 /* Either need_sched() was true or fatal signal pending */
33 #define COMPACT_CONTENDED_SCHED 1
34 /* Zone lock or lru_lock was contended in async compaction */
35 #define COMPACT_CONTENDED_LOCK  2
36
37 struct alloc_context; /* in mm/internal.h */
38
39 #ifdef CONFIG_COMPACTION
40 extern int sysctl_compact_memory;
41 extern int sysctl_compaction_handler(struct ctl_table *table, int write,
42                         void __user *buffer, size_t *length, loff_t *ppos);
43 extern int sysctl_extfrag_threshold;
44 extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
45                         void __user *buffer, size_t *length, loff_t *ppos);
46 extern int sysctl_compact_unevictable_allowed;
47
48 extern int fragmentation_index(struct zone *zone, unsigned int order);
49 extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
50                         unsigned int order,
51                 unsigned int alloc_flags, const struct alloc_context *ac,
52                 enum migrate_mode mode, int *contended);
53 extern void compact_pgdat(pg_data_t *pgdat, int order);
54 extern void reset_isolation_suitable(pg_data_t *pgdat);
55 extern enum compact_result compaction_suitable(struct zone *zone, int order,
56                 unsigned int alloc_flags, int classzone_idx);
57
58 extern void defer_compaction(struct zone *zone, int order);
59 extern bool compaction_deferred(struct zone *zone, int order);
60 extern void compaction_defer_reset(struct zone *zone, int order,
61                                 bool alloc_success);
62 extern bool compaction_restarting(struct zone *zone, int order);
63
64 extern int kcompactd_run(int nid);
65 extern void kcompactd_stop(int nid);
66 extern void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx);
67
68 #else
69 static inline enum compact_result try_to_compact_pages(gfp_t gfp_mask,
70                         unsigned int order, int alloc_flags,
71                         const struct alloc_context *ac,
72                         enum migrate_mode mode, int *contended)
73 {
74         return COMPACT_CONTINUE;
75 }
76
77 static inline void compact_pgdat(pg_data_t *pgdat, int order)
78 {
79 }
80
81 static inline void reset_isolation_suitable(pg_data_t *pgdat)
82 {
83 }
84
85 static inline enum compact_result compaction_suitable(struct zone *zone, int order,
86                                         int alloc_flags, int classzone_idx)
87 {
88         return COMPACT_SKIPPED;
89 }
90
91 static inline void defer_compaction(struct zone *zone, int order)
92 {
93 }
94
95 static inline bool compaction_deferred(struct zone *zone, int order)
96 {
97         return true;
98 }
99
100 static inline int kcompactd_run(int nid)
101 {
102         return 0;
103 }
104 static inline void kcompactd_stop(int nid)
105 {
106 }
107
108 static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
109 {
110 }
111
112 #endif /* CONFIG_COMPACTION */
113
114 #if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
115 extern int compaction_register_node(struct node *node);
116 extern void compaction_unregister_node(struct node *node);
117
118 #else
119
120 static inline int compaction_register_node(struct node *node)
121 {
122         return 0;
123 }
124
125 static inline void compaction_unregister_node(struct node *node)
126 {
127 }
128 #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
129
130 #endif /* _LINUX_COMPACTION_H */