On Mon, Jun 27, 2022 at 07:19:09PM +0000, Alexander Atanasov wrote:
Allow the guest to know how much it is ballooned by the host.why do we need this in debugfs? Isn't this available in sysfs already?
It is useful when debugging out of memory conditions.
When host gets back memory from the guest it is accounted
as used memory in the guest but the guest have no way to know
how much it is actually ballooned.
No pretty printing and fixed as per coding style.
....
+static int virtio_balloon_debug_show(struct seq_file *f, void *offset)
+{
+ struct virtio_balloon *b = f->private;
+ u32 num_pages;
+ struct sysinfo i;
+
+ si_meminfo(&i);
+
+ seq_printf(f, "%-22s: %llx\n", "capabilities", b->vdev->features);
+ seq_printf(f, "%-22s: %d\n", "page_size", 4096);I suspect this function doesn't work properly when page size is not 4K.
+I don't really get the comment here.
+ virtio_cread_le(b->vdev, struct virtio_balloon_config, actual,
+ &num_pages);
+ /* Memory returned to host or amount we can inflate if possible */
+ seq_printf(f, "%-22s: %u\n", "ballooned_pages", num_pages);
+ /* Total Memory for the guest from host */Are you sure these are in units of 4Kbyte pages?
+ seq_printf(f, "%-22s: %lu\n", "total_pages", i.totalram);
+
+ /* Current memory for the guest */
+ seq_printf(f, "%-22s: %lu\n", "current_pages", i.totalram - num_pages);