Mel Gorman | 748446b | 2010-05-24 14:32:27 -0700 | [diff] [blame] | 1 | #ifndef _LINUX_COMPACTION_H |
| 2 | #define _LINUX_COMPACTION_H |
| 3 | |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 4 | /* Return values for compact_zone() and try_to_compact_pages() */ |
Vlastimil Babka | 53853e2 | 2014-10-09 15:27:02 -0700 | [diff] [blame] | 5 | /* compaction didn't start as it was deferred due to past failures */ |
| 6 | #define COMPACT_DEFERRED 0 |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 7 | /* compaction didn't start as it was not possible or direct reclaim was more suitable */ |
Vlastimil Babka | 53853e2 | 2014-10-09 15:27:02 -0700 | [diff] [blame] | 8 | #define COMPACT_SKIPPED 1 |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 9 | /* compaction should continue to another pageblock */ |
Vlastimil Babka | 53853e2 | 2014-10-09 15:27:02 -0700 | [diff] [blame] | 10 | #define COMPACT_CONTINUE 2 |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 11 | /* direct compaction partially compacted a zone and there are suitable pages */ |
Vlastimil Babka | 53853e2 | 2014-10-09 15:27:02 -0700 | [diff] [blame] | 12 | #define COMPACT_PARTIAL 3 |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 13 | /* The full zone was compacted */ |
Vlastimil Babka | 53853e2 | 2014-10-09 15:27:02 -0700 | [diff] [blame] | 14 | #define COMPACT_COMPLETE 4 |
Joonsoo Kim | 837d026 | 2015-02-11 15:27:06 -0800 | [diff] [blame] | 15 | /* For more detailed tracepoint output */ |
| 16 | #define COMPACT_NO_SUITABLE_PAGE 5 |
| 17 | #define COMPACT_NOT_SUITABLE_ZONE 6 |
Joonsoo Kim | 16c4a09 | 2015-02-11 15:27:01 -0800 | [diff] [blame] | 18 | /* When adding new state, please change compaction_status_string, too */ |
Mel Gorman | 748446b | 2010-05-24 14:32:27 -0700 | [diff] [blame] | 19 | |
Vlastimil Babka | 1f9efde | 2014-10-09 15:27:14 -0700 | [diff] [blame] | 20 | /* 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 Babka | 1a6d53a | 2015-02-11 15:25:44 -0800 | [diff] [blame] | 28 | struct alloc_context; /* in mm/internal.h */ |
| 29 | |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 30 | #ifdef CONFIG_COMPACTION |
| 31 | extern int sysctl_compact_memory; |
| 32 | extern int sysctl_compaction_handler(struct ctl_table *table, int write, |
| 33 | void __user *buffer, size_t *length, loff_t *ppos); |
Mel Gorman | 5e77190 | 2010-05-24 14:32:31 -0700 | [diff] [blame] | 34 | extern int sysctl_extfrag_threshold; |
| 35 | extern int sysctl_extfrag_handler(struct ctl_table *table, int write, |
| 36 | void __user *buffer, size_t *length, loff_t *ppos); |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 37 | |
| 38 | extern int fragmentation_index(struct zone *zone, unsigned int order); |
Vlastimil Babka | 1a6d53a | 2015-02-11 15:25:44 -0800 | [diff] [blame] | 39 | extern 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 Morton | 7103f16 | 2013-02-22 16:32:33 -0800 | [diff] [blame] | 42 | extern void compact_pgdat(pg_data_t *pgdat, int order); |
Mel Gorman | 6299702 | 2012-10-08 16:32:47 -0700 | [diff] [blame] | 43 | extern void reset_isolation_suitable(pg_data_t *pgdat); |
Vlastimil Babka | ebff398 | 2014-12-10 15:43:22 -0800 | [diff] [blame] | 44 | extern unsigned long compaction_suitable(struct zone *zone, int order, |
| 45 | int alloc_flags, int classzone_idx); |
Mel Gorman | 4f92e25 | 2010-05-24 14:32:32 -0700 | [diff] [blame] | 46 | |
Joonsoo Kim | 24e2716 | 2015-02-11 15:27:09 -0800 | [diff] [blame] | 47 | extern void defer_compaction(struct zone *zone, int order); |
| 48 | extern bool compaction_deferred(struct zone *zone, int order); |
| 49 | extern void compaction_defer_reset(struct zone *zone, int order, |
| 50 | bool alloc_success); |
| 51 | extern bool compaction_restarting(struct zone *zone, int order); |
Mel Gorman | 6299702 | 2012-10-08 16:32:47 -0700 | [diff] [blame] | 52 | |
Mel Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 53 | #else |
Vlastimil Babka | 1a6d53a | 2015-02-11 15:25:44 -0800 | [diff] [blame] | 54 | static 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 Gorman | 56de726 | 2010-05-24 14:32:30 -0700 | [diff] [blame] | 58 | { |
| 59 | return COMPACT_CONTINUE; |
| 60 | } |
| 61 | |
Andrew Morton | 7103f16 | 2013-02-22 16:32:33 -0800 | [diff] [blame] | 62 | static inline void compact_pgdat(pg_data_t *pgdat, int order) |
Rik van Riel | 7be62de | 2012-03-21 16:33:52 -0700 | [diff] [blame] | 63 | { |
Rik van Riel | 7be62de | 2012-03-21 16:33:52 -0700 | [diff] [blame] | 64 | } |
| 65 | |
Mel Gorman | 6299702 | 2012-10-08 16:32:47 -0700 | [diff] [blame] | 66 | static inline void reset_isolation_suitable(pg_data_t *pgdat) |
| 67 | { |
| 68 | } |
| 69 | |
Vlastimil Babka | ebff398 | 2014-12-10 15:43:22 -0800 | [diff] [blame] | 70 | static inline unsigned long compaction_suitable(struct zone *zone, int order, |
| 71 | int alloc_flags, int classzone_idx) |
Mel Gorman | 3e7d344 | 2011-01-13 15:45:56 -0800 | [diff] [blame] | 72 | { |
| 73 | return COMPACT_SKIPPED; |
| 74 | } |
| 75 | |
Rik van Riel | aff6224 | 2012-03-21 16:33:52 -0700 | [diff] [blame] | 76 | static inline void defer_compaction(struct zone *zone, int order) |
Mel Gorman | 4f92e25 | 2010-05-24 14:32:32 -0700 | [diff] [blame] | 77 | { |
| 78 | } |
| 79 | |
Rik van Riel | aff6224 | 2012-03-21 16:33:52 -0700 | [diff] [blame] | 80 | static inline bool compaction_deferred(struct zone *zone, int order) |
Mel Gorman | 4f92e25 | 2010-05-24 14:32:32 -0700 | [diff] [blame] | 81 | { |
Gavin Shan | c59e261 | 2012-07-31 16:42:49 -0700 | [diff] [blame] | 82 | return true; |
Mel Gorman | 4f92e25 | 2010-05-24 14:32:32 -0700 | [diff] [blame] | 83 | } |
| 84 | |
Mel Gorman | 76ab0f5 | 2010-05-24 14:32:28 -0700 | [diff] [blame] | 85 | #endif /* CONFIG_COMPACTION */ |
| 86 | |
Mel Gorman | ed4a6d7 | 2010-05-24 14:32:29 -0700 | [diff] [blame] | 87 | #if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) |
| 88 | extern int compaction_register_node(struct node *node); |
| 89 | extern void compaction_unregister_node(struct node *node); |
| 90 | |
| 91 | #else |
| 92 | |
| 93 | static inline int compaction_register_node(struct node *node) |
| 94 | { |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | static inline void compaction_unregister_node(struct node *node) |
| 99 | { |
| 100 | } |
| 101 | #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */ |
| 102 | |
Mel Gorman | 748446b | 2010-05-24 14:32:27 -0700 | [diff] [blame] | 103 | #endif /* _LINUX_COMPACTION_H */ |