[04:17] hello, I'm experiencing weird (wrong) ram usage on a fresh ubuntu 22.04 VM running on hyper-v with dynamic memory enabled [04:18] basically the displayed memory assigned/requested on the hypervisor is wildly different from the one displayed in linux shell (top) [07:53] arkanoid, hard to say where to file a bug report, hyperV or 22.04 ... [10:40] arkanoid: I'm not sure what "dynamic memory" means. Is that memory ballooning? AIUI, to do that you need an agent inside the VM to assist. Otherwise the VM will always use the maximum. Is that what you're trying to do - have I understood this correctly? If so, have you installed an agent inside the VM? === Thumpxr6 is now known as Thumpxr === Thumpxr5 is now known as Thumpxr [15:39] rbasak: thanks for the answer. I don't think I have. I checked the official docs and it is not requested. It should "just-work". I've checked the presence of lsmod | grep "hv" and they are there [15:42] arkanoid: OK. Sorry, this is beyond my immediately knowledge then. [15:42] *immediate [15:43] rbasak: have a look here https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/supported-ubuntu-virtual-machines-on-hyper-v [15:43] line "dynamic memory" [16:25] rbasak: I've just installed a brand new vanilla 22.04 VM. On first login, htop shows 222MB / 1.85GB (vm configured for dynamic allocation min 512MB max 2048MB). Hyper-V Management shows Assigned Memory 2048 MB, Memory Demand 839Mb [16:26] *839MB [16:27] Sorry, I don't have time to look any deeper into this. [16:27] Hopefully someone else here will be able to help [16:32] rbasak: thanks for the feedback [16:51] arkanoid: I don't know if I can really help much, but what would you expect to see? (i.e. which of those numbers aren't what you expect?) [16:54] well, memory requirements inside the VM is much much lower than what the hypervisor thinks. In my production ubuntu VM I have htop displaying 1.6GB used+buffer+cache, hyperv on same machine shows "memory demand: 4792MB" which is == the maximum allowed by dynamic memory policy. VM goes all you can eat according to the hypervisor [16:55] consuming 2.5x times memory on hypervisors is not quite good [16:58] Right, I think what's happening is that once a particular address has been requested by the VM, the hypervisor allocates it to the VM permanently (because it has no way of knowing if the VM is still using it or not). [17:00] So over time, the VM will end up requesting every address in its memory, and therefore end up forcing the HV to allocate the full dynamic memory space. [17:00] Odd_Bloke: it could be, the VM is using postgres interally, not much pressure, but not quite still neither [17:00] but isn't the dynamic memory + hv_* mods + guest stuff all made to limit this? [17:01] I mean, is the dynamic memory only meant to go up and never down? dealloc is not handled? [17:01] I don't really know how it works for Hyper-V specifically, I'm afraid, but I believe this is the function that the agent r'basak described fulfils: it observes the VM's state and communicates to the HV which blocks can be deallocated. [17:02] do know where I can read about this agent? [17:03] I believe it would need to be something Hyper-V specific so I don't know where to direct you, I'm afraid. [17:04] Odd_Bloke: thanks for the feedback [17:24] is this not handled by the hv_balloon kernel module? [17:27] but then it seems you'd also need to enable "Dynamic Memory" in the Hyper-V settings for the VM [17:33] minimal: done both since step 1 [17:34] issue is vm goes all-you-can-eat immediately [17:42] arkanoid: I have only theoretical knowledge of VM balloon mechanism but what I understood is that the VM starts with the full amount and it's only when the host goes through memory pressure that it asks the VM if it's OK to inflate the balloon (which is AFAIK, just a kernel module/driver, no agent involved) and if the guest's driver says yes, I can give you back this and this pages, then the [17:42] host get them back. The "returned" pages might not be as much as the host demanded for if the guest is unable to free more pages [17:45] the hv_balloon module does appear to provide a "pages_ballooned" value inside debugfs to indicate the number of "pages we have given back to host" [17:48] minimal: if it's working surely it's not working well. 2.5x memory consumption is a lot [17:49] I'm trying right now with linux-azure kernel/metapackage [18:22] arkanoid: Is your host under memory pressure? If not, then it sounds like you shouldn't expect any pages to be returned to the host, so the 2.5x memory consumption would be expected. [20:00] Odd_Bloke: how do I know? Htop seems locked at 1.6GB usage+cache [20:01] Linux doesn't show any pressure problem, it shows 2.4GB free [20:05] now the numbers are slightly different, but here's the copypaste from htop header: MiB Mem : 3905.1 total, 1092.1 free, 1638.3 used, 1174.7 buff/cache [20:06] free -h output: https://termbin.com/q3f0 [20:07] hyper-v "Memory demand" is 4792MB [20:08] If I understood sdeziel correctly, then I don't think you'll see any change in the memory assigned to the guest unless the _host_ experiences memory pressure (and so asks hv_balloon in the guest to give it some pages back). [20:13] I've been using Ubuntu server 20 ISO and installing nvidia drivers on it - all smooth. [20:13] Lately I started using ubuntu server 20 cloudimg and it just doesn't work, gpu are not detected properly [20:13] is there some known large differences between the two installation types or is it my skill issue? [20:30] How are you installing the drivers? [20:33] Installing in both servers in a similar way, using cuda runfile and following the docs [20:37] Does `uname -r` match between the two? [20:38] checking [20:43] exact same, both 5.15.0-94-generic [20:45] Is the `linux-image-generic` package installed on the cloud image server? [20:46] no, only linux-image-generic-hwe-20.04 [20:50] Aha, right, on focal. That was my one idea, I'm afraid, I'm not sure what's going on. [20:51] thanks for the attempt!