51 lines
2.0 KiB
Diff
51 lines
2.0 KiB
Diff
From 4bc77bad350313fa1137597d7e388660901e1a5a Mon Sep 17 00:00:00 2001
|
|
From: Florian Schmaus <flo@geekplace.eu>
|
|
Date: Mon, 6 Nov 2023 17:24:14 +0100
|
|
Subject: [PATCH] core: include peak memory in unit_log_resources()
|
|
|
|
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
|
|
(cherry picked from commit 0531bded79dcdde93f2b076f86c40d02b81a18b9)
|
|
|
|
Related: RHEL-95797
|
|
---
|
|
src/core/unit.c | 19 +++++++++++++++++++
|
|
1 file changed, 19 insertions(+)
|
|
|
|
diff --git a/src/core/unit.c b/src/core/unit.c
|
|
index 0f60fe061c..56580b1716 100644
|
|
--- a/src/core/unit.c
|
|
+++ b/src/core/unit.c
|
|
@@ -2238,6 +2238,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",
|
|
@@ -2281,6 +2282,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;
|
|
|