Re: [PATCH v1 2/2] Drivers: virtio: balloon: Report inflated memory

From: Alexander Atanasov
Date: Tue Aug 16 2022 - 05:31:12 EST


On 15.08.22 19:05, Nadav Amit wrote:
On Aug 15, 2022, at 5:52 AM, Alexander Atanasov <alexander.atanasov@xxxxxxxxxxxxx> wrote:

If it is going to be a place for generic logic may be it should be
renamed to balloon_common.[ch] ?

as possible. I made the effort to reuse this infrastructure (which is now
used by both VMware and virtio), and would prefer to share as much code as
possible.

For instance, I would appreciate if the update upon inflate would go into
balloon_page_list_enqueue() and balloon_page_enqueue(). VMware's 2MB pages
logic is not shared, so it would require a change that is specific for
VMware code.

I looked at the code and i do not see how i can reuse it since
BALLOON_COMPACTION can be disabled and as you say even for VMWare it
would require updates on other places. Looks like if i do so i would
have to handle update from each driver for both cases. I think it is
better to clearly mark the spots when drivers do their internal
recalculations and report to the core. I see only VMWare is using
balloon_page_list_enqueue , virtio balloon is using only migration and
i don't see how to hook it there - i haven't checked the rest of the
balloons but i guess it would be similiar . I agree it is a good to have
a common place for such logic but it might be better of for a separate
work in the future.

Fine. I would live with whatever you do and if needed change it later.


- balloon_page_list_enqueue and balloon_page_enqueue are called under locks.
- they work page by page
- different page sizes different hypervisors
- pages to bytes conversion again different page sizes

I will put the new code in balloon_common but i can not reuse what you propose for the reasons above.

--
Regards,
Alexander Atanasov