2

Running a 4.19 linux kernel + couple of patches RT oriented + occasionally running a couple of processes SCHED_RR (for "pro"-audio purposes)

CONFIG_KSM set in the kernel and ksmd running, I usually keep /sys/kernel/mm/ksm/run = 0 except when only running standard desktop applications (KDE / KMAIL / Chromium / LibreOffice / VLC + a Mariadb server with max 2 clients of a tiny database)

In this latter case, I turn /sys/kernel/mm/ksm/run = 1 but, at the end of the day, all the witnesses of some useful activity supposed to be reported in the /sys/kernel/mm/ksm files desperately show : 0

1/ Am I missing something vs none of the applications I run actually madvise MADV_MERGEABLE ?

2/ Are there common desktop applications actually madvising MADV_MERGEABLE ? I thought my sql server would be one of those but... apparently... ???

3/ In the (un?)fortunate case KSM would appear of absolutely no use to me, I would like to get rid of the useless ksmd daemon but... running a non-systemd system (openrc) I fail to understand what commands its launch, I mean which rc service launches it if not launched by the kernel itself when CONFIG_KSM=[y].

2
  1. I suspect the latter; a code search doesn’t find many uses, outside hypervisors and Chromium on Android.

  2. Not that I’m aware of. (How many non-VM-related applications would be expected to routinely have large amounts of memory with the same contents, other than their binary code which is already shared?)

  3. ksmd is a kernel thread. Writing 0 to /sys/kernel/mm/ksm/run should disable it if it’s running.

5
  • 1/ Many thanks for the link to codesearch.debian I did not know and appears being of considerable value to me. I build all my applications from source but keep these sources compressed in so many different archive formats that grepping globally is just a pain in the ass. – MC68020 Aug 30 '20 at 13:42
  • 2/ You are actually correct. I'm left surprised for what concerns mariadb. I would have assumed that databases systems are typically of those applications with significant amount of duplicated data. But... once again... you are correct. – MC68020 Aug 30 '20 at 13:49
  • 3/ (On my system), Contrarily to the khugepaged dameon which automatically terminates and exit following cat never > /sys/kernel/mm/transparent_hugepage/enabled, ksmd does not seem terminating when writing 0 to /sys/kernel/mm/ksm/run. Anyway, I'll rebuild my kernel CONFIG_KSM=[n] and check if this is the trigger of kernel decision to launch ksmd or not. – MC68020 Aug 30 '20 at 13:57
  • Many thanks for having spent some time on my problem. – MC68020 Aug 30 '20 at 13:57
  • 1
    You’re very welcome! Regarding databases, it certainly seems useful on the face of it, but bear in mind that KSM does page de-duplication, so the duplicate data has to represent full pages (which isn’t all that likely with databases). KSM works very well with VMs since they have large amounts of identical pages (running the same operating systems etc.), but there aren’t all that many other workloads that benefit from page de-duplication. I haven’t looked into point 3 in detail, perhaps it wasn’t deemed useful to completely disable ksmd (it should however be quiescent). – Stephen Kitt Aug 30 '20 at 15:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.