in src/oomd/plugins/KillMemoryGrowth-inl.h [149:195]
void KillMemoryGrowth<Base>::ologKillTarget(
OomdContext& ctx,
const CgroupContext& target,
const std::vector<OomdContext::ConstCgroupContextRef>& peers) {
auto rank_cgroup = get_ranking_fn(ctx, peers);
int64_t sib_memcurrent = 0;
for (const CgroupContext& cgroup_ctx : peers) {
sib_memcurrent += cgroup_ctx.current_usage().value_or(0);
}
switch (rank_cgroup(target).first) {
case KMGPhase::SIZE_THRESHOLD: {
OLOG << "Picked \"" << target.cgroup().relativePath() << "\" ("
<< target.current_usage().value_or(0) / 1024 / 1024
<< "MB) based on size > " << size_threshold_ << "% of sibling total "
<< sib_memcurrent / 1024 / 1024 << "MB"
<< " with kill preference "
<< target.kill_preference().value_or(KillPreference::NORMAL);
break;
}
case KMGPhase::GROWTH: {
std::ostringstream oss;
oss << std::setprecision(2) << std::fixed;
oss << "Picked \"" << target.cgroup().relativePath() << "\" ("
<< target.current_usage().value_or(0) / 1024 / 1024
<< "MB) based on growth rate " << target.memory_growth().value_or(0)
<< " (min growth rate " << min_growth_ratio_ << ")"
<< " among P" << growing_size_percentile_ << " largest,"
<< " with kill preference "
<< target.kill_preference().value_or(KillPreference::NORMAL);
OLOG << oss.str();
break;
}
case KMGPhase::SIZE_NO_THRESHOLD: {
OLOG << "Picked \"" << target.cgroup().relativePath() << "\" ("
<< target.current_usage().value_or(0) / 1024 / 1024
<< "MB) based on effective usage of "
<< target.effective_usage().value_or(0) << "MB"
<< " with kill preference "
<< target.kill_preference().value_or(KillPreference::NORMAL);
break;
}
}
}