diff options
Diffstat (limited to 'src/oom/oomd-util.h')
-rw-r--r-- | src/oom/oomd-util.h | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/oom/oomd-util.h b/src/oom/oomd-util.h index 181443ae7a..560697a4f4 100644 --- a/src/oom/oomd-util.h +++ b/src/oom/oomd-util.h @@ -66,7 +66,8 @@ bool oomd_swap_free_below(const OomdSystemContext *ctx, int threshold_permyriad) /* The compare functions will sort from largest to smallest, putting all the contexts with "avoid" at the end * (after the smallest values). */ -static inline int compare_pgscan_and_memory_usage(OomdCGroupContext * const *c1, OomdCGroupContext * const *c2) { +static inline int compare_pgscan_rate_and_memory_usage(OomdCGroupContext * const *c1, OomdCGroupContext * const *c2) { + uint64_t last1, last2; int r; assert(c1); @@ -76,7 +77,22 @@ static inline int compare_pgscan_and_memory_usage(OomdCGroupContext * const *c1, if (r != 0) return r; - r = CMP((*c2)->pgscan, (*c1)->pgscan); + /* If last_pgscan > pgscan, assume the cgroup was recreated and reset last_pgscan to zero. */ + last2 = (*c2)->last_pgscan; + if ((*c2)->last_pgscan > (*c2)->pgscan) { + log_info("Last pgscan %" PRIu64 "greater than current pgscan %" PRIu64 "for %s. Using last pgscan of zero.", + (*c2)->last_pgscan, (*c2)->pgscan, (*c2)->path); + last2 = 0; + } + + last1 = (*c1)->last_pgscan; + if ((*c1)->last_pgscan > (*c1)->pgscan) { + log_info("Last pgscan %" PRIu64 "greater than current pgscan %" PRIu64 "for %s. Using last pgscan of zero.", + (*c1)->last_pgscan, (*c1)->pgscan, (*c1)->path); + last1 = 0; + } + + r = CMP((*c2)->pgscan - last2, (*c1)->pgscan - last1); if (r != 0) return r; @@ -107,7 +123,7 @@ int oomd_cgroup_kill(const char *path, bool recurse, bool dry_run); /* The following oomd_kill_by_* functions return 1 if processes were killed, or negative otherwise. */ /* If `prefix` is supplied, only cgroups whose paths start with `prefix` are eligible candidates. Otherwise, * everything in `h` is a candidate. */ -int oomd_kill_by_pgscan(Hashmap *h, const char *prefix, bool dry_run); +int oomd_kill_by_pgscan_rate(Hashmap *h, const char *prefix, bool dry_run); int oomd_kill_by_swap_usage(Hashmap *h, bool dry_run); int oomd_cgroup_context_acquire(const char *path, OomdCGroupContext **ret); @@ -119,6 +135,9 @@ int oomd_system_context_acquire(const char *proc_swaps_path, OomdSystemContext * * was no prior data to reference. */ int oomd_insert_cgroup_context(Hashmap *old_h, Hashmap *new_h, const char *path); +/* Update each OomdCGroupContext in `curr_h` with prior interval information from `old_h`. */ +void oomd_update_cgroup_contexts_between_hashmaps(Hashmap *old_h, Hashmap *curr_h); + void oomd_dump_swap_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const char *prefix); void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE *f, const char *prefix); void oomd_dump_system_context(const OomdSystemContext *ctx, FILE *f, const char *prefix); |