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