at v4.4-rc3 3.5 kB view raw
1#ifndef _LINUX_COMPACTION_H 2#define _LINUX_COMPACTION_H 3 4/* Return values for compact_zone() and try_to_compact_pages() */ 5/* compaction didn't start as it was deferred due to past failures */ 6#define COMPACT_DEFERRED 0 7/* compaction didn't start as it was not possible or direct reclaim was more suitable */ 8#define COMPACT_SKIPPED 1 9/* compaction should continue to another pageblock */ 10#define COMPACT_CONTINUE 2 11/* direct compaction partially compacted a zone and there are suitable pages */ 12#define COMPACT_PARTIAL 3 13/* The full zone was compacted */ 14#define COMPACT_COMPLETE 4 15/* For more detailed tracepoint output */ 16#define COMPACT_NO_SUITABLE_PAGE 5 17#define COMPACT_NOT_SUITABLE_ZONE 6 18#define COMPACT_CONTENDED 7 19/* When adding new states, please adjust include/trace/events/compaction.h */ 20 21/* Used to signal whether compaction detected need_sched() or lock contention */ 22/* No contention detected */ 23#define COMPACT_CONTENDED_NONE 0 24/* Either need_sched() was true or fatal signal pending */ 25#define COMPACT_CONTENDED_SCHED 1 26/* Zone lock or lru_lock was contended in async compaction */ 27#define COMPACT_CONTENDED_LOCK 2 28 29struct alloc_context; /* in mm/internal.h */ 30 31#ifdef CONFIG_COMPACTION 32extern int sysctl_compact_memory; 33extern int sysctl_compaction_handler(struct ctl_table *table, int write, 34 void __user *buffer, size_t *length, loff_t *ppos); 35extern int sysctl_extfrag_threshold; 36extern int sysctl_extfrag_handler(struct ctl_table *table, int write, 37 void __user *buffer, size_t *length, loff_t *ppos); 38extern int sysctl_compact_unevictable_allowed; 39 40extern int fragmentation_index(struct zone *zone, unsigned int order); 41extern unsigned long try_to_compact_pages(gfp_t gfp_mask, unsigned int order, 42 int alloc_flags, const struct alloc_context *ac, 43 enum migrate_mode mode, int *contended); 44extern void compact_pgdat(pg_data_t *pgdat, int order); 45extern void reset_isolation_suitable(pg_data_t *pgdat); 46extern unsigned long compaction_suitable(struct zone *zone, int order, 47 int alloc_flags, int classzone_idx); 48 49extern void defer_compaction(struct zone *zone, int order); 50extern bool compaction_deferred(struct zone *zone, int order); 51extern void compaction_defer_reset(struct zone *zone, int order, 52 bool alloc_success); 53extern bool compaction_restarting(struct zone *zone, int order); 54 55#else 56static inline unsigned long try_to_compact_pages(gfp_t gfp_mask, 57 unsigned int order, int alloc_flags, 58 const struct alloc_context *ac, 59 enum migrate_mode mode, int *contended) 60{ 61 return COMPACT_CONTINUE; 62} 63 64static inline void compact_pgdat(pg_data_t *pgdat, int order) 65{ 66} 67 68static inline void reset_isolation_suitable(pg_data_t *pgdat) 69{ 70} 71 72static inline unsigned long compaction_suitable(struct zone *zone, int order, 73 int alloc_flags, int classzone_idx) 74{ 75 return COMPACT_SKIPPED; 76} 77 78static inline void defer_compaction(struct zone *zone, int order) 79{ 80} 81 82static inline bool compaction_deferred(struct zone *zone, int order) 83{ 84 return true; 85} 86 87#endif /* CONFIG_COMPACTION */ 88 89#if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA) 90extern int compaction_register_node(struct node *node); 91extern void compaction_unregister_node(struct node *node); 92 93#else 94 95static inline int compaction_register_node(struct node *node) 96{ 97 return 0; 98} 99 100static inline void compaction_unregister_node(struct node *node) 101{ 102} 103#endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */ 104 105#endif /* _LINUX_COMPACTION_H */