OpenVZ Forum - RDF feed
type: channel
items: Making a VE use a particular cpu
items: Re: Making a VE use a particular cpu

Making a VE use a particular cpu
type: item
description: Hello everybody, is it possible to limit a VE to a particular cpu or set of cpus? I've a server with 2 Intel I7 quad-core cpus and i'd like to split the cores among the different VEs. thanks for your help
creator: arghbis
date: 2008-12-22T09:38:45-00:00

Re: Making a VE use a particular cpu
type: item
description: Hello, you cannot bind your VE to physical CPU but you can limit the number of CPUS inside VE and cpu time. (man vzctl (--cpus parameters and --cpulimit))
creator: maratrus
date: 2008-12-22T13:37:52-00:00

Re: Making a VE use a particular cpu
type: item
description: thanks for the answer. I already know the option --cpus, but it does not enforce the use of "separated" cpus. For instance, i have 2 VEs that run transcoding programs, each using 4 threads. To optimize the performances, i want these two VE to run on different cpus. Maybe the kernel already handle this or maybe my idea is stupid?
creator: arghbis
date: 2008-12-22T13:43:12-00:00

Re: Making a VE use a particular cpu
type: item
description: You can do that using cpusets from HN (incase cpusets actually work in openvz kernel) you can put a specific VE init process in it's own cpuset. You can use cpuset tool for easier administration of cpusets - http://developer.novell.com/wiki/index.php/Cpuset
creator: piavlo
date: 2008-12-22T23:12:05-00:00

Re: Making a VE use a particular cpu
type: item
description: I've just tried it and it works as should. This is on 8 cpus system: fire-ovz1 ~ # cset set --cpu=6 --set=blah cset: --> created cpuset "blah" fire-ovz1 ~ # cset proc --list blah cset: "blah" cpuset of: 6 cpu, with: 0 tasks running fire-ovz1 ~ # cset proc --set=blah --exec vzctl start 103 cset: 1 tasks match criteria cset: --> last message, executed args into cpuset "/blah", new pid is: 5842 Starting VE ... VE is mounted Setting CPU units: 100000 Configure meminfo: 2460180 Configure veth devices: veth103.0 VE start in progress... fire-ovz1 ~ # cset proc --list blah cset: "blah" cpuset of: 6 cpu, with: 8 tasks running USER PID PPID S TASK NAME -------- ----- ----- - --------- root 5855 1 S init [3] root 5936 5855 S /sbin/udevd --daemon root 6180 5855 S /sbin/rc default root 6190 5855 S /usr/sbin/syslog-ng root 6201 5855 S /usr/sbin/atd root 6204 6180 S /sbin/runscript /etc/init.d/net.eth0 start root 6205 6204 S /bin/sh /lib64/rc/sh/runscript.sh /etc/init.d/net.eth root 6264 6205 S dhcpcd -H -C resolv.conf -C ntp.conf -C yp.conf -G -h fire-ovz1 ~ #
creator: piavlo
date: 2008-12-23T00:13:05-00:00

Re: Making a VE use a particular cpu
type: item
description: Thanks a lot for the tips! i'll try it soon
creator: arghbis
date: 2008-12-23T09:29:32-00:00

Re: Making a VE use a particular cpu
type: item
description: Hello, as far as I understand (and please correct me if I'm wrong) cpuset changes task_struct->cpu_allowed field according to its rules. That's mean that we bind the task not to physical but virtual cpus (it is OpenVZ specific feature). Virtual CPUs are bound to physical CPUs but this connection is not permanent. So, your task could be bound to virtual CPU (vcpu) but actually run on different physical CPUs (pcpu). We can conduct the following experiment (on the test node!) Set appropriate sets with cset command as described in previous post. Run our VE and issue inside that VE the command e.g. # cat /dev/zero > /dev/null & then on the HN trigger several times: # echo "p" > /proc/sysrq-trigger and look in dmesg. There should be appear information concerning with the task running on that moment (physical and virtual CPUs numbers also should be shown). Our goal is catch "cat" process inside VE running on different physical CPUs.
creator: maratrus
date: 2008-12-23T14:48:07-00:00

Re: Making a VE use a particular cpu
type: item
description: maratrus wrote on Tue, 23 December 2008 16:48 Hello, as far as I understand (and please correct me if I'm wrong) cpuset changes task_struct->cpu_allowed field according to its rules. That's mean that we bind the task not to physical but virtual cpus (it is OpenVZ specific feature). Even if I do it in HN = VE0? If i have 8 pcpus does it means that there are also exactly 8 vcpus? Can you elaborate (or point me to documentstion) on why this is needed in openvz kernel. Since using cpu affinity in openvz kernels is also usefull feature, and I don't understand why this vcpu & pcpu thing needed in VE0. Quote: Virtual CPUs are bound to physical CPUs but this connection is not permanent. So, your task could be bound to virtual CPU (vcpu) but actually run on different physical CPUs (pcpu). You mean that the cpus i see inside HN , for example using htop are also virtual, so if i monitnor a specific process bound to specific cpu using htop, I won't notice if it migrates to other pcpu(unless if it migrates to other vcpu)? While on vanilla kernel i can see if the process migrates to other cpu. What about mpstat command, do i see vcpus with it or pcpus? Is there a cpu load monitoring command what will show me pcpus? From what it looks the sys entries at /sys/devices/system/cpu/cpu?/ show me pcpus since putting offline cpu with: echo 0 > /sys/devices/system/cpu/cpu3/online Removes cpu 3 from /proc/cpuinfo , which I hope shows me pcpus! Quote: We can conduct the following experiment (on the test node!) Set appropriate sets with cset command as described in previous post. Run our VE and issue inside that VE the command e.g. # cat /dev/zero > /dev/null & then on the HN trigger several times: # echo "p" > /proc/sysrq-trigger and look in dmesg. There should be appear information concerning with the task running on that moment (physical and virtual CPUs numbers also should be shown). Our goal is catch "cat" process inside VE running on different physical CPUs. Is cpu 6 below a vcpu or pc…
creator: piavlo
date: 2008-12-23T16:19:22-00:00

Re: Making a VE use a particular cpu
type: item
description: Hello, as far as I see your node is running 2.6.24 kernel. Sorry for misleading but my previous message concerns with 2.6.18 kernels. 2.6.24 kernel doesn't contain all this stuff. Quote: Even if I do it in HN = VE0? If i have 8 pcpus does it means that there are also exactly 8 vcpus? Can you elaborate (or point me to documentstion) on why this is needed in openvz kernel. Since using cpu affinity in openvz kernels is also usefull feature, and I don't understand why this vcpu & pcpu thing needed in VE0. The main idea of all this stuff is providing fair scheduler. If we are going to run a process of particular VE we cannot guarantee that there are processes of that VE in a given CPU runqueue.
creator: maratrus
date: 2008-12-24T13:17:59-00:00

Re: Making a VE use a particular cpu
type: item
description: maratrus wrote on Wed, 24 December 2008 15:17 Hello, as far as I see your node is running 2.6.24 kernel. Sorry for misleading but my previous message concerns with 2.6.18 kernels. 2.6.24 kernel doesn't contain all this stuff. So in 2.6.24 cpusets work as in vanilla kernel? Quote: The main idea of all this stuff is providing fair scheduler. If we are going to run a process of particular VE we cannot guarantee that there are processes of that VE in a given CPU runqueue. Frankly, I don't quite undertand: Is this Virtual CPU runqueue or Physical CPU runqueue? Scheduler can move proccess from one runqueue to another anyway, so how is it differenet in fairscheduling. And why this does not happen in 2.6.24 ovz? Is it since openvz fairscheduler based on new default linux CFS scheduler? If so then why this does not happen in CFS? And if i'm on 2.6.18 ovz and use mpstat to monitor cpu load which cpus do i see vcpus or pcpus? Thanks
creator: piavlo
date: 2008-12-24T14:29:08-00:00

Re: Making a VE use a particular cpu
type: item
description: Hello, we have to provide an ability to divide processes into several groups (e.g. if VE1 has only one process and VE2 has hundred of them the last hundred processes in VE2 should get the same CPU time (in sum) as a single one in VE1). O(1) scheduler make OpenVZ developers to create an additional layer to provide such functionality. Using CFS scheduler allowed to get rid of some things because it was possible to use hierarchy without building a massive additional layer. Quote: And if i'm on 2.6.18 ovz and use mpstat to monitor cpu load which cpus do i see vcpus or pcpus? Information from proc concerning cpus should be represent as vcpu.
creator: maratrus
date: 2008-12-24T17:36:56-00:00

Re: Making a VE use a particular cpu
type: item
description: maratrus wrote on Wed, 24 December 2008 19:36 Information from proc concerning cpus should be represent as vcpu. And information under /sys/devices/system/cpu/ is pcpu? Thanks for the explanations
creator: piavlo
date: 2008-12-24T18:31:06-00:00

Re: Making a VE use a particular cpu
type: item
description: Quote: And information under /sys/devices/system/cpu/ is pcpu? Information under that directory is about physical CPUs. BTW, that information is not available from inside the VE. VCPU layer is not CPU emulation layer - it is scheduler layer. Roughly speaking it is CPU mask virtualization.
creator: maratrus
date: 2008-12-25T07:28:44-00:00

Re: Making a VE use a particular cpu
type: item
description: maratrus wrote on Thu, 25 December 2008 09:28 Information under that directory is about physical CPUs. BTW, that information is not available from inside the VE. VCPU layer is not CPU emulation layer - it is scheduler layer. Roughly speaking it is CPU mask virtualization. Ok Thanks С Новым Годом
creator: piavlo
date: 2008-12-25T13:39:49-00:00

Re: Making a VE use a particular cpu
type: item
description: Quote: С Новым Годом Russian language! Спасибо большое, Вас также с Новым Годом и всего наилучшего!
creator: maratrus
date: 2008-12-26T07:43:46-00:00