1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 17:51:22 +03:00

core: move where we send unit change updates to oomd

Post-merge suggestion from #15206
This commit is contained in:
Anita Zhang 2020-10-19 01:44:17 -07:00
parent 8922eddad6
commit f561e8c659
3 changed files with 8 additions and 17 deletions

View File

@ -226,7 +226,7 @@ $1.IPIngressFilterPath, config_parse_ip_filter_bpf_progs,
$1.IPEgressFilterPath, config_parse_ip_filter_bpf_progs, 0, offsetof($1, cgroup_context.ip_filters_egress)
$1.ManagedOOMSwap, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_swap)
$1.ManagedOOMMemoryPressure, config_parse_managed_oom_mode, 0, offsetof($1, cgroup_context.moom_mem_pressure)
$1.ManagedOOMMemoryPressureLimitPercent, config_parse_managed_oom_mem_pressure_limit, 0, offsetof($1, cgroup_context)
$1.ManagedOOMMemoryPressureLimitPercent, config_parse_managed_oom_mem_pressure_limit, 0, offsetof($1, cgroup_context.moom_mem_pressure_limit)
$1.NetClass, config_parse_warn_compat, DISABLED_LEGACY, 0'
)m4_dnl
Unit.Description, config_parse_unit_string_printf, 0, offsetof(Unit, description)

View File

@ -3824,7 +3824,6 @@ int config_parse_managed_oom_mode(
const char *rvalue,
void *data,
void *userdata) {
Unit *u = userdata;
ManagedOOMMode *mode = data, m;
UnitType t;
@ -3836,7 +3835,7 @@ int config_parse_managed_oom_mode(
if (isempty(rvalue)) {
*mode = MANAGED_OOM_AUTO;
goto finish;
return 0;
}
m = managed_oom_mode_from_string(rvalue);
@ -3845,9 +3844,6 @@ int config_parse_managed_oom_mode(
return 0;
}
*mode = m;
finish:
(void) manager_varlink_send_managed_oom_update(u);
return 0;
}
@ -3862,8 +3858,7 @@ int config_parse_managed_oom_mem_pressure_limit(
const char *rvalue,
void *data,
void *userdata) {
Unit *u = userdata;
CGroupContext *c = data;
int *limit = data;
UnitType t;
int r;
@ -3874,8 +3869,8 @@ int config_parse_managed_oom_mem_pressure_limit(
return log_syntax(unit, LOG_WARNING, filename, line, 0, "%s= is not supported for this unit type, ignoring.", lvalue);
if (isempty(rvalue)) {
c->moom_mem_pressure_limit = 0;
goto finish;
*limit = 0;
return 0;
}
r = parse_percent(rvalue);
@ -3884,12 +3879,7 @@ int config_parse_managed_oom_mem_pressure_limit(
return 0;
}
c->moom_mem_pressure_limit = r;
finish:
/* Only update the limit if memory pressure detection is enabled because the information is irrelevant otherwise */
if (c->moom_mem_pressure == MANAGED_OOM_KILL)
(void) manager_varlink_send_managed_oom_update(u);
*limit = r;
return 0;
}

View File

@ -1684,6 +1684,7 @@ int unit_load(Unit *u) {
unit_add_to_dbus_queue(unit_follow_merge(u));
unit_add_to_gc_queue(u);
(void) manager_varlink_send_managed_oom_update(u);
return 0;
@ -2630,7 +2631,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, UnitNotifyFlag
* sets one of the ManagedOOM*= properties to "kill", then later removes it. systemd-oomd needs to
* know to stop monitoring when the unit changes from "kill" -> "auto" on daemon-reload, but we don't
* have the information on the property. Thus, indiscriminately send an update. */
if (UNIT_IS_INACTIVE_OR_FAILED(ns) || ns == UNIT_ACTIVE)
if (UNIT_IS_INACTIVE_OR_FAILED(ns) || UNIT_IS_ACTIVE_OR_RELOADING(ns))
(void) manager_varlink_send_managed_oom_update(u);
}