Skip to content

Commit c5b70a2

Browse files
pizhenweimstsirkin
authored andcommitted
virtio_balloon: introduce memory allocation stall counter
Memory allocation stall counter represents the performance/latency of memory allocation, expose this counter to the host side by virtio balloon device via out-of-bound way. Acked-by: David Hildenbrand <david@redhat.com> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com> Message-Id: <20240423034109.1552866-4-pizhenwei@bytedance.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 6cf1c97 commit c5b70a2

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

drivers/virtio/virtio_balloon.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,8 @@ static inline unsigned int update_balloon_vm_stats(struct virtio_balloon *vb)
355355
{
356356
unsigned long events[NR_VM_EVENT_ITEMS];
357357
unsigned int idx = 0;
358+
unsigned int zid;
359+
unsigned long stall = 0;
358360

359361
all_vm_events(events);
360362
update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN,
@@ -365,6 +367,12 @@ static inline unsigned int update_balloon_vm_stats(struct virtio_balloon *vb)
365367
update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
366368
update_stat(vb, idx++, VIRTIO_BALLOON_S_OOM_KILL, events[OOM_KILL]);
367369

370+
/* sum all the stall events */
371+
for (zid = 0; zid < MAX_NR_ZONES; zid++)
372+
stall += events[ALLOCSTALL_NORMAL - ZONE_NORMAL + zid];
373+
374+
update_stat(vb, idx++, VIRTIO_BALLOON_S_ALLOC_STALL, stall);
375+
368376
#ifdef CONFIG_HUGETLB_PAGE
369377
update_stat(vb, idx++, VIRTIO_BALLOON_S_HTLB_PGALLOC,
370378
events[HTLB_BUDDY_PGALLOC]);

include/uapi/linux/virtio_balloon.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ struct virtio_balloon_config {
7272
#define VIRTIO_BALLOON_S_HTLB_PGALLOC 8 /* Hugetlb page allocations */
7373
#define VIRTIO_BALLOON_S_HTLB_PGFAIL 9 /* Hugetlb page allocation failures */
7474
#define VIRTIO_BALLOON_S_OOM_KILL 10 /* OOM killer invocations */
75-
#define VIRTIO_BALLOON_S_NR 11
75+
#define VIRTIO_BALLOON_S_ALLOC_STALL 11 /* Stall count of memory allocatoin */
76+
#define VIRTIO_BALLOON_S_NR 12
7677

7778
#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
7879
VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
@@ -85,7 +86,8 @@ struct virtio_balloon_config {
8586
VIRTIO_BALLOON_S_NAMES_prefix "disk-caches", \
8687
VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
8788
VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \
88-
VIRTIO_BALLOON_S_NAMES_prefix "oom-kills" \
89+
VIRTIO_BALLOON_S_NAMES_prefix "oom-kills", \
90+
VIRTIO_BALLOON_S_NAMES_prefix "alloc-stalls" \
8991
}
9092

9193
#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")

0 commit comments

Comments
 (0)