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
24 /* The full zone was compacted */
26 /* For more detailed tracepoint output */
27 COMPACT_NO_SUITABLE_PAGE,
28 COMPACT_NOT_SUITABLE_ZONE,
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
40 struct alloc_context; /* in mm/internal.h */
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);
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);
49 extern int sysctl_compact_unevictable_allowed;
51 extern int fragmentation_index(struct zone *zone, unsigned int order);
52 extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
54 unsigned int alloc_flags, const struct alloc_context *ac,
55 enum migrate_mode mode, int *contended);
56 extern void compact_pgdat(pg_data_t *pgdat, int order);
57 extern void reset_isolation_suitable(pg_data_t *pgdat);
58 extern enum compact_result compaction_suitable(struct zone *zone, int order,
59 unsigned int alloc_flags, int classzone_idx);
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,
65 extern bool compaction_restarting(struct zone *zone, int order);
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);
72 static inline enum compact_result try_to_compact_pages(gfp_t gfp_mask,
73 unsigned int order, int alloc_flags,
74 const struct alloc_context *ac,
75 enum migrate_mode mode, int *contended)
77 return COMPACT_CONTINUE;
80 static inline void compact_pgdat(pg_data_t *pgdat, int order)
84 static inline void reset_isolation_suitable(pg_data_t *pgdat)
88 static inline enum compact_result compaction_suitable(struct zone *zone, int order,
89 int alloc_flags, int classzone_idx)
91 return COMPACT_SKIPPED;
94 static inline void defer_compaction(struct zone *zone, int order)
98 static inline bool compaction_deferred(struct zone *zone, int order)
103 static inline int kcompactd_run(int nid)
107 static inline void kcompactd_stop(int nid)
111 static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
115 #endif /* CONFIG_COMPACTION */
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);
123 static inline int compaction_register_node(struct node *node)
128 static inline void compaction_unregister_node(struct node *node)
131 #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
133 #endif /* _LINUX_COMPACTION_H */