blob: aa8f61cf3a19fa3a28214f2a504e031e9e7d3e68 [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);
Eric B Munson5bbe3542015-04-15 16:13:20 -070037extern int sysctl_compact_unevictable_allowed;
Mel Gorman56de7262010-05-24 14:32:30 -070038
39extern int fragmentation_index(struct zone *zone, unsigned int order);
Vlastimil Babka1a6d53a2015-02-11 15:25:44 -080040extern 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);
Andrew Morton7103f162013-02-22 16:32:33 -080043extern void compact_pgdat(pg_data_t *pgdat, int order);
Mel Gorman62997022012-10-08 16:32:47 -070044extern void reset_isolation_suitable(pg_data_t *pgdat);
Vlastimil Babkaebff3982014-12-10 15:43:22 -080045extern unsigned long compaction_suitable(struct zone *zone, int order,
46 int alloc_flags, int classzone_idx);
Mel Gorman4f92e252010-05-24 14:32:32 -070047
Joonsoo Kim24e27162015-02-11 15:27:09 -080048extern void defer_compaction(struct zone *zone, int order);
49extern bool compaction_deferred(struct zone *zone, int order);
50extern void compaction_defer_reset(struct zone *zone, int order,
51 bool alloc_success);
52extern bool compaction_restarting(struct zone *zone, int order);
Mel Gorman62997022012-10-08 16:32:47 -070053
Mel Gorman56de7262010-05-24 14:32:30 -070054#else
Vlastimil Babka1a6d53a2015-02-11 15:25:44 -080055static 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)
Mel Gorman56de7262010-05-24 14:32:30 -070059{
60 return COMPACT_CONTINUE;
61}
62
Andrew Morton7103f162013-02-22 16:32:33 -080063static inline void compact_pgdat(pg_data_t *pgdat, int order)
Rik van Riel7be62de2012-03-21 16:33:52 -070064{
Rik van Riel7be62de2012-03-21 16:33:52 -070065}
66
Mel Gorman62997022012-10-08 16:32:47 -070067static inline void reset_isolation_suitable(pg_data_t *pgdat)
68{
69}
70
Vlastimil Babkaebff3982014-12-10 15:43:22 -080071static inline unsigned long compaction_suitable(struct zone *zone, int order,
72 int alloc_flags, int classzone_idx)
Mel Gorman3e7d3442011-01-13 15:45:56 -080073{
74 return COMPACT_SKIPPED;
75}
76
Rik van Rielaff62242012-03-21 16:33:52 -070077static inline void defer_compaction(struct zone *zone, int order)
Mel Gorman4f92e252010-05-24 14:32:32 -070078{
79}
80
Rik van Rielaff62242012-03-21 16:33:52 -070081static inline bool compaction_deferred(struct zone *zone, int order)
Mel Gorman4f92e252010-05-24 14:32:32 -070082{
Gavin Shanc59e2612012-07-31 16:42:49 -070083 return true;
Mel Gorman4f92e252010-05-24 14:32:32 -070084}
85
Mel Gorman76ab0f52010-05-24 14:32:28 -070086#endif /* CONFIG_COMPACTION */
87
Mel Gormaned4a6d72010-05-24 14:32:29 -070088#if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
89extern int compaction_register_node(struct node *node);
90extern void compaction_unregister_node(struct node *node);
91
92#else
93
94static inline int compaction_register_node(struct node *node)
95{
96 return 0;
97}
98
99static inline void compaction_unregister_node(struct node *node)
100{
101}
102#endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
103
Mel Gorman748446b2010-05-24 14:32:27 -0700104#endif /* _LINUX_COMPACTION_H */