summaryrefslogtreecommitdiffstats
path: root/src/oom
diff options
context:
space:
mode:
authorOleg Solovyov <mcpain@altlinux.org>2022-08-02 09:10:54 +0200
committerLennart Poettering <lennart@poettering.net>2022-08-11 09:53:55 +0200
commitd784a8d474a7e9c421a7b44530612e91c8764627 (patch)
treec5dcf6c9484f28c46b55b4b594f17e69f392230c /src/oom
parentcore/scope: Add oom-kill status for scope units (#24269) (diff)
downloadsystemd-d784a8d474a7e9c421a7b44530612e91c8764627.tar.xz
systemd-d784a8d474a7e9c421a7b44530612e91c8764627.zip
oomd: notify via dbus what have been killed
Diffstat (limited to 'src/oom')
-rw-r--r--src/oom/oomd-manager-bus.c5
-rw-r--r--src/oom/oomd-manager.c24
2 files changed, 27 insertions, 2 deletions
diff --git a/src/oom/oomd-manager-bus.c b/src/oom/oomd-manager-bus.c
index b41e366309..f4c196ee10 100644
--- a/src/oom/oomd-manager-bus.c
+++ b/src/oom/oomd-manager-bus.c
@@ -38,6 +38,11 @@ static const sd_bus_vtable manager_vtable[] = {
SD_BUS_PARAM(fd),
bus_method_dump_by_fd,
SD_BUS_VTABLE_UNPRIVILEGED),
+ SD_BUS_SIGNAL_WITH_NAMES("Killed",
+ "ss",
+ SD_BUS_PARAM(cgroup)
+ SD_BUS_PARAM(reason),
+ 0),
SD_BUS_VTABLE_END
};
diff --git a/src/oom/oomd-manager.c b/src/oom/oomd-manager.c
index e49eef6577..d9574fa97b 100644
--- a/src/oom/oomd-manager.c
+++ b/src/oom/oomd-manager.c
@@ -410,7 +410,7 @@ static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void
if (r < 0)
log_notice_errno(r, "Failed to kill any cgroup(s) based on swap: %m");
else {
- if (selected && r > 0)
+ if (selected && r > 0) {
log_notice("Killed %s due to memory used (%"PRIu64") / total (%"PRIu64") and "
"swap used (%"PRIu64") / total (%"PRIu64") being more than "
PERMYRIAD_AS_PERCENT_FORMAT_STR,
@@ -418,6 +418,16 @@ static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void
m->system_context.mem_used, m->system_context.mem_total,
m->system_context.swap_used, m->system_context.swap_total,
PERMYRIAD_AS_PERCENT_FORMAT_VAL(m->swap_used_limit_permyriad));
+
+ /* send dbus signal */
+ (void) sd_bus_emit_signal(m->bus,
+ "/org/freedesktop/oom1",
+ "org.freedesktop.oom1.Manager",
+ "Killed",
+ "ss",
+ selected,
+ "memory-used");
+ }
return 0;
}
}
@@ -524,13 +534,23 @@ static int monitor_memory_pressure_contexts_handler(sd_event_source *s, uint64_t
* it. In either case, go through the event loop again and select a new candidate if
* pressure is still high. */
m->mem_pressure_post_action_delay_start = usec_now;
- if (selected && r > 0)
+ if (selected && r > 0) {
log_notice("Killed %s due to memory pressure for %s being %lu.%02lu%% > %lu.%02lu%%"
" for > %s with reclaim activity",
selected, t->path,
LOADAVG_INT_SIDE(t->memory_pressure.avg10), LOADAVG_DECIMAL_SIDE(t->memory_pressure.avg10),
LOADAVG_INT_SIDE(t->mem_pressure_limit), LOADAVG_DECIMAL_SIDE(t->mem_pressure_limit),
FORMAT_TIMESPAN(m->default_mem_pressure_duration_usec, USEC_PER_SEC));
+
+ /* send dbus signal */
+ (void) sd_bus_emit_signal(m->bus,
+ "/org/freedesktop/oom1",
+ "org.freedesktop.oom1.Manager",
+ "Killed",
+ "ss",
+ selected,
+ "memory-pressure");
+ }
return 0;
}
}