Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1136782

Summary: guest boots slowly when ksm service is running
Product: Red Hat Enterprise Linux 6 Reporter: Xu Han <xuhan>
Component: qemu-kvmAssignee: Luiz Capitulino <lcapitulino>
Status: CLOSED NOTABUG QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.6CC: aarcange, bsarathy, chayang, coli, drjones, juzhang, knoel, lcapitulino, mkenneth, qzhang, rbalakri, scui, shuang, virt-maint, xfu, xuhan, xutian, ypu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-31 13:14:46 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
strace log none

Description Xu Han 2014-09-03 09:59:39 UTC
Description of problem:
guest boots slowly when ksm service is running. it took more than 5 mins to get response from QMP port, while booting guest with '-m 800G'.

and the processes status are:
---------------------------------------------------------------------
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND            
  315 root      25   5     0    0    0 R 95.2  0.0   1:06.57 ksmd               
 3082 root      20   0 80.6g 151m 4828 D  4.3  0.1   0:00.28 qemu-kvm 

Version-Release number of selected component (if applicable):
qemu-kvm-rhev-0.12.1.2-2.443.el6.x86_64

How reproducible:
100%


Steps to Reproduce:
1. start ksm service and boot guest with following script.
#!/bin/bash

/usr/libexec/qemu-kvm \
    -M rhel6.6.0  \
    -nodefaults  \
    -chardev socket,id=qmp_id_qmpmonitor1,path=/tmp/monitor-ksm,server,nowait \
    -mon chardev=qmp_id_qmpmonitor1,mode=control  \
    -m 81920  \
    -smp 4,maxcpus=4,cores=4,threads=1,sockets=1  \
    -cpu 'Westmere' \
    -vnc :0 \
    -enable-kvm &
    
sleep 1
top -p `pgrep qemu-kvm`
time nc -U /tmp/monitor-ksm << EOF >/dev/null
{'execute': 'qmp_capabilities'}
{'execute': 'quit'}
EOF

2. stop ksm service and boot guest with above script again.


Actual results:
ksm is running:
-----------------
real	0m15.243s
user	0m0.527s
sys	0m0.322s

ksm is stoped:
----------------
real	0m0.144s
user	0m0.582s
sys	0m0.359s


Expected results:


Additional info:

Comment 1 Xu Han 2014-09-03 10:09:28 UTC
Created attachment 934029 [details]
strace log

sorry, the script in comment 0 should not have this line:
  top -p `pgrep qemu-kvm`

some of the brk() syscall took too much time
21:57:21.874232 brk(0x7ff3731ee000)     = 0x7ff3731ee000 <0.000033>
21:57:21.874556 brk(0x7ff373211000)     = 0x7ff373211000 <0.388917>  <--
21:57:22.263789 brk(0x7ff373234000)     = 0x7ff373234000 <0.000015>
21:57:22.264092 brk(0x7ff373257000)     = 0x7ff373257000 <0.000015>

Comment 3 Luiz Capitulino 2015-03-26 17:22:00 UTC
Do you have ksmtuned installed and running?

If you do, can you try the settings recommended in bug 541230 comment 11 ?

Comment 4 Luiz Capitulino 2015-03-26 17:25:53 UTC
As ksmd eating CPU usually turns out to be configuration problems, I'm treating this BZ as a low-priority one. In this case I'm moving it to 6.8, as we're past development deadline for 6.7.

Comment 5 Xu Han 2015-03-31 04:59:16 UTC
(In reply to Luiz Capitulino from comment #3)
> Do you have ksmtuned installed and running?

Seems, no.

Anyway, I checked the status of ksm and ksmtuned with a new installed host:
# chkconfig --list | grep ksm
ksm            	0:off	1:off	2:off	3:on	4:on	5:on	6:off
ksmtuned       	0:off	1:off	2:off	3:on	4:on	5:on	6:off
# service ksm status
ksm is not running
# service ksmtuned status
ksmtuned is stopped

So, started ksmtuned manually, then boot a guest with allocating 80G memory will get a regular duration(in this case ksm would not be triggered).
# sh ksm.sh 

real	0m0.122s
user	0m0.592s
sys	0m0.414s

Comment 6 Luiz Capitulino 2015-03-31 13:14:46 UTC
OK, using ksmtuned is necessary. Closing as NOTABUG as it fixes the problem.