---
title: 虚拟机绑核绑内存
description: "建议进行CPU 1:1绑定，并确保内存访问与绑定的CPU位于同一Die上，以达到最佳性能优化。"
url: https://www.hikunpeng.com/document/detail/zh/kunpengcpfs/systuningguide/systemtg/kunpengtypical_05_0004.html
sourcePath: /source/zh/kunpengcpfs/systuningguide/systemtg/kunpengtypical_05_0004.html
indexId: b20db22bef1f5f90d528ead43e2b14f6fa09ab8244fd02baca37787861cc73cc74
---
# 虚拟机绑核绑内存

建议进行CPU 1:1绑定，并确保内存访问与绑定的CPU位于同一Die上，以达到最佳性能优化。

1. 配置虚拟机绑核绑内存的详细操作步骤请参见《KVM虚拟机 调优指南》的CPU 1:1绑核，内存访问同一个Die(https://www.hikunpeng.com/document/detail/zh/kunpengcpfs/ecosystemEnable/QEMU-KVM/kunpengkvm_05_0009.html)章节。其中，虚拟机XML配置文件内容请参见本章节2。
2. 以下是一个进行CPU 1:1绑定的配置示例，供您在配置虚拟机的XML配置文件时参考。
  该示例是基于绑定4个vCPU和分配16GB内存的配置，请您根据实际需求对参数进行相应的调整，相关参数含义与使用场景请参考官方文档(https://libvirt.org/formatdomain.html#cpu-tuning)。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 <domain type = 'KVM'> ... <vcpu placement='static'>4</vcpu> <cputune> <vcpupin vcpu='0' cpuset='4'/> <vcpupin vcpu='1' cpuset='5'/> <vcpupin vcpu='2' cpuset='6'/> <vcpupin vcpu='3' cpuset='7'/> <emulatorpin cpuset='4-7'/> </cputune> ... <numatune> <memnode cellid='0' mode='strict' nodeset='0'/> </numatune> ... <cpu mode='host-passthrough' check='none'> <topology sockets='1' dies='1' clusters='1' cores='4' threads='1'/> <numa> <cell id='0' cpus='0-3' memory='16777216' unit='KiB'/> </numa> </cpu> ... <domain>
