This shows you the differences between two versions of the page.
ep:labs:02:contents:tasks:ex3 [2022/06/13 17:27] radu.mantu |
ep:labs:02:contents:tasks:ex3 [2022/09/13 11:58] (current) radu.mantu [03. [30p] Kernel Samepage Merging] |
||
---|---|---|---|
Line 10: | Line 10: | ||
<code bash> | <code bash> | ||
- | # on Ubuntu you can usually find it on your /boot partition | + | # on Ubuntu you can usually find it in your /boot partition |
$ grep CONFIG_KSM /boot/config-$(uname -r) | $ grep CONFIG_KSM /boot/config-$(uname -r) | ||
CONFIG_KSM=y | CONFIG_KSM=y | ||
Line 48: | Line 48: | ||
Finally, look at the provided code, compile it, and launch the program. As an argument you will need to provide the number of pages that will be allocated and initialized with the same value. Note that not all pages will be de-duplicated instantly. So keep in mind your system's RAM limitations before deciding how much you can spare (1-2GB should be ok, right?) | Finally, look at the provided code, compile it, and launch the program. As an argument you will need to provide the number of pages that will be allocated and initialized with the same value. Note that not all pages will be de-duplicated instantly. So keep in mind your system's RAM limitations before deciding how much you can spare (1-2GB should be ok, right?) | ||
- | The result should look something like this: | + | The result should look something like **Figure 1**: |
- | <spoiler> | + | {{:ep:labs:02:contents:tasks:ksm_vmstat.png?700|}} |
- | | {{:ep:labs:02:contents:tasks:ksm_vmstat.png?700|}} | | + | <html><center> |
- | </spoiler> | + | <b>Figure 1:</b> <b>vmstat</b> output during the execution of our sample program (unit of measure: MB). The free memory steadily decreases from a baseline value of ~4.5GB to a minimum of ~2.5GB after the process starts. As <b>ksmd</b> begins scanning and merging pages, the free memory steadily increases. When the process eventually terminates, the amount of free memory reverts to its initial value. |
- | + | </center></html> | |
- | Here, we can see the active memory suddenly rising when we start the process. Over the next few seconds, as **ksmd** starts scanning pages, the active memory slowly drops. Finally, as the process terminates, all memory is reclaimed by the kernel and the active memory returns to roughly the same value as before. | + | |
If you ever want to make use of this in your own experiments, remember to adjust the configurations of **ksmd**. Waking too often or scanning to many pages at once could end up doing more harm than good. See what works for your particular system. | If you ever want to make use of this in your own experiments, remember to adjust the configurations of **ksmd**. Waking too often or scanning to many pages at once could end up doing more harm than good. See what works for your particular system. |