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 */
7 /* compaction didn't start as it was deferred due to past failures */
10 * compaction didn't start as it was not possible or direct reclaim
14 /* compaction should continue to another pageblock */
17 * direct compaction partially compacted a zone and there are suitable
21 /* The full zone was compacted */
23 /* For more detailed tracepoint output */
24 COMPACT_NO_SUITABLE_PAGE,
25 COMPACT_NOT_SUITABLE_ZONE,
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
37 struct alloc_context; /* in mm/internal.h */
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;
48 extern int fragmentation_index(struct zone *zone, unsigned int order);
49 extern enum compact_result try_to_compact_pages(gfp_t gfp_mask,
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);
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,
62 extern bool compaction_restarting(struct zone *zone, int order);
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);
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)
74 return COMPACT_CONTINUE;
77 static inline void compact_pgdat(pg_data_t *pgdat, int order)
81 static inline void reset_isolation_suitable(pg_data_t *pgdat)
85 static inline enum compact_result compaction_suitable(struct zone *zone, int order,
86 int alloc_flags, int classzone_idx)
88 return COMPACT_SKIPPED;
91 static inline void defer_compaction(struct zone *zone, int order)
95 static inline bool compaction_deferred(struct zone *zone, int order)
100 static inline int kcompactd_run(int nid)
104 static inline void kcompactd_stop(int nid)
108 static inline void wakeup_kcompactd(pg_data_t *pgdat, int order, int classzone_idx)
112 #endif /* CONFIG_COMPACTION */
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);
120 static inline int compaction_register_node(struct node *node)
125 static inline void compaction_unregister_node(struct node *node)
128 #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
130 #endif /* _LINUX_COMPACTION_H */