This shows you the differences between two versions of the page.
|
ep:labs:04:contents:tasks:ex3 [2025/02/11 23:36] cezar.craciunoiu |
ep:labs:04:contents:tasks:ex3 [2026/04/02 13:56] (current) radu.mantu |
||
|---|---|---|---|
| Line 3: | Line 3: | ||
| [[https://www.kernel.org/doc/html/latest/admin-guide/mm/ksm.html|KSM]] is a page de-duplication strategy introduced in kernel version 2.6.32. In case you are wondering, it's not the same thing as the file page cache. KSM was originally developed in tandem with KVM in order to detect data pages with //exactly// the same content and make their page table entries point to the same physical address (marked Copy-On-Write.) The end goal was to allow more VMs to run on the same host. Since each page must be scanned for identical content, this solution had no chance of scaling well with the available quantity of RAM. So, the developers compromised to scan only with the private anonymous pages that were marked as likely candidates via ''madvise(addr, length, MADV_MERGEABLE)''. | [[https://www.kernel.org/doc/html/latest/admin-guide/mm/ksm.html|KSM]] is a page de-duplication strategy introduced in kernel version 2.6.32. In case you are wondering, it's not the same thing as the file page cache. KSM was originally developed in tandem with KVM in order to detect data pages with //exactly// the same content and make their page table entries point to the same physical address (marked Copy-On-Write.) The end goal was to allow more VMs to run on the same host. Since each page must be scanned for identical content, this solution had no chance of scaling well with the available quantity of RAM. So, the developers compromised to scan only with the private anonymous pages that were marked as likely candidates via ''madvise(addr, length, MADV_MERGEABLE)''. | ||
| - | Download the {{:ep:labs:02:contents:tasks:ksm.zip|skeleton}} for this task. | + | === [10p] Task A - Check kernel support & enable ksmd === |
| - | + | ||
| - | === [15p] Task A - Check kernel support & enable ksmd === | + | |
| First things first, you need to verify that KSM was enabled during your kernel's compilation. For this, you need to check the Linux build configuration file. Hopefully, you should see something like this: | First things first, you need to verify that KSM was enabled during your kernel's compilation. For this, you need to check the Linux build configuration file. Hopefully, you should see something like this: | ||
| Line 29: | Line 27: | ||
| There are a few more files in the ksm/ directory. We will still use one or two later on. But for now, configuring the previous ones should be enough. Google the rest if you're interested. | There are a few more files in the ksm/ directory. We will still use one or two later on. But for now, configuring the previous ones should be enough. Google the rest if you're interested. | ||
| - | === [15p] Task B - Watch the magic happen === | + | === [10p] Task B - Watch the magic happen === |
| For this step it would be better to have a few terminals open. First, let's start a ''vmstat''. Keep your eyes on the active memory column when we run the sample program. | For this step it would be better to have a few terminals open. First, let's start a ''vmstat''. Keep your eyes on the active memory column when we run the sample program. | ||
| Line 59: | Line 57: | ||
| Include a screenshot with the same output as the one in the spoiler above. \\ | Include a screenshot with the same output as the one in the spoiler above. \\ | ||
| Edit the screenshot or note in writing at what point you started the application, where it reached max memory usage, the interval where KSM daemon was doing its job (in the 10s sleep interval) and where the process died. | Edit the screenshot or note in writing at what point you started the application, where it reached max memory usage, the interval where KSM daemon was doing its job (in the 10s sleep interval) and where the process died. | ||
| + | |||
| + | === [10p] Task C - Plot results === | ||
| + | Now that you’ve observed the effects of KSM using vmstat, it’s time to visualize them. Solve the TODOs from plot.py from skeleton to generate a real-time plot that shows free memory, used memory, and memory used as a buffer over time, based on the freemem column from the output of the vmstat command. | ||
| + | |||
| + | <note tip> | ||
| + | **Troubleshooting** | ||
| + | ----- | ||
| + | If you get something resembling ''Could not load the Qt platform plugin "xcb" in "" even though it was found.'' on either WSL or certain Linux environments (e.g., having Hyprland as a Wayland compositor), check out | ||
| + | [[https://blinq.hashnode.dev/fixing-xcb-load-failures-in-pyqt5-on-windows-subsystem-for-linux-wsl|this post]]. | ||
| + | </note> | ||