[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c96e46b6-ef66-447d-8aaa-14e2f1d99d1b@redhat.com>
Date: Thu, 18 Apr 2024 13:49:46 +0200
From: David Hildenbrand <david@...hat.com>
To: zhenwei pi <pizhenwei@...edance.com>, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, virtualization@...ts.linux.dev
Cc: mst@...hat.com, jasowang@...hat.com, xuanzhuo@...ux.alibaba.com,
akpm@...ux-foundation.org
Subject: Re: [PATCH 2/3] virtio_balloon: introduce memory allocation stall
counter
On 18.04.24 08:26, zhenwei pi wrote:
> 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 <pizhenwei@...edance.com>
> ---
> drivers/virtio/virtio_balloon.c | 20 +++++++++++++++++++-
> include/uapi/linux/virtio_balloon.h | 6 ++++--
> 2 files changed, 23 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c
> index fd19934a847f..e88e6573afa5 100644
> --- a/drivers/virtio/virtio_balloon.c
> +++ b/drivers/virtio/virtio_balloon.c
> @@ -321,7 +321,7 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
> unsigned long events[NR_VM_EVENT_ITEMS];
> struct sysinfo i;
> unsigned int idx = 0;
> - long available;
> + long available, stall = 0;
> unsigned long caches;
>
> all_vm_events(events);
> @@ -338,6 +338,24 @@ static unsigned int update_balloon_stats(struct virtio_balloon *vb)
> update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]);
> update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]);
> update_stat(vb, idx++, VIRTIO_BALLOON_S_OOM_KILL, events[OOM_KILL]);
> +
> + /* sum all the stall events */
> +#ifdef CONFIG_ZONE_DMA
> + stall += events[ALLOCSTALL_DMA];
> +#endif
> +#ifdef CONFIG_ZONE_DMA32
> + stall += events[ALLOCSTALL_DMA32];
> +#endif
> +#ifdef CONFIG_HIGHMEM
> + stall += events[ALLOCSTALL_HIGH];
> +#endif
> +#ifdef CONFIG_ZONE_DEVICE
> + stall += events[ALLOCSTALL_DEVICE];
> +#endif
Naive me would think that ALLOCSTALL_DEVICE is always 0. :)
Likely we should just do:
for (zid = 0; zid < MAX_NR_ZONES; zid++)
stall += events[ALLOCSTALL_NORMAL - ZONE_NORMAL + zid];
(see isolate_lru_folios() -> __count_zid_vm_events(), where we realy on
the same ordering)
Apart form that, LGTM.
--
Cheers,
David / dhildenb
Powered by blists - more mailing lists