当前位置: 首页 > 工具软件 > KSM > 使用案例 >

KVM内存管理(三)—— KSM操作实践

拓拔俊艾
2023-12-01

 

关闭 ksm 和 ksmtuned 服务

[root@localhost ~]# /bin/systemctl stop ksmtuned
[root@localhost ~]# /bin/systemctl stop ksm
[root@localhost ~]# echo 0 > /sys/kernel/mm/ksm/run

启动虚拟机

[root@localhost ~]# /usr/libexec/qemu-kvm centos70-64.qcow2 -m 2G  -serial stdio
VNC server running on ::1:5900


CentOS Linux 7 (Core)
Kernel 3.10.0-1127.el7.x86_64 on an x86_64

localhost login: 

 开启ksm 和 ksmtuned 服务

可以看到ksm已经在进行工作。

[root@localhost ~]# /bin/systemctl start ksm
[root@localhost ~]# /bin/systemctl start ksmtuned
[root@localhost ~]# cat /sys/kernel/mm/ksm/run
1
[root@localhost ~]# 
[root@localhost ~]# cat /sys/kernel/mm/ksm/full_scans 
6816
[root@localhost ~]# cat /sys/kernel/mm/ksm/full_scans 
6818
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_shared 
9478
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_sharing 
31264
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_unshared 
64367
[root@localhost ~]# 
[root@localhost ~]# cat /sys/kernel/mm/ksm/full_scans 
6823
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_shared 
9478
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_sharing 
31442
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_unshared 
64036
[root@localhost ~]# cat /sys/kernel/mm/ksm/full_scans 
6834
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_shared 
9674
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_sharing 
31782
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_unshared 
63722
[root@localhost ~]# 

关闭虚拟机

可以看到ksm

[root@localhost ~]# 
[root@localhost ~]# cat /sys/kernel/mm/ksm/run
1
[root@localhost ~]# cat /sys/kernel/mm/ksm/full_scans 
6953
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_shared 
0
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_sharing 
0
[root@localhost ~]# cat /sys/kernel/mm/ksm/pages_unshared 
0
[root@localhost ~]# 
[root@localhost ~]# 
[root@localhost ~]# /bin/systemctl status ksmtuned
● ksmtuned.service - Kernel Samepage Merging (KSM) Tuning Daemon
   Loaded: loaded (/usr/lib/systemd/system/ksmtuned.service; enabled; vendor preset: enabled)
   Active: active (running) since 二 2021-04-13 22:07:53 EDT; 9min ago
  Process: 22515 ExecStart=/usr/sbin/ksmtuned (code=exited, status=0/SUCCESS)
 Main PID: 22521 (ksmtuned)
    Tasks: 2
   CGroup: /system.slice/ksmtuned.service
           ├─22521 /bin/bash /usr/sbin/ksmtuned
           └─23162 sleep 60

4月 13 22:07:53 localhost.localdomain systemd[1]: Starting Kernel Samepage Merging (KSM) Tuning Daemon...
4月 13 22:07:53 localhost.localdomain systemd[1]: Started Kernel Samepage Merging (KSM) Tuning Daemon.
[root@localhost ~]# /bin/systemctl status ksm
● ksm.service - Kernel Samepage Merging
   Loaded: loaded (/usr/lib/systemd/system/ksm.service; enabled; vendor preset: enabled)
   Active: active (exited) since 二 2021-04-13 22:07:47 EDT; 9min ago
  Process: 22392 ExecStop=/usr/libexec/ksmctl stop (code=exited, status=0/SUCCESS)
  Process: 22501 ExecStart=/usr/libexec/ksmctl start (code=exited, status=0/SUCCESS)
 Main PID: 22501 (code=exited, status=0/SUCCESS)
    Tasks: 0
   CGroup: /system.slice/ksm.service

4月 13 22:07:47 localhost.localdomain systemd[1]: Starting Kernel Samepage Merging...
4月 13 22:07:47 localhost.localdomain systemd[1]: Started Kernel Samepage Merging.
[root@localhost ~]# 

 

 类似资料: