Skip to content

Commit 7ccb9ad

Browse files
pizhenweiintel-lab-lkp
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. Signed-off-by: zhenwei pi <[email protected]>
1 parent 953406d commit 7ccb9ad

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

drivers/virtio/virtio_balloon.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
321321
unsigned long events[NR_VM_EVENT_ITEMS];
322322
struct sysinfo i;
323323
unsigned int idx = 0;
324-
long available;
324+
long available, stall = 0;
325325
unsigned long caches;
326326

327327
all_vm_events(events);
@@ -355,6 +355,23 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
355355
update_stat(vb, idx++, VIRTIO_BALLOON_S_OOM_KILL,
356356
events[OOM_KILL]);
357357

358+
/* sum all the stall event */
359+
#ifdef CONFIG_ZONE_DMA
360+
stall += events[ALLOCSTALL_DMA];
361+
#endif
362+
#ifdef CONFIG_ZONE_DMA32
363+
stall += events[ALLOCSTALL_DMA32];
364+
#endif
365+
#ifdef CONFIG_HIGHMEM
366+
stall += events[ALLOCSTALL_HIGH];
367+
#endif
368+
#ifdef CONFIG_ZONE_DEVICE
369+
stall += events[ALLOCSTALL_DEVICE];
370+
#endif
371+
stall += events[ALLOCSTALL_NORMAL];
372+
stall += events[ALLOCSTALL_MOVABLE];
373+
update_stat(vb, idx++, VIRTIO_BALLOON_S_ALLOC_STALL, stall);
374+
358375
return idx;
359376
}
360377

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-kill" \
89+
VIRTIO_BALLOON_S_NAMES_prefix "oom-kill", \
90+
VIRTIO_BALLOON_S_NAMES_prefix "alloc-stall" \
8991
}
9092

9193
#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")

0 commit comments

Comments
 (0)