summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2024-10-09 10:24:10 +0200
committerGitHub <noreply@github.com>2024-10-09 10:24:10 +0200
commit6ce06e94b105a9afac069dea7dc79346aa1595e8 (patch)
tree916adc70e3502ade3b2e349b6b447e0e024cdefc
parentNEWS: announce the F20/F21/F22/F23 key mangling removal scheduled for v258 (diff)
parentoomd: separate entries with comma for readability (diff)
downloadsystemd-6ce06e94b105a9afac069dea7dc79346aa1595e8.tar.xz
systemd-6ce06e94b105a9afac069dea7dc79346aa1595e8.zip
Merge pull request #34671 from yuwata/memory
tree-wide: several memory accounting cleanups
-rw-r--r--src/core/service.c6
-rw-r--r--src/oom/oomd-manager.c12
-rw-r--r--src/oom/oomd-util.c6
-rw-r--r--src/systemctl/systemctl-show.c34
4 files changed, 32 insertions, 26 deletions
diff --git a/src/core/service.c b/src/core/service.c
index 7162016313..c008849b78 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -5309,7 +5309,11 @@ static int service_can_live_mount(const Unit *u, sd_bus_error *error) {
/* Ensure that the unit runs in a private mount namespace */
if (!exec_needs_mount_namespace(unit_get_exec_context(u), /* params= */ NULL, unit_get_exec_runtime(u))) {
- log_unit_debug(u, "Unit not running in private mount namespace, cannot live mount");
+
+ /* This is also called in property_get_can_live_mount(). Suppress the debugging log when called in it. */
+ if (error)
+ log_unit_debug(u, "Unit not running in private mount namespace, cannot live mount");
+
return sd_bus_error_setf(
error,
SD_BUS_ERROR_INVALID_ARGS,
diff --git a/src/oom/oomd-manager.c b/src/oom/oomd-manager.c
index a7b0717958..6ff4d98c32 100644
--- a/src/oom/oomd-manager.c
+++ b/src/oom/oomd-manager.c
@@ -340,17 +340,12 @@ static int acquire_managed_oom_connect(Manager *m) {
static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void *userdata) {
Manager *m = ASSERT_PTR(userdata);
- usec_t usec_now;
int r;
assert(s);
assert(!hashmap_isempty(m->monitored_swap_cgroup_contexts));
/* Reset timer */
- r = sd_event_now(sd_event_source_get_event(s), CLOCK_MONOTONIC, &usec_now);
- if (r < 0)
- return log_error_errno(r, "Failed to reset event timer: %m");
-
r = sd_event_source_set_time_relative(s, SWAP_INTERVAL_USEC);
if (r < 0)
return log_error_errno(r, "Failed to set relative time for timer: %m");
@@ -804,10 +799,17 @@ int manager_get_dump_string(Manager *m, char **ret) {
_cleanup_(memstream_done) MemStream ms = {};
OomdCGroupContext *c;
FILE *f;
+ int r;
assert(m);
assert(ret);
+ /* Always reread memory/swap info here. Otherwise it may be outdated if swap monitoring is off.
+ * Let's make sure to always report up-to-date data. */
+ r = oomd_system_context_acquire("/proc/meminfo", &m->system_context);
+ if (r < 0)
+ log_debug_errno(r, "Failed to acquire system context, ignoring: %m");
+
f = memstream_init(&ms);
if (!f)
return -ENOMEM;
diff --git a/src/oom/oomd-util.c b/src/oom/oomd-util.c
index 69d103e71f..7c08d6714f 100644
--- a/src/oom/oomd-util.c
+++ b/src/oom/oomd-util.c
@@ -607,7 +607,7 @@ void oomd_dump_memory_pressure_cgroup_context(const OomdCGroupContext *ctx, FILE
fprintf(f,
"%sPath: %s\n"
"%s\tMemory Pressure Limit: %lu.%02lu%%\n"
- "%s\tPressure: Avg10: %lu.%02lu Avg60: %lu.%02lu Avg300: %lu.%02lu Total: %s\n"
+ "%s\tPressure: Avg10: %lu.%02lu, Avg60: %lu.%02lu, Avg300: %lu.%02lu, Total: %s\n"
"%s\tCurrent Memory Usage: %s\n",
strempty(prefix), ctx->path,
strempty(prefix), LOADAVG_INT_SIDE(ctx->mem_pressure_limit), LOADAVG_DECIMAL_SIDE(ctx->mem_pressure_limit),
@@ -635,8 +635,8 @@ void oomd_dump_system_context(const OomdSystemContext *ctx, FILE *f, const char
assert(f);
fprintf(f,
- "%sMemory: Used: %s Total: %s\n"
- "%sSwap: Used: %s Total: %s\n",
+ "%sMemory: Used: %s, Total: %s\n"
+ "%sSwap: Used: %s, Total: %s\n",
strempty(prefix),
FORMAT_BYTES(ctx->mem_used),
FORMAT_BYTES(ctx->mem_total),
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index 6f3fd76622..335b365be2 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -758,68 +758,68 @@ static void print_status_info(
printf(" (");
if (i->memory_min > 0) {
printf("%smin: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_min));
- prefix = " ";
+ prefix = ", ";
}
if (i->memory_low > 0) {
printf("%slow: %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->memory_low));
- prefix = " ";
+ prefix = ", ";
}
if (i->startup_memory_low > 0) {
printf("%slow (startup): %s", prefix, FORMAT_BYTES_CGROUP_PROTECTION(i->startup_memory_low));
- prefix = " ";
+ prefix = ", ";
}
if (i->memory_high != CGROUP_LIMIT_MAX) {
printf("%shigh: %s", prefix, FORMAT_BYTES(i->memory_high));
- prefix = " ";
+ prefix = ", ";
}
if (i->startup_memory_high != CGROUP_LIMIT_MAX) {
printf("%shigh (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_high));
- prefix = " ";
+ prefix = ", ";
}
if (i->memory_max != CGROUP_LIMIT_MAX) {
printf("%smax: %s", prefix, FORMAT_BYTES(i->memory_max));
- prefix = " ";
+ prefix = ", ";
}
if (i->startup_memory_max != CGROUP_LIMIT_MAX) {
printf("%smax (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_max));
- prefix = " ";
+ prefix = ", ";
}
if (i->memory_swap_max != CGROUP_LIMIT_MAX) {
printf("%sswap max: %s", prefix, FORMAT_BYTES(i->memory_swap_max));
- prefix = " ";
+ prefix = ", ";
}
if (i->startup_memory_swap_max != CGROUP_LIMIT_MAX) {
printf("%sswap max (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_swap_max));
- prefix = " ";
+ prefix = ", ";
}
if (i->memory_zswap_max != CGROUP_LIMIT_MAX) {
printf("%szswap max: %s", prefix, FORMAT_BYTES(i->memory_zswap_max));
- prefix = " ";
+ prefix = ", ";
}
if (i->startup_memory_zswap_max != CGROUP_LIMIT_MAX) {
printf("%szswap max (startup): %s", prefix, FORMAT_BYTES(i->startup_memory_zswap_max));
- prefix = " ";
+ prefix = ", ";
}
if (i->memory_limit != CGROUP_LIMIT_MAX) {
printf("%slimit: %s", prefix, FORMAT_BYTES(i->memory_limit));
- prefix = " ";
+ prefix = ", ";
}
if (show_memory_available) {
printf("%savailable: %s", prefix, FORMAT_BYTES(i->memory_available));
- prefix = " ";
+ prefix = ", ";
}
if (show_memory_peak) {
printf("%speak: %s", prefix, FORMAT_BYTES(i->memory_peak));
- prefix = " ";
+ prefix = ", ";
}
if (show_memory_swap_peak) {
- printf("%sswap: %s swap peak: %s", prefix,
+ printf("%sswap: %s, swap peak: %s", prefix,
FORMAT_BYTES(i->memory_swap_current), FORMAT_BYTES(i->memory_swap_peak));
- prefix = " ";
+ prefix = ", ";
}
if (show_memory_zswap_current) {
printf("%szswap: %s", prefix, FORMAT_BYTES(i->memory_zswap_current));
- prefix = " ";
+ prefix = ", ";
}
printf(")");
}