compaction.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. 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. 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. #else
  49. static inline unsigned long try_to_compact_pages(gfp_t gfp_mask,
  50. unsigned int order, int alloc_flags,
  51. const struct alloc_context *ac,
  52. enum migrate_mode mode, int *contended)
  53. {
  54. return COMPACT_CONTINUE;
  55. }
  56. static inline void compact_pgdat(pg_data_t *pgdat, int order)
  57. {
  58. }
  59. static inline void reset_isolation_suitable(pg_data_t *pgdat)
  60. {
  61. }
  62. static inline unsigned long compaction_suitable(struct zone *zone, int order,
  63. int alloc_flags, int classzone_idx)
  64. {
  65. return COMPACT_SKIPPED;
  66. }
  67. static inline void defer_compaction(struct zone *zone, int order)
  68. {
  69. }
  70. static inline bool compaction_deferred(struct zone *zone, int order)
  71. {
  72. return true;
  73. }
  74. #endif /* CONFIG_COMPACTION */
  75. #if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
  76. extern int compaction_register_node(struct node *node);
  77. extern void compaction_unregister_node(struct node *node);
  78. #else
  79. static inline int compaction_register_node(struct node *node)
  80. {
  81. return 0;
  82. }
  83. static inline void compaction_unregister_node(struct node *node)
  84. {
  85. }
  86. #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
  87. #endif /* _LINUX_COMPACTION_H */