diff options
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/compaction.h | 65 |
1 files changed, 5 insertions, 60 deletions
diff --git a/include/linux/compaction.h b/include/linux/compaction.h index 501d7513aac1..a014559e4a49 100644 --- a/include/linux/compaction.h +++ b/include/linux/compaction.h | |||
| @@ -44,66 +44,11 @@ extern void reset_isolation_suitable(pg_data_t *pgdat); | |||
| 44 | extern unsigned long compaction_suitable(struct zone *zone, int order, | 44 | extern unsigned long compaction_suitable(struct zone *zone, int order, |
| 45 | int alloc_flags, int classzone_idx); | 45 | int alloc_flags, int classzone_idx); |
| 46 | 46 | ||
| 47 | /* Do not skip compaction more than 64 times */ | 47 | extern void defer_compaction(struct zone *zone, int order); |
| 48 | #define COMPACT_MAX_DEFER_SHIFT 6 | 48 | extern bool compaction_deferred(struct zone *zone, int order); |
| 49 | 49 | extern void compaction_defer_reset(struct zone *zone, int order, | |
| 50 | /* | 50 | bool alloc_success); |
| 51 | * Compaction is deferred when compaction fails to result in a page | 51 | extern bool compaction_restarting(struct zone *zone, int order); |
| 52 | * allocation success. 1 << compact_defer_limit compactions are skipped up | ||
| 53 | * to a limit of 1 << COMPACT_MAX_DEFER_SHIFT | ||
| 54 | */ | ||
| 55 | static inline void defer_compaction(struct zone *zone, int order) | ||
| 56 | { | ||
| 57 | zone->compact_considered = 0; | ||
| 58 | zone->compact_defer_shift++; | ||
| 59 | |||
| 60 | if (order < zone->compact_order_failed) | ||
| 61 | zone->compact_order_failed = order; | ||
| 62 | |||
| 63 | if (zone->compact_defer_shift > COMPACT_MAX_DEFER_SHIFT) | ||
| 64 | zone->compact_defer_shift = COMPACT_MAX_DEFER_SHIFT; | ||
| 65 | } | ||
| 66 | |||
| 67 | /* Returns true if compaction should be skipped this time */ | ||
| 68 | static inline bool compaction_deferred(struct zone *zone, int order) | ||
| 69 | { | ||
| 70 | unsigned long defer_limit = 1UL << zone->compact_defer_shift; | ||
| 71 | |||
| 72 | if (order < zone->compact_order_failed) | ||
| 73 | return false; | ||
| 74 | |||
| 75 | /* Avoid possible overflow */ | ||
| 76 | if (++zone->compact_considered > defer_limit) | ||
| 77 | zone->compact_considered = defer_limit; | ||
| 78 | |||
| 79 | return zone->compact_considered < defer_limit; | ||
| 80 | } | ||
| 81 | |||
| 82 | /* | ||
| 83 | * Update defer tracking counters after successful compaction of given order, | ||
| 84 | * which means an allocation either succeeded (alloc_success == true) or is | ||
| 85 | * expected to succeed. | ||
| 86 | */ | ||
| 87 | static inline void compaction_defer_reset(struct zone *zone, int order, | ||
| 88 | bool alloc_success) | ||
| 89 | { | ||
| 90 | if (alloc_success) { | ||
| 91 | zone->compact_considered = 0; | ||
| 92 | zone->compact_defer_shift = 0; | ||
| 93 | } | ||
| 94 | if (order >= zone->compact_order_failed) | ||
| 95 | zone->compact_order_failed = order + 1; | ||
| 96 | } | ||
| 97 | |||
| 98 | /* Returns true if restarting compaction after many failures */ | ||
| 99 | static inline bool compaction_restarting(struct zone *zone, int order) | ||
| 100 | { | ||
| 101 | if (order < zone->compact_order_failed) | ||
| 102 | return false; | ||
| 103 | |||
| 104 | return zone->compact_defer_shift == COMPACT_MAX_DEFER_SHIFT && | ||
| 105 | zone->compact_considered >= 1UL << zone->compact_defer_shift; | ||
| 106 | } | ||
| 107 | 52 | ||
| 108 | #else | 53 | #else |
| 109 | static inline unsigned long try_to_compact_pages(gfp_t gfp_mask, | 54 | static inline unsigned long try_to_compact_pages(gfp_t gfp_mask, |
