compaction.h 3.7 KB

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