Differences

This shows you the differences between two versions of the page.

Link to this comparison view

ep:labs:02:contents:tasks:ex3 [2021/10/11 18:39]
gheorghe.petre2608 [03. [30p] Kernel Samepage Merging]
ep:labs:02:contents:tasks:ex3 [2022/09/13 11:58] (current)
radu.mantu [03. [30p] Kernel Samepage Merging]
Line 7: Line 7:
 === [15p] 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 make config ​build file that is stored on your /boot partition. 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:
  
 <code bash> <code bash>
 +# 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
 +
 +# otherwise, you can find a gzip compressed copy in /proc
 +$ zcat /​proc/​config.gz | grep CONFIG_KSM
 CONFIG_KSM=y CONFIG_KSM=y
 </​code>​ </​code>​
Line 43: 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|}} | +
-</​spoiler>​+
  
-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 dropsFinally, as the process terminates, ​all memory is reclaimed by the kernel and the active ​memory ​returns ​to roughly the same value as before.+{{:​ep:​labs:​02:​contents:​tasks:​ksm_vmstat.png?​700|}} 
 +<​html><​center>​ 
 +<​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 ​startsAs <b>ksmd</b> begins ​scanning ​and merging ​pages, the free memory ​steadily increasesWhen the process ​eventually ​terminates, the amount of free memory ​reverts ​to its initial ​value. 
 +</​center></​html>​
  
 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.
ep/labs/02/contents/tasks/ex3.txt · Last modified: 2022/09/13 11:58 by radu.mantu
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0