1 #ifndef _LINUX_COMPACTION_H
2 #define _LINUX_COMPACTION_H
4 /* Return values for compact_zone() and try_to_compact_pages() */
5 /* When adding new states, please adjust include/trace/events/compaction.h */
8 * compaction didn't start as it was not possible or direct reclaim
12 /* compaction didn't start as it was deferred due to past failures */
14 /* compaction not active last round */
15 COMPACT_INACTIVE = COMPACT_DEFERRED,
17 /* compaction should continue to another pageblock */
20 * direct compaction partially compacted a zone and there are suitable
25 * direct compaction has scanned part of the zone but wasn't successfull
26 * to compact suitable pages.
28 COMPACT_PARTIAL_SKIPPED,
30 * The full zone was compacted scanned but wasn't successfull to compact
34 /* For more detailed tracepoint output */
35 COMPACT_NO_SUITABLE_PAGE,
36 COMPACT_NOT_SUITABLE_ZONE,
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
48 struct alloc_context; /* in mm/internal.h */
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;
59 extern int fragmentation_index(struct zone *zone, unsigned int order);
60 extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
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);
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,
73 extern bool compaction_restarting(struct zone *zone, int order);
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);
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)
85 return COMPACT_CONTINUE;
88 static inline void compact_pgdat(pg_data_t *pgdat, int order)
92 static inline void reset_isolation_suitable(pg_data_t *pgdat)
96 static inline enum compact_result compaction_suitable(struct zone *zone, int order,
97 int alloc_flags, int classzone_idx)
99 return COMPACT_SKIPPED;
102 static inline void defer_compaction(struct zone *zone, int order)
106 static inline bool compaction_deferred(struct zone *zone, int order)
111 static inline int kcompactd_run(int nid)
115 static inline void kcompactd_stop(int nid)
119 static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
123 #endif /* CONFIG_COMPACTION */
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);
131 static inline int compaction_register_node(struct node *node)
136 static inline void compaction_unregister_node(struct node *node)
139 #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
141 #endif /* _LINUX_COMPACTION_H */