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 830766 - [libvirt] Can not pin vcpu to pcpu
Summary: [libvirt] Can not pin vcpu to pcpu
Keywords:
Status: CLOSED WORKSFORME
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: x86_64
OS: Linux
high
unspecified
Target Milestone: rc
: ---
Assignee: Libvirt Maintainers
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-06-11 11:26 UTC by Kiril Nesenko
Modified: 2012-06-16 01:28 UTC (History)
11 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-06-16 01:28:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
logs (375.61 KB, application/x-bzip)
2012-06-11 11:26 UTC, Kiril Nesenko
no flags Details

Description Kiril Nesenko 2012-06-11 11:26:13 UTC
Created attachment 590903 [details]
logs

Description of problem:
Trying to pin vcpu to pcpu and seems like the vm jumps between cpus.


From dumpxml:
<cputune>                                        
    <shares>1020</shares>                          
    <vcpupin vcpu='0' cpuset='1'/>                 
  </cputune>                   

[root@white-vdsg tmp]# ps -U qemu -o pid,psr,comm
  PID PSR COMMAND
 4040   0 qemu-kvm
[root@white-vdsg tmp]# ps -U qemu -o pid,psr,comm
  PID PSR COMMAND
 4040   2 qemu-kvm
[root@white-vdsg tmp]# ps -U qemu -o pid,psr,comm
  PID PSR COMMAND
 4040   1 qemu-kvm


Version-Release number of selected component (if applicable):
vdsm-4.9.6-16.0.el6.x86_64
libvirt-0.9.10-21.el6.x86_64

How reproducible:


Steps to Reproduce:
1. Create a vm and try to pin cpu from rhevm ui. Parameters: 0#1
2.
3.
  
Actual results:
seems like pin cpu option does not works

Expected results:
vm should be pinned to the specific cpu

Additional info:

Comment 2 Daniel Berrangé 2012-06-11 12:03:39 UTC
The QEMU process run for KVM is a multi-threaded process, which has one child thread per VCPU. The main thread leader handles the event loop. The XML you have provided *only* sets affinity for the VCPU threads. The main thread is left unpinned. In other words your test case is broken.

If you want to pin *all* threads, then use  <vcpu cpuset='1'>1</vcpu>.

Alternatively if you check to check just the vCPU pinning, then you need to look at the child threads of process 4040 (ie /proc/4040/task/NNNN)

Comment 3 Laszlo Hornyak 2012-06-14 12:56:04 UTC
Ok, we do not want to pin the quemu main process to CPU, but only a thread. Is there a way to find out whuch quemu process belongs to which VM?

Comment 4 Daniel Berrangé 2012-06-14 13:41:31 UTC
There is no supported API for obtaining that information, because it is not required in order to do CPU pinning with libvirt. You just use the libvirt APIs / virsh commands or XML to pin individual vCPUs.

If you just want this info, for the sake of QA testing of libvirt though, you can use the unsupported 'qemu-monitor-command' call to discover it, eg

# virsh qemu-monitor-command --hmp demovm 'info cpus' 
* CPU #0: pc=0x00000000000fefc6 (halted) thread_id=7394
  CPU #1: pc=0x00000000000ff0a2 (halted) thread_id=7398
  CPU #2: pc=0x00000000000ff0a2 (halted) thread_id=7403
  CPU #3: pc=0x00000000000ff0a2 (halted) thread_id=7412

The thread-id field is the process ID

Comment 5 Laszlo Hornyak 2012-06-15 11:34:38 UTC
Cool, thank you Daniel!

Comment 6 Laszlo Hornyak 2012-06-15 12:56:22 UTC
I checked the process over, Kiril please check your system:

- I created a Vm in oVirt with cpu pinning (0#0)
- in vdsm log, I found that the domain was created with         
        <cputune>
                <vcpupin cpuset="0" vcpu="0"/>
        </cputune>
- As Daniel recommended, I used `qemu-monitor-command --hmp vm1 'info cpus'` from virsh, returned
* CPU #0: pc=0x00000000000ff858 (halted) thread_id=9803
- I checked cpu-affinity with taskset
taskset -p 9803
pid 9803's current affinity mask: 1
(according to taskset's documentation, "0x00000001 is processor #0", this looks correct)

It looks all correct. Can we close this issue?

Comment 7 Dave Allan 2012-06-16 01:28:30 UTC
Kiril, this looks correct to me, so I'm closing.  Please don't hesitate to reopen if you believe it's not working correctly for you.


Note You need to log in before you can comment on or make changes to this bug.