On Wed, 19 Oct 2022 at 12:57, Alexander Atanasov <
[email protected]> wrote:
> Currently balloon drivers (Virtio,XEN, HyperV, VMWare, ...)
> inflate and deflate the guest memory size but there is no
> way to know how much the memory size is changed by them.
>
> Make it possible for the drivers to report the values to mm core.
>
> Display reported InflatedTotal and InflatedFree in /proc/meminfo
> and print these values on OOM and sysrq from show_mem().
>
> The two values are the result of the two modes the drivers work
> with using adjust_managed_page_count or without.
>
> In earlier versions, there was a notifier for these changes
> but after discussion - it is better to implement it in separate
> patch series. Since it came out as larger work than initially expected.
>
> Amount of inflated memory can be used:
> - totalram_pages() users working with drivers not using
> adjust_managed_page_count
> - si_meminfo(..) users can improve calculations
> - by userspace software that monitors memory pressure
>
Sorry, I see no reason for that series.
Balloon inflation adjusts totalram_pages. That's enough.
There is no reason to know the amount of non-existent ballooned memory
inside.
Management software which works outside should care about that.
For debugging you could get current balloon size from /proc/vmstat
(balloon_inflate - balloon_deflate).
Also (I guess) /proc/kpageflags has a bit for that.
Anyway it's easy to monitor balloon inflation by seeing changes of total
memory size.
>
> Alexander Atanasov (8):
> mm: Make a place for a common balloon code
> mm: Enable balloon drivers to report inflated memory
> mm: Display inflated memory to users
> mm: Display inflated memory in logs
> drivers: virtio: balloon - report inflated memory
> drivers: vmware: balloon - report inflated memory
> drivers: hyperv: balloon - report inflated memory
> documentation: create a document about how balloon drivers operate
>
> Documentation/filesystems/proc.rst | 6 +
> Documentation/mm/balloon.rst | 138 ++++++++++++++++++
> MAINTAINERS | 4 +-
> arch/powerpc/platforms/pseries/cmm.c | 2 +-
> drivers/hv/hv_balloon.c | 12 ++
> drivers/misc/vmw_balloon.c | 3 +-
> drivers/virtio/virtio_balloon.c | 7 +-
> fs/proc/meminfo.c | 10 ++
> .../linux/{balloon_compaction.h => balloon.h} | 18 ++-
> lib/show_mem.c | 8 +
> mm/Makefile | 2 +-
> mm/{balloon_compaction.c => balloon.c} | 19 ++-
> mm/migrate.c | 1 -
> mm/vmscan.c | 1 -
> 14 files changed, 213 insertions(+), 18 deletions(-)
> create mode 100644 Documentation/mm/balloon.rst
> rename include/linux/{balloon_compaction.h => balloon.h} (91%)
> rename mm/{balloon_compaction.c => balloon.c} (94%)
>
> v4->v5:
> - removed notifier
> - added documentation
> - vmware update after op is done , outside of the mutex
> v3->v4:
> - add support in hyperV and vmware balloon drivers
> - display balloon memory in show_mem so it is logged on OOM and on sysrq
> v2->v3:
> - added missed EXPORT_SYMBOLS
> Reported-by: kernel test robot <[email protected]>
> - instead of balloon_common.h just use balloon.h (yes, naming is hard)
> - cleaned up balloon.h - remove from files that do not use it and
> remove externs from function declarations
> v1->v2:
> - reworked from simple /proc/meminfo addition
>
> Cc: Michael S. Tsirkin <[email protected]>
> Cc: David Hildenbrand <[email protected]>
> Cc: Wei Liu <[email protected]>
> Cc: Nadav Amit <[email protected]>
> Cc: [email protected]
> Cc: Jason Wang <[email protected]>
> Cc: [email protected]
> Cc: "K. Y. Srinivasan" <[email protected]>
> Cc: Haiyang Zhang <[email protected]>
> Cc: Stephen Hemminger <[email protected]>
> Cc: Dexuan Cui <[email protected]>
> Cc: [email protected]
> Cc: Juergen Gross <[email protected]>
> Cc: Stefano Stabellini <[email protected]>
> Cc: Oleksandr Tyshchenko <[email protected]>
> Cc: [email protected]
>
> base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
> --
> 2.31.1
>
>