mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-04 17:47:03 +03:00
oomd: rename last_hit_mem_pressure_limit -> mem_pressure_limit_hit_start
Since this is only changed the first time the limit is hit (and remains set as long as the pressure remains over), I changed the name to better reflect that. Keeps consistent with "last_had_mem_reclaim" which is actually updated every time there is reclaim activity.
This commit is contained in:
parent
df637ede7b
commit
69c8f0255a
@ -82,17 +82,17 @@ int oomd_pressure_above(Hashmap *h, usec_t duration, Set **ret) {
|
||||
if (ctx->memory_pressure.avg10 > ctx->mem_pressure_limit) {
|
||||
usec_t diff;
|
||||
|
||||
if (ctx->last_hit_mem_pressure_limit == 0)
|
||||
ctx->last_hit_mem_pressure_limit = now(CLOCK_MONOTONIC);
|
||||
if (ctx->mem_pressure_limit_hit_start == 0)
|
||||
ctx->mem_pressure_limit_hit_start = now(CLOCK_MONOTONIC);
|
||||
|
||||
diff = now(CLOCK_MONOTONIC) - ctx->last_hit_mem_pressure_limit;
|
||||
diff = now(CLOCK_MONOTONIC) - ctx->mem_pressure_limit_hit_start;
|
||||
if (diff >= duration) {
|
||||
r = set_put(targets, ctx);
|
||||
if (r < 0)
|
||||
return -ENOMEM;
|
||||
}
|
||||
} else
|
||||
ctx->last_hit_mem_pressure_limit = 0;
|
||||
ctx->mem_pressure_limit_hit_start = 0;
|
||||
}
|
||||
|
||||
if (!set_isempty(targets)) {
|
||||
@ -417,7 +417,7 @@ int oomd_insert_cgroup_context(Hashmap *old_h, Hashmap *new_h, const char *path)
|
||||
if (old_ctx) {
|
||||
curr_ctx->last_pgscan = old_ctx->pgscan;
|
||||
curr_ctx->mem_pressure_limit = old_ctx->mem_pressure_limit;
|
||||
curr_ctx->last_hit_mem_pressure_limit = old_ctx->last_hit_mem_pressure_limit;
|
||||
curr_ctx->mem_pressure_limit_hit_start = old_ctx->mem_pressure_limit_hit_start;
|
||||
curr_ctx->last_had_mem_reclaim = old_ctx->last_had_mem_reclaim;
|
||||
}
|
||||
|
||||
@ -447,7 +447,7 @@ void oomd_update_cgroup_contexts_between_hashmaps(Hashmap *old_h, Hashmap *curr_
|
||||
|
||||
ctx->last_pgscan = old_ctx->pgscan;
|
||||
ctx->mem_pressure_limit = old_ctx->mem_pressure_limit;
|
||||
ctx->last_hit_mem_pressure_limit = old_ctx->last_hit_mem_pressure_limit;
|
||||
ctx->mem_pressure_limit_hit_start = old_ctx->mem_pressure_limit_hit_start;
|
||||
ctx->last_had_mem_reclaim = old_ctx->last_had_mem_reclaim;
|
||||
|
||||
if (oomd_pgscan_rate(ctx) > 0)
|
||||
|
@ -35,7 +35,7 @@ struct OomdCGroupContext {
|
||||
/* These are only used for acting on high memory pressure. */
|
||||
loadavg_t mem_pressure_limit;
|
||||
usec_t mem_pressure_duration_usec;
|
||||
usec_t last_hit_mem_pressure_limit;
|
||||
usec_t mem_pressure_limit_hit_start;
|
||||
usec_t last_had_mem_reclaim;
|
||||
};
|
||||
|
||||
@ -52,7 +52,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(OomdCGroupContext*, oomd_cgroup_context_free);
|
||||
|
||||
/* Scans all the OomdCGroupContexts in `h` and returns 1 and a set of pointers to those OomdCGroupContexts in `ret`
|
||||
* if any of them have exceeded their supplied memory pressure limits for the `duration` length of time.
|
||||
* `last_hit_mem_pressure_limit` is updated accordingly for each entry when the limit is exceeded, and when it returns
|
||||
* `mem_pressure_limit_hit_start` is updated accordingly for the first time the limit is exceeded, and when it returns
|
||||
* below the limit.
|
||||
* Returns 0 and sets `ret` to an empty set if no entries exceeded limits for `duration`.
|
||||
* Returns -ENOMEM for allocation errors. */
|
||||
|
@ -155,7 +155,7 @@ static void test_oomd_cgroup_context_acquire_and_insert(void) {
|
||||
/* make sure certain values from h1 get updated in h2 */
|
||||
c1->pgscan = UINT64_MAX;
|
||||
c1->mem_pressure_limit = 6789;
|
||||
c1->last_hit_mem_pressure_limit = 42;
|
||||
c1->mem_pressure_limit_hit_start = 42;
|
||||
c1->last_had_mem_reclaim = 888;
|
||||
assert_se(h2 = hashmap_new(&oomd_cgroup_ctx_hash_ops));
|
||||
assert_se(oomd_insert_cgroup_context(h1, h2, cgroup) == 0);
|
||||
@ -166,7 +166,7 @@ static void test_oomd_cgroup_context_acquire_and_insert(void) {
|
||||
assert_se(c1 != c2);
|
||||
assert_se(c2->last_pgscan == UINT64_MAX);
|
||||
assert_se(c2->mem_pressure_limit == 6789);
|
||||
assert_se(c2->last_hit_mem_pressure_limit == 42);
|
||||
assert_se(c2->mem_pressure_limit_hit_start == 42);
|
||||
assert_se(c2->last_had_mem_reclaim == 888); /* assumes the live pgscan is less than UINT64_MAX */
|
||||
|
||||
/* Assert that avoid/omit are not set if the cgroup is not owned by root */
|
||||
@ -187,12 +187,12 @@ static void test_oomd_update_cgroup_contexts_between_hashmaps(void) {
|
||||
OomdCGroupContext ctx_old[2] = {
|
||||
{ .path = paths[0],
|
||||
.mem_pressure_limit = 5,
|
||||
.last_hit_mem_pressure_limit = 777,
|
||||
.mem_pressure_limit_hit_start = 777,
|
||||
.last_had_mem_reclaim = 888,
|
||||
.pgscan = 57 },
|
||||
{ .path = paths[1],
|
||||
.mem_pressure_limit = 6,
|
||||
.last_hit_mem_pressure_limit = 888,
|
||||
.mem_pressure_limit_hit_start = 888,
|
||||
.last_had_mem_reclaim = 888,
|
||||
.pgscan = 42 },
|
||||
};
|
||||
@ -218,14 +218,14 @@ static void test_oomd_update_cgroup_contexts_between_hashmaps(void) {
|
||||
assert_se(c_new = hashmap_get(h_new, "/0.slice"));
|
||||
assert_se(c_old->pgscan == c_new->last_pgscan);
|
||||
assert_se(c_old->mem_pressure_limit == c_new->mem_pressure_limit);
|
||||
assert_se(c_old->last_hit_mem_pressure_limit == c_new->last_hit_mem_pressure_limit);
|
||||
assert_se(c_old->mem_pressure_limit_hit_start == c_new->mem_pressure_limit_hit_start);
|
||||
assert_se(c_old->last_had_mem_reclaim == c_new->last_had_mem_reclaim);
|
||||
|
||||
assert_se(c_old = hashmap_get(h_old, "/1.slice"));
|
||||
assert_se(c_new = hashmap_get(h_new, "/1.slice"));
|
||||
assert_se(c_old->pgscan == c_new->last_pgscan);
|
||||
assert_se(c_old->mem_pressure_limit == c_new->mem_pressure_limit);
|
||||
assert_se(c_old->last_hit_mem_pressure_limit == c_new->last_hit_mem_pressure_limit);
|
||||
assert_se(c_old->mem_pressure_limit_hit_start == c_new->mem_pressure_limit_hit_start);
|
||||
assert_se(c_new->last_had_mem_reclaim > c_old->last_had_mem_reclaim);
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ static void test_oomd_pressure_above(void) {
|
||||
assert_se(oomd_pressure_above(h1, 0 /* duration */, &t1) == 1);
|
||||
assert_se(set_contains(t1, &ctx[0]) == true);
|
||||
assert_se(c = hashmap_get(h1, "/herp.slice"));
|
||||
assert_se(c->last_hit_mem_pressure_limit > 0);
|
||||
assert_se(c->mem_pressure_limit_hit_start > 0);
|
||||
|
||||
/* Low memory pressure */
|
||||
assert_se(h2 = hashmap_new(&string_hash_ops));
|
||||
@ -297,7 +297,7 @@ static void test_oomd_pressure_above(void) {
|
||||
assert_se(oomd_pressure_above(h2, 0 /* duration */, &t2) == 0);
|
||||
assert_se(t2 == NULL);
|
||||
assert_se(c = hashmap_get(h2, "/derp.slice"));
|
||||
assert_se(c->last_hit_mem_pressure_limit == 0);
|
||||
assert_se(c->mem_pressure_limit_hit_start == 0);
|
||||
|
||||
/* High memory pressure w/ multiple cgroups */
|
||||
assert_se(hashmap_put(h1, "/derp.slice", &ctx[1]) >= 0);
|
||||
@ -305,9 +305,9 @@ static void test_oomd_pressure_above(void) {
|
||||
assert_se(set_contains(t3, &ctx[0]) == true);
|
||||
assert_se(set_size(t3) == 1);
|
||||
assert_se(c = hashmap_get(h1, "/herp.slice"));
|
||||
assert_se(c->last_hit_mem_pressure_limit > 0);
|
||||
assert_se(c->mem_pressure_limit_hit_start > 0);
|
||||
assert_se(c = hashmap_get(h1, "/derp.slice"));
|
||||
assert_se(c->last_hit_mem_pressure_limit == 0);
|
||||
assert_se(c->mem_pressure_limit_hit_start == 0);
|
||||
}
|
||||
|
||||
static void test_oomd_swap_free_below(void) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user