diff options
author | Florian Schmaus <flo@geekplace.eu> | 2023-11-06 17:24:14 +0100 |
---|---|---|
committer | Florian Schmaus <flo@geekplace.eu> | 2023-11-06 18:08:33 +0100 |
commit | 0531bded79dcdde93f2b076f86c40d02b81a18b9 (patch) | |
tree | 06b4f1f0cfb73b1115cdd5131ae0d0f3b640eeb0 /src/core | |
parent | cgroup: add support for memory.peak (diff) | |
download | systemd-0531bded79dcdde93f2b076f86c40d02b81a18b9.tar.xz systemd-0531bded79dcdde93f2b076f86c40d02b81a18b9.zip |
core: include peak memory in unit_log_resources()
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/unit.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/unit.c b/src/core/unit.c index 02c5cbd102..d7e7da40c2 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -2326,6 +2326,7 @@ static int unit_log_resources(Unit *u) { size_t n_message_parts = 0, n_iovec = 0; char* message_parts[1 + 2 + 2 + 1], *t; nsec_t nsec = NSEC_INFINITY; + uint64_t memory_peak = UINT64_MAX; int r; const char* const ip_fields[_CGROUP_IP_ACCOUNTING_METRIC_MAX] = { [CGROUP_IP_INGRESS_BYTES] = "IP_METRIC_INGRESS_BYTES", @@ -2369,6 +2370,24 @@ static int unit_log_resources(Unit *u) { nsec > NOTICEWORTHY_CPU_NSEC); } + (void) unit_get_memory_peak(u, &memory_peak); + if (memory_peak != UINT64_MAX) { + /* Format peak memory for inclusion in the structured log message */ + if (asprintf(&t, "MEMORY_PEAK=%" PRIu64, memory_peak) < 0) { + r = log_oom(); + goto finish; + } + iovec[n_iovec++] = IOVEC_MAKE_STRING(t); + + /* Format peak memory for inclusion in the human language message string */ + t = strjoin(FORMAT_BYTES(memory_peak), " memory peak"); + if (!t) { + r = log_oom(); + goto finish; + } + message_parts[n_message_parts++] = t; + } + for (CGroupIOAccountingMetric k = 0; k < _CGROUP_IO_ACCOUNTING_METRIC_MAX; k++) { uint64_t value = UINT64_MAX; |