Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

virtio_balloon: introduce oom-kill invocations

When the guest OS runs under critical memory pressure, the guest
starts to kill processes. A guest monitor agent may scan 'oom_kill'
from /proc/vmstat, and reports the OOM KILL event. However, the agent
may be killed and we will loss this critical event(and the later
events).

For now we can also grep for magic words in guest kernel log from host
side. Rather than this unstable way, virtio balloon reports OOM-KILL
invocations instead.

Acked-by: David Hildenbrand <david@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Message-Id: <20240423034109.1552866-3-pizhenwei@bytedance.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>

authored by

zhenwei pi and committed by
Michael S. Tsirkin
6cf1c97d e25fbcd9

+5 -2
+1
drivers/virtio/virtio_balloon.c
··· 363 363 pages_to_bytes(events[PSWPOUT])); 364 364 update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]); 365 365 update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]); 366 + update_stat(vb, idx++, VIRTIO_BALLOON_S_OOM_KILL, events[OOM_KILL]); 366 367 367 368 #ifdef CONFIG_HUGETLB_PAGE 368 369 update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
+4 -2
include/uapi/linux/virtio_balloon.h
··· 71 71 #define VIRTIO_BALLOON_S_CACHES 7 /* Disk caches */ 72 72 #define VIRTIO_BALLOON_S_HTLB_PGALLOC 8 /* Hugetlb page allocations */ 73 73 #define VIRTIO_BALLOON_S_HTLB_PGFAIL 9 /* Hugetlb page allocation failures */ 74 - #define VIRTIO_BALLOON_S_NR 10 74 + #define VIRTIO_BALLOON_S_OOM_KILL 10 /* OOM killer invocations */ 75 + #define VIRTIO_BALLOON_S_NR 11 75 76 76 77 #define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \ 77 78 VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \ ··· 84 83 VIRTIO_BALLOON_S_NAMES_prefix "available-memory", \ 85 84 VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \ 86 85 VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \ 87 - VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures" \ 86 + VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \ 87 + VIRTIO_BALLOON_S_NAMES_prefix "oom-kills" \ 88 88 } 89 89 90 90 #define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")