core/cgroup: two follow-ups for recent OOMKills PR (#39215)

Follow-ups for #38906.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-10-16 13:38:01 +02:00
committed by GitHub
2 changed files with 15 additions and 12 deletions

View File

@@ -2696,10 +2696,13 @@ node /org/freedesktop/systemd1/unit/avahi_2ddaemon_2eservice {
<varname>OOMPolicy=kill</varname> is enabled for the unit or not. If enabled, the property contains the
number of times the kernel OOM killer killed all the processes in the unit's cgroup and its
descendant cgroups. If disabled, the property contains the number of processes the kernel OOM killer
has killed in the unit's cgroup and its descendant cgroups.</para>
has killed in the unit's cgroup and its descendant cgroups. When the corresponding cgroups have not
been realized, it reports <constant>18446744073709551615</constant> (<constant>2^64 - 1</constant>).</para>
<para><varname>ManagedOOMKills</varname> contains the number of times <command>systemd-oomd</command>
killed all the processes in the unit's cgroup and its descendant cgroups.</para>
killed all the processes in the unit's cgroup and its descendant cgroups. When the corresponding
cgroups have not been realized yet, it reports <constant>18446744073709551615</constant>
(<constant>2^64 - 1</constant>).</para>
</refsect2>
<refsect2>

View File

@@ -3033,22 +3033,22 @@ int unit_check_oom(Unit *u) {
if (ctx->memory_oom_group) {
r = cg_get_keyed_attribute(
"memory",
crt->cgroup_path,
"memory.events.local",
STRV_MAKE("oom_group_kill"),
&oom_kill);
"memory",
crt->cgroup_path,
"memory.events.local",
STRV_MAKE("oom_group_kill"),
&oom_kill);
if (r < 0 && !IN_SET(r, -ENOENT, -ENXIO))
return log_unit_debug_errno(u, r, "Failed to read oom_group_kill field of memory.events.local cgroup attribute, ignoring: %m");
}
if (isempty(oom_kill)) {
r = cg_get_keyed_attribute(
"memory",
crt->cgroup_path,
"memory.events",
STRV_MAKE("oom_kill"),
&oom_kill);
"memory",
crt->cgroup_path,
"memory.events",
STRV_MAKE("oom_kill"),
&oom_kill);
if (r < 0 && !IN_SET(r, -ENOENT, -ENXIO))
return log_unit_debug_errno(u, r, "Failed to read oom_kill field of memory.events cgroup attribute: %m");
}