KSMTUNED(8)

πŸ“¦ version 4.20180327, in ubuntu stonking

πŸ’– KSMTUNED(8) πŸ’–

okay bestie, pull up a chair, because we're about to talk about ksmtuned β€” that's the ksmtuned</> command from the User Commands corner of the manual (section 8, she's got range). she's a shell script that babysits Kernel Samepage Merging for your qemu girlies and honestly? she's the moment. ✨


🌸 NAME 🌸

ksmtuned β€” dynamically tune Kernel Samepage Merging (KSM) for qemu workloads πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

ksmtuned

that's it. that's the whole thing. no flags, no arguments, she just goes. no cap.


✨ DESCRIPTION ✨

so ksmtuned is a background tuning daemon, and the vibe is: she's implemented as a shell script (yes, she's a script and she's THRIVING, don't be weird about it). her whole job is to periodically estimate memory pressure from running qemu processes and then adjust Linux KSM aggressiveness by writing to sysfs</> controls. lowkey a genius.

At startup, the daemon optionally sources /etc/ksmtuned.conf and computes:

  • Total RAM from /proc/meminfo. πŸ“Š
  • A memory threshold based on KSM_THRES_COEF and KSM_THRES_CONST.
  • A sleep interval for KSM scans derived from total memory and KSM_SLEEP_MSEC.

then, every KSM_MONITOR_INTERVAL seconds, she does the little routine:

  1. Sums RSS for running qemu processes.
  2. Checks available memory (MemFree + Buffers + Cached).
  3. Stops KSM when memory pressure is low.
  4. Otherwise starts KSM and updates pages_to_scan using boost/decay logic.

and here's the cute part β€” the daemon traps SIGUSR1 while running, which wakes the wait cycle so the next adjustment can happen promptly after VM start/stop events. it's giving "text me and I'll wake up immediately" energy. 🫢


πŸ’… OPTIONS πŸ’…

okay so real talk: ksmtuned has no command-line options. none. zero. she doesn't want them, she doesn't need them. πŸ™…β€β™€οΈ

Behavior is configured through environment/configuration variables instead β€” keep scrolling, that's the next section.


πŸŽ€ CONFIGURATION VARIABLES πŸŽ€

The following variables may be set in /etc/ksmtuned.conf:

  • KSM_MONITOR_INTERVAL β€” Seconds between tuning passes (default: 60).
  • KSM_NPAGES_BOOST β€” Increment applied to pages_to_scan when free memory is below threshold (default: 300).
  • KSM_NPAGES_DECAY β€” Adjustment applied when free memory is above threshold (default: -50).
  • KSM_NPAGES_MIN β€” Minimum pages_to_scan (default: 64).
  • KSM_NPAGES_MAX β€” Maximum pages_to_scan (default: 1250).
  • KSM_SLEEP_MSEC β€” Base sleep millisecs used to compute /sys/kernel/mm/ksm/sleep_millisecs (default: 10).
  • KSM_THRES_COEF β€” Percent of total memory used in threshold calculation (default: 20).
  • KSM_THRES_CONST β€” Minimum threshold in KiB (default: 2048).
  • PIDFILE β€” Path to write daemon PID (default: /var/run/ksmtune.pid).
  • DEBUG β€” If non-empty, enable debug logging.
  • LOGFILE β€” Optional log destination used when DEBUG is set.
bestie, notice how the numbers are exact. we do NOT freestyle the defaults. the defaults are sacred. πŸ‘‘

🌈 FILES 🌈

  • /etc/ksmtuned.conf β€” Optional runtime configuration.
  • /proc/meminfo β€” Source for total/free memory data.
  • /sys/kernel/mm/ksm/run β€” Enable/disable KSM.
  • /sys/kernel/mm/ksm/pages_to_scan β€” Tune KSM scan intensity.
  • /sys/kernel/mm/ksm/sleep_millisecs β€” Tune pause between KSM scans.
  • /var/run/ksmtune.pid β€” Default PID file for the spawned loop process.

⭐ SEE ALSO ⭐

ksmctl(1), systemd(1), proc(5), ksm(7)

go read those too, they're the friend group. the girlies. the whole squad. πŸ¦‹


and that's the whole page!! this was ksmtuned from KSMTUNED(8), User Commands, dated April 2026. she ate and left no crumbs, periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from