Skip to content

Commit ee29a11

Browse files
pizhenweiintel-lab-lkp
authored andcommitted
virtio_balloon: introduce memory scan/reclaim info
Expose memory scan/reclaim information to the host side via virtio balloon device. Now we have a metric to analyze the memory performance: y: counter increases n: counter does not changes h: the rate of counter change is high l: the rate of counter change is low OOM: VIRTIO_BALLOON_S_OOM_KILL STALL: VIRTIO_BALLOON_S_ALLOC_STALL ASCAN: VIRTIO_BALLOON_S_SCAN_ASYNC DSCAN: VIRTIO_BALLOON_S_SCAN_DIRECT ARCLM: VIRTIO_BALLOON_S_RECLAIM_ASYNC DRCLM: VIRTIO_BALLOON_S_RECLAIM_DIRECT - OOM[y], STALL[*], ASCAN[*], DSCAN[*], ARCLM[*], DRCLM[*]: the guest runs under really critial memory pressure - OOM[n], STALL[h], ASCAN[*], DSCAN[l], ARCLM[*], DRCLM[l]: the memory allocation stalls due to cgroup, not the global memory pressure. - OOM[n], STALL[h], ASCAN[*], DSCAN[h], ARCLM[*], DRCLM[h]: the memory allocation stalls due to global memory pressure. The performance gets hurt a lot. A high ratio between DRCLM/DSCAN shows quite effective memory reclaiming. - OOM[n], STALL[h], ASCAN[*], DSCAN[h], ARCLM[*], DRCLM[l]: the memory allocation stalls due to global memory pressure. the ratio between DRCLM/DSCAN gets low, the guest OS is thrashing heavily, the serious case leads poor performance and difficult trouble shooting. Ex, sshd may block on memory allocation when accepting new connections, a user can't login a VM by ssh command. - OOM[n], STALL[n], ASCAN[h], DSCAN[n], ARCLM[l], DRCLM[n]: the low ratio between ARCLM/ASCAN shows that the guest tries to reclaim more memory, but it can't. Once more memory is required in future, it will struggle to reclaim memory. Signed-off-by: zhenwei pi <[email protected]>
1 parent 7ccb9ad commit ee29a11

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

drivers/virtio/virtio_balloon.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,15 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
372372
stall += events[ALLOCSTALL_MOVABLE];
373373
update_stat(vb, idx++, VIRTIO_BALLOON_S_ALLOC_STALL, stall);
374374

375+
update_stat(vb, idx++, VIRTIO_BALLOON_S_SCAN_ASYNC,
376+
pages_to_bytes(events[PGSCAN_KSWAPD]));
377+
update_stat(vb, idx++, VIRTIO_BALLOON_S_SCAN_DIRECT,
378+
pages_to_bytes(events[PGSCAN_DIRECT]));
379+
update_stat(vb, idx++, VIRTIO_BALLOON_S_RECLAIM_ASYNC,
380+
pages_to_bytes(events[PGSTEAL_KSWAPD]));
381+
update_stat(vb, idx++, VIRTIO_BALLOON_S_RECLAIM_DIRECT,
382+
pages_to_bytes(events[PGSTEAL_DIRECT]));
383+
375384
return idx;
376385
}
377386

include/uapi/linux/virtio_balloon.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ struct virtio_balloon_config {
7373
#define VIRTIO_BALLOON_S_HTLB_PGFAIL 9 /* Hugetlb page allocation failures */
7474
#define VIRTIO_BALLOON_S_OOM_KILL 10 /* OOM killer invocations */
7575
#define VIRTIO_BALLOON_S_ALLOC_STALL 11 /* Stall count of memory allocatoin */
76-
#define VIRTIO_BALLOON_S_NR 12
76+
#define VIRTIO_BALLOON_S_SCAN_ASYNC 12 /* Amount of memory scanned asynchronously */
77+
#define VIRTIO_BALLOON_S_SCAN_DIRECT 13 /* Amount of memory scanned directly */
78+
#define VIRTIO_BALLOON_S_RECLAIM_ASYNC 14 /* Amount of memory reclaimed asynchronously */
79+
#define VIRTIO_BALLOON_S_RECLAIM_DIRECT 15 /* Amount of memory reclaimed directly */
80+
#define VIRTIO_BALLOON_S_NR 16
7781

7882
#define VIRTIO_BALLOON_S_NAMES_WITH_PREFIX(VIRTIO_BALLOON_S_NAMES_prefix) { \
7983
VIRTIO_BALLOON_S_NAMES_prefix "swap-in", \
@@ -87,7 +91,11 @@ struct virtio_balloon_config {
8791
VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-allocations", \
8892
VIRTIO_BALLOON_S_NAMES_prefix "hugetlb-failures", \
8993
VIRTIO_BALLOON_S_NAMES_prefix "oom-kill", \
90-
VIRTIO_BALLOON_S_NAMES_prefix "alloc-stall" \
94+
VIRTIO_BALLOON_S_NAMES_prefix "alloc-stall", \
95+
VIRTIO_BALLOON_S_NAMES_prefix "scan-async", \
96+
VIRTIO_BALLOON_S_NAMES_prefix "scan-direct", \
97+
VIRTIO_BALLOON_S_NAMES_prefix "reclaim-async", \
98+
VIRTIO_BALLOON_S_NAMES_prefix "reclaim-direct" \
9199
}
92100

93101
#define VIRTIO_BALLOON_S_NAMES VIRTIO_BALLOON_S_NAMES_WITH_PREFIX("")

0 commit comments

Comments
 (0)