ultravioletrs / cocos

Cocos AI - Confidential Computing System for AI
https://ultraviolet.rs/cocos.html
Apache License 2.0
25 stars 9 forks source link

Feature: Bring back `tmpfs` and disable swap #263

Open drasko opened 1 month ago

drasko commented 1 month ago

Is your feature request related to a problem? Please describe.

No

Describe the feature you are requesting, as well as the possible use case(s) for it.

tmpfs is newer than ramfs, and can be set to take the whole RAM partition in fstab:

tmpfs   /mnt/tmpfs   tmpfs   defaults,size=100%   0  0

Additionally, Linux swap can be disabled, again in /etc/fstab:

/swapfile   none    swap    sw    0   0

Use something like this in Buildroot to allow that we use tmpfs, but that is capable taking whole available RAM, and with swap turned off (not to write anything to disk).

Indicate the importance of this feature to you.

Must-have

Anything else?

No response

drasko commented 1 month ago

Actually, swap should be disabled in Buildroot during the kernel compilation, I think with CONFIG_SWAP flag:

General Setup --->
  [ ] Support for paging of anonymous memory (swap)

Try if it possible to compile kernel with tmpfs, but with swap disabled already in Buildroot.

dborovcanin commented 2 days ago

@danko-miladinovic What's your opinion on this, is this needed?

danko-miladinovic commented 2 days ago

This is fine for us to have. Because we have an in RAM VM, we do not have a disk, so swap is not being used. Currently the VM uses ramfs which does not have memory restrictions that tmpfs has. We can go back to tmpfs which is a small change, but I am still looking into a way to resize tmpfs in order to remove the memory limit. There is a way by re-mounting tmpfs file systems but I want to check if there is a way using kernel command line or some other easier way.

drasko commented 2 days ago

@danko-miladinovic does not the config with fstab as I mentioned here resize the tmpfs to whole partition (100%)?

danko-miladinovic commented 2 days ago

Yes, but fstab only resizes one specific mount point based on the provided size parameter. It will not resize every file system that is tmpfs. If we want to resize every mount point that uses tmpfs then every one of them must be defined in fstab.

Sorry, this is actually fine, we can resize the / or the root file system to be 100% of RAM size. The rest (tmp, dev ...) can be default 50% of RAM size. Is this fine? Our EOS has tmp, dev and run as separate tmpfs filesystems, meaning they are not part of the root file system.

drasko commented 2 days ago

Cool, then we can try it and see how it works.