Thursday, September 23, 2010

How to pin CPU/Memory Affinity with CPUSET (Host Kernel 2.6.34)

Note: Below were tested on the host system of Fedora 13 with kernel 2.6.34.7-56.fc13.x86_64.

This post demonstrates how to use CPUSET to pin a process (including a KVM process) to a certain core and memory unit in a NUMA system. The goal is to let the CPU always access local memory thus save time in memory traffic. The memory performance is very different in fact (see the other post for memory/cpu benchmark).

1. Setup cpuset
mkdir /dev/cpuset
mount -t cgroup -ocpuset cpuset /dev/cpuset


2. Create a new cpuset
mkdir /dev/cpuset/mycpuset


3. Assign CPU to it
echo 1 > /dev/cpuset/mycpuset/cpuset.cpus


4. Assign Memory Node to it
echo 1 > /dev/cpuset/mycpuset/cpuset.mems


5. Assign the kvm tasks(processes)
First find out the process id of qemu-kvm.
cat /var/run/libvirt/qemu/fedora13.xml |grep pid
<domstatus state='running' pid='4305'>
<vcpu pid='4306'/>
Then add all the above process ids to the cpuset:
echo 4305 > /dev/cpuset/mycpuset/tasks
echo 4306 > /dev/cpuset/mycpuset/tasks

2 comments:

  1. Polo Ralph Lauren Corporation is a leader in the design,marketing and distribution of premium lifestyle products in four categories: apparel,home, accessories and fragrances. For more than 43 years, polo ralph lauren outlet reputation and distinctive image have been consistently developed across an expanding number of products, brands and internation markets

    Polo Ralph Lauren Corporation is a leader in the design,marketing and distribution of premium lifestyle products in four categories: apparel,home, accessories and fragrances. For more than 43 years, ralph lauren outlet reputation and distinctive image have been consistently developed across an expanding number of products, brands and internation markets

    Abercrombie ia an American based retailer and fashion brand for casual apparel for men, women and childre. It stocks personal care items, casual clothing,and discount deals.It operates on a multinational basis with more than 1000 stores as well as online shopping and enjoys a huge and loyal customer base which loves abercrombie coupons range and latest style.

    ReplyDelete
  2. Polo Ralph Lauren Corporation is a leader in the design,marketing and distribution of premium lifestyle products in four categories: apparel,home, accessories and fragrances. For more than 43 years, polo ralph lauren outlet reputation and distinctive image have been consistently developed across an expanding number of products, brands and internation markets

    Polo Ralph Lauren Corporation is a leader in the design,marketing and distribution of premium lifestyle products in four categories: apparel,home, accessories and fragrances. For more than 43 years, ralph lauren outlet reputation and distinctive image have been consistently developed across an expanding number of products, brands and internation markets

    Abercrombie ia an American based retailer and fashion brand for casual apparel for men, women and childre. It stocks personal care items, casual clothing,and discount deals.It operates on a multinational basis with more than 1000 stores as well as online shopping and enjoys a huge and loyal customer base which loves abercrombie coupons range and latest style.

    ReplyDelete