compaction.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. /* When adding new state, please change compaction_status_string, too */
  18. /* Used to signal whether compaction detected need_sched() or lock contention */
  19. /* No contention detected */
  20. #define COMPACT_CONTENDED_NONE 0
  21. /* Either need_sched() was true or fatal signal pending */
  22. #define COMPACT_CONTENDED_SCHED 1
  23. /* Zone lock or lru_lock was contended in async compaction */
  24. #define COMPACT_CONTENDED_LOCK 2
  25. struct alloc_context; /* in mm/internal.h */
  26. #ifdef CONFIG_COMPACTION
  27. extern int sysctl_compact_memory;
  28. extern int sysctl_compaction_handler(struct ctl_table *table, int write,
  29. void __user *buffer, size_t *length, loff_t *ppos);
  30. extern int sysctl_extfrag_threshold;
  31. extern int sysctl_extfrag_handler(struct ctl_table *table, int write,
  32. void __user *buffer, size_t *length, loff_t *ppos);
  33. extern int fragmentation_index(struct zone *zone, unsigned int order);
  34. extern unsigned long try_to_compact_pages(gfp_t gfp_mask, unsigned int order,
  35. int alloc_flags, const struct alloc_context *ac,
  36. enum migrate_mode mode, int *contended);
  37. extern void compact_pgdat(pg_data_t *pgdat, int order);
  38. extern void reset_isolation_suitable(pg_data_t *pgdat);
  39. extern unsigned long compaction_suitable(struct zone *zone, int order,
  40. int alloc_flags, int classzone_idx);
  41. extern void defer_compaction(struct zone *zone, int order);
  42. extern bool compaction_deferred(struct zone *zone, int order);
  43. extern void compaction_defer_reset(struct zone *zone, int order,
  44. bool alloc_success);
  45. extern bool compaction_restarting(struct zone *zone, int order);
  46. #else
  47. static inline unsigned long try_to_compact_pages(gfp_t gfp_mask,
  48. unsigned int order, int alloc_flags,
  49. const struct alloc_context *ac,
  50. enum migrate_mode mode, int *contended)
  51. {
  52. return COMPACT_CONTINUE;
  53. }
  54. static inline void compact_pgdat(pg_data_t *pgdat, int order)
  55. {
  56. }
  57. static inline void reset_isolation_suitable(pg_data_t *pgdat)
  58. {
  59. }
  60. static inline unsigned long compaction_suitable(struct zone *zone, int order,
  61. int alloc_flags, int classzone_idx)
  62. {
  63. return COMPACT_SKIPPED;
  64. }
  65. static inline void defer_compaction(struct zone *zone, int order)
  66. {
  67. }
  68. static inline bool compaction_deferred(struct zone *zone, int order)
  69. {
  70. return true;
  71. }
  72. #endif /* CONFIG_COMPACTION */
  73. #if defined(CONFIG_COMPACTION) && defined(CONFIG_SYSFS) && defined(CONFIG_NUMA)
  74. extern int compaction_register_node(struct node *node);
  75. extern void compaction_unregister_node(struct node *node);
  76. #else
  77. static inline int compaction_register_node(struct node *node)
  78. {
  79. return 0;
  80. }
  81. static inline void compaction_unregister_node(struct node *node)
  82. {
  83. }
  84. #endif /* CONFIG_COMPACTION && CONFIG_SYSFS && CONFIG_NUMA */
  85. #endif /* _LINUX_COMPACTION_H */