Por que o Kernel Shared Memory é 0 no Ubuntu 12.04

2

Alguém pode me explicar por que o KSM não está funcionando significa que atualmente meu kernel não está utilizando o KSM para menos utilização de memória RAM.

 grep KSM /boot/config-3.2.0-23-generic 
 CONFIG_KSM=y

 cat /sys/kernel/mm/ksm/pages_shared 
 0
 cat /sys/kernel/mm/ksm/pages_sharing
 0
 cat /sys/kernel/mm/ksm/pages_unshared
 0

Kernel: 3.2.0-23-generic

Ubuntu 12.04 LTS Ambiente de trabalho de 64 bits

free -m

         total       used       free     shared    buffers     cached
Mem:      1964       1883         81          0         11        228
-/+ buffers/cache:       1644        320
Swap:         2008        485       1523

ipcs -m

 ------ Shared Memory Segments --------
 key        shmid      owner      perms      bytes      nattch     status      
0x00000000 0          myexperiments   600        393216     2          dest         
0x00000000 2490369    myexperiments   600        393216     2          dest         
0x00000000 98306      myexperiments   600        393216     2          dest         
0x00000000 2523139    myexperiments   600        393216     2          dest         
0x00000000 13008900   myexperiments   666        262080     1          dest         
0x00000000 1245189    myexperiments   666        4          2          dest         
0x00000000 1277958    myexperiments   666        4          1          dest         
0x00000000 6520839    myexperiments   600        393216     2          dest         
0x00000000 14811144   myexperiments   666        1277760    3          dest         
0x00000000 12648458   myexperiments   666        300000     1          dest         
0x00000000 8060939    myexperiments   666        300000     1          dest         
0x00000000 12943373   myexperiments   666        300000     2          dest         
0x00000000 12976142   myexperiments   666        262080     2          dest         
0x00000000 13271055   myexperiments   666        300000     2          dest
    
por Kevin Parker 17.01.2013 / 19:00

2 respostas

5

O KSMD não fará nada, a menos que o software aplicativo o convoque chamando madvise(MADV_MERGEABLE) . Muito provavelmente, você não está usando nenhum aplicativo que use os serviços do KSMD.

MADV_MERGEABLE (since Linux 2.6.32):

Enable Kernel Samepage Merging (KSM) for the pages in the range specified by addr and length. The kernel regularly scans those areas of user memory that have been marked as mergeable, looking for pages with identical content. These are replaced by a single write-protected page (which is automatically copied if a process later wants to update the content of the page). KSM only merges private anonymous pages (see mmap(2)).

The KSM feature is intended for applications that generate many instances of the same data (e.g., virtualization systems such as KVM). It can consume a lot of processing power; use with care. See the kernel source file Documentation/vm/ksm.txt for more details. The MADV_MERGEABLE and MADV_UNMERGEABLE operations are only available if the kernel was configured with CONFIG_KSM.

    
por 17.01.2013 / 20:03
0

Além do que David Schwartz disse sobre a necessidade de que os aplicativos definissem via madvise qual página poderia ser autorizada para mesclar , há mais uma configuração para ativar no Ubuntu para permitir que ksm faça seu trabalho:

sudo bash -c "echo 1 > /sys/kernel/mm/ksm/run"

Você pode verificar antes qual é o valor atual: cat /sys/kernel/mm/ksm/run nas minhas caixas Ubuntu 14.04.3 LTS e Ubuntu 15.04, seu valor é 0 . Aqui estão os valores diferentes de acordo com a documentação do kernel Kernel Samepage Merging :

How to use the Kernel Samepage Merging feature

run         - set 0 to stop ksmd from running but keep merged pages,
              set 1 to run ksmd e.g. "echo 1 > /sys/kernel/mm/ksm/run",
              set 2 to stop ksmd and unmerge all pages currently merged,
                    but leave mergeable areas registered for next run
              Default: 0 (must be changed to 1 to activate KSM,
                          except if CONFIG_SYSFS is disabled)
    
por 15.09.2015 / 09:07