Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace uksmd with built-in KSM support in systemd #64

Merged
merged 4 commits into from
Jun 18, 2024

Conversation

ventureoo
Copy link
Member

@ventureoo ventureoo commented Jun 13, 2024

systemd allows to use the same mechanism (kernel API) as uksmd using the MemoryKSM=yes service option. The idea is that we take the processes that are parent to most user processes like display managers (SDDM/GDM/LightMD/Ly/etc) or getty in case we don't have a display manager, and enable MemoryKSM=yes for them, so that all child processes inherit the PR_SET_MEMORY_MERGE attribute, which gives ksmd a hint that the pages of this process can be merged. Unlike uksmd it allows us to:

  1. Don't waste a lot of unnecessary CPU time for tracking down new processes.
  2. No need for additional kernel patches that will probably never be accepted in upstream.
  3. Avoid depending on extra services/packages which may be undesirable for some users (see Is uksmd still a necessary dependency for cachyos-settings? CachyOS-PKGBUILDS#203)
  4. For some users uksmd causes freezes (see occassionally freezes the whole system uksmd#5).

I also put a new ksmctl utility in these patches that allows you to disable ksmd right at runtime, in case debugging/regressions occur. Measurements and profits can be retrieved using topmem --sort ksm.

Marked as a draft until systemd 256 is available in the repo, as it contains an important fix related to these changes.

@ptr1337 ptr1337 marked this pull request as ready for review June 18, 2024 07:41
@ptr1337 ptr1337 merged commit d4db4b7 into master Jun 18, 2024
ventureoo added a commit to ventureoo/ARU that referenced this pull request Jun 22, 2024
There is an alternative way to get the same thing uksmd does using
systemd. This method will be described later. See:

CachyOS/CachyOS-Settings#64
@ptr1337 ptr1337 deleted the uksmd-replacement branch June 23, 2024 15:09
1Naim added a commit to 1Naim/CachyOS-Settings that referenced this pull request Jul 25, 2024
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