blob: a014559e4a49d7a3bb95d49e72e68221ef8f4548 [file] [log] [blame]
Mel Gorman748446b2010-05-24 14:32:27 -07001#ifndef _LINUX_COMPACTION_H
2#define _LINUX_COMPACTION_H
3
Mel Gorman56de7262010-05-24 14:32:30 -07004/* Return values for compact_zone() and try_to_compact_pages() */
Vlastimil Babka53853e22014-10-09 15:27:02 -07005/* compaction didn't start as it was deferred due to past failures */
6#define COMPACT_DEFERRED 0
Mel Gorman56de7262010-05-24 14:32:30 -07007/* compaction didn't start as it was not possible or direct reclaim was more suitable */
Vlastimil Babka53853e22014-10-09 15:27:02 -07008#define COMPACT_SKIPPED 1
Mel Gorman56de7262010-05-24 14:32:30 -07009/* compaction should continue to another pageblock */
Vlastimil Babka53853e22014-10-09 15:27:02 -070010#define COMPACT_CONTINUE 2
Mel Gorman56de7262010-05-24 14:32:30 -070011/* direct compaction partially compacted a zone and there are suitable pages */
Vlastimil Babka53853e22014-10-09 15:27:02 -070012#define COMPACT_PARTIAL 3
Mel Gorman56de7262010-05-24 14:32:30 -070013/* The full zone was compacted */
Vlastimil Babka53853e22014-10-09 15:27:02 -070014#define COMPACT_COMPLETE 4
Joonsoo Kim837d0262015-02-11 15:27:06 -080015/* For more detailed tracepoint output */
16#define COMPACT_NO_SUITABLE_PAGE 5
17#define COMPACT_NOT_SUITABLE_ZONE 6
Joonsoo Kim16c4a092015-02-11 15:27:01 -080018/* When adding new state, please change compaction_status_string, too */
Mel Gorman748446b2010-05-24 14:32:27 -070019
Vlastimil Babka1f9efde2014-10-09 15:27:14 -070020/* 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
Vlastimil Babka1a6d53a2015-02-11 15:25:44 -080028struct alloc_context; /* in mm/internal.h */
29
Mel Gorman76ab0f52010-05-24 14:32:28 -070030#ifdef CONFIG_COMPACTION
31extern int sysctl_compact_memory;
32extern int sysctl_compaction_handler(struct ctl_table *table, int write,
33 void __user *buffer, size_t *length, loff_t *ppos);
Mel Gorman5e771902010-05-24 14:32:31 -070034extern int sysctl_extfrag_threshold;
35extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
36 void __user *buffer, size_t *length, loff_t *ppos);
Mel Gorman56de7262010-05-24 14:32:30 -070037
38extern int fragmentation_index(struct zone *zone, unsigned int order);
Vlastimil Babka1a6d53a2015-02-11 15:25:44 -080039extern unsigned long try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
40 int alloc_flags, const struct alloc_context *ac,
41 enum migrate_mode mode, int *contended);
Andrew Morton7103f162013-02-22 16:32:33 -080042extern void compact_pgdat(pg_data_t *pgdat, int order);
Mel Gorman62997022012-10-08 16:32:47 -070043extern void reset_isolation_suitable(pg_data_t *pgdat);
Vlastimil Babkaebff3982014-12-10 15:43:22 -080044extern unsigned long compaction_suitable(struct zone *zone, int order,
45 int alloc_flags, int classzone_idx);
Mel Gorman4f92e252010-05-24 14:32:32 -070046
Joonsoo Kim24e27162015-02-11 15:27:09 -080047extern void defer_compaction(struct zone *zone, int order);
48extern bool compaction_deferred(struct zone *zone, int order);
49extern void compaction_defer_reset(struct zone *zone, int order,
50 bool alloc_success);
51extern bool compaction_restarting(struct zone *zone, int order);
Mel Gorman62997022012-10-08 16:32:47 -070052
Mel Gorman56de7262010-05-24 14:32:30 -070053#else
Vlastimil Babka1a6d53a2015-02-11 15:25:44 -080054static inline unsigned long try_to_compact_pages(gfp_t gfp_mask,
55 unsigned int order, int alloc_flags,
56 const struct alloc_context *ac,
57 enum migrate_mode mode, int *contended)
Mel Gorman56de7262010-05-24 14:32:30 -070058{
59 return COMPACT_CONTINUE;
60}
61
Andrew Morton7103f162013-02-22 16:32:33 -080062static inline void compact_pgdat(pg_data_t *pgdat, int order)
Rik van Riel7be62de2012-03-21 16:33:52 -070063{
Rik van Riel7be62de2012-03-21 16:33:52 -070064}
65
Mel Gorman62997022012-10-08 16:32:47 -070066static inline void reset_isolation_suitable(pg_data_t *pgdat)
67{
68}
69
Vlastimil Babkaebff3982014-12-10 15:43:22 -080070static inline unsigned long compaction_suitable(struct zone *zone, int order,
71 int alloc_flags, int classzone_idx)
Mel Gorman3e7d3442011-01-13 15:45:56 -080072{
73 return COMPACT_SKIPPED;
74}
75
Rik van Rielaff62242012-03-21 16:33:52 -070076static inline void defer_compaction(struct zone *zone, int order)
Mel Gorman4f92e252010-05-24 14:32:32 -070077{
78}
79
Rik van Rielaff62242012-03-21 16:33:52 -070080static inline bool compaction_deferred(struct zone *zone, int order)
Mel Gorman4f92e252010-05-24 14:32:32 -070081{
Gavin Shanc59e2612012-07-31 16:42:49 -070082 return true;
Mel Gorman4f92e252010-05-24 14:32:32 -070083}
84
Mel Gorman76ab0f52010-05-24 14:32:28 -070085#endif /* CONFIG_COMPACTION */
86
Mel Gormaned4a6d72010-05-24 14:32:29 -070087#if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
88extern int compaction_register_node(struct node *node);
89extern void compaction_unregister_node(struct node *node);
90
91#else
92
93static inline int compaction_register_node(struct node *node)
94{
95 return 0;
96}
97
98static inline void compaction_unregister_node(struct node *node)
99{
100}
101#endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
102
Mel Gorman748446b2010-05-24 14:32:27 -0700103#endif /* _LINUX_COMPACTION_H */