How do I pin a VM to a Numa Zone at the hypervisor?

I have a product that we are running on our VMs that are impacted when crossing NUMA zones. How can I force this via the api?

In Libvirt we do this locally:

  <numatune>
    <memory mode="strict" nodeset="1-4,^3"/>
    <memnode cellid="0" mode="strict" nodeset="1"/>
    <memnode cellid="2" mode="preferred" nodeset="2"/>
  </numatune>

and

<vcpu placement='static' cpuset="1-4,^3,6" current="1">2</vcpu>

1 Reply

It seems like you're referring to NUMA awareness and CPU pinning. To answer your initial question, it can't be done via the API. You also wouldn't be able to use libvert since Linodes do not support nested virtualization. However, you could use the NUMAPolicy and NUMAMask features in systemd.exec to perform CPU pinning.

The most helpful mode parameter to pass would likely be MPOL_LOCAL, since it specifies local allocation and memory would be preferentially allocated to the node that triggers allocation. You also wouldn't need to set up NUMAMask at that point. That said, you do have the option to use NUMAMask to control the node list to be applied if you choose a different parameter.

You can use the command numactl --hardware (along with other numactl flags) to get the information needed to configure these. For example, on my 2GB Linode, I get the following information:

numactl --hardware
available: 1 nodes (0)
node 0 cpus: 0
node 0 size: 2004 MB
node 0 free: 405 MB
node distances:
node   0
  0:  10

This tells me that there is one NUMA node with one CPU. Alternatively, on my 4GB Linode:

numactl --hardware
available: 1 nodes (0)
node 0 cpus: 0 1
node 0 size: 3955 MB
node 0 free: 223 MB
node distances:
node   0
  0:  10

I have one node with two CPUs. If I wanted to set the NUMAPolicy on my 4GB Linode to use only CPU 0, I would set MPOL_BIND and indicate 0 in my NUMAMask configuration.

CPU pinning is typically used for memory-intensive applications that may benefit from use of a Dedicated CPU Linode that doesn't share a processor with other Linodes, as opposed to declaring internal CPU cores for its processes.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct