Skip to content

Conversation

@slp
Copy link
Collaborator

@slp slp commented Nov 5, 2024

By default, HK sets the heap size to be half the size of the *guest*
memory. Since commit 167744dc it's also possible to override the heap
size by setting the HK_SYSMEM environment variable.

Previously, the vram command line option was acting on the virtio-gpu
SHM window. This didn't help in most cases because userspace doesn't
really care nor is aware of it.

Here, we set the SHM window of virtio-gpu to always be as large as the
host's RAM, not because we expect VRAM to consume 100% of the RAM (which
is obviously impossible) but to account for region fragmentation. Then,
we use HK_SYSMEM to tell userspace the desired heap size (the closest
thing to VRAM we can aim for), which will be set to either the value
passed by the user throught the "vram" argument or half the size of the
*host* RAM.

slp added 2 commits November 5, 2024 17:35
Move prepare_env_vars up in the main function, since in the next commit
we're going to need the vector to be available earlier.

Signed-off-by: Sergio Lopez <slp@redhat.com>
By default, HK sets the heap size to be half the size of the *guest*
memory. Since commit 167744dc it's also possible to override the heap
size by setting the HK_SYSMEM environment variable.

Previously, the vram command line option was acting on the virtio-gpu
SHM window. This didn't help in most cases because userspace doesn't
really care nor is aware of it.

Here, we set the SHM window of virtio-gpu to always be as large as the
host's RAM, not because we expect VRAM to consume 100% of the RAM (which
is obviously impossible) but to account for region fragmentation. Then,
we use HK_SYSMEM to tell userspace the desired heap size (the closest
thing to VRAM we can aim for), which will be set to either the value
passed by the user throught the "vram" argument or half the size of the
*host* RAM.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Copy link
Member

@alyssarosenzweig alyssarosenzweig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the HK backdoor but until we have better kernel level stuff this seems reasonable +1

@slp slp merged commit 7720e0f into AsahiLinux:main Nov 6, 2024
2 checks passed
@slp slp deleted the better-vram branch November 6, 2024 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants