A.13. VDSM フックの例
例A.5 NUMA ノードのチューニング
このフックスクリプトは、numaset カスタムプロパティーに基づいた NUMA ホスト上におけるメモリー割り当ての調整を可能にします。カスタムプロパティーが設定されていない場合には、何も起こりません。
numaset=^(interleave|strict|preferred):[\^]?\d+(-\d+)?(,[\^]?\d+(-\d+)?)*$
numaset カスタムプロパティーで割り当てモード (interleave、strict、preferred) と使用するノードの両方を指定することができます。2 つの値は、コロン (:) で区切ります。正規表現により、nodeset を以下のように指定することができます。
- 特定のノード (
numaset=strict:1で、ノード 1 のみを使用するように指定) - 使用するノードの範囲 (
numaset=strict:1-4で、ノード 1 から 4 までを使用するように指定) - 特定のノードを使用しない (
numaset=strict:^3で、ノード 3 を使用しないように指定) - コンマ区切りで記述した、上記のいずれかの組み合わせ (
numaset=strict:1-4,6で、ノード 1 から 4 までと、6 を使用するように指定)
/usr/libexec/vdsm/hooks/before_vm_start/50_numa
#!/usr/bin/python
import os
import sys
import hooking
import traceback
'''
numa hook
=========
add numa support for domain xml:
<numatune>
<memory mode="strict" nodeset="1-4,^3" />
</numatune>
memory=interleave|strict|preferred
numaset="1" (use one NUMA node)
numaset="1-4" (use 1-4 NUMA nodes)
numaset="^3" (don't use NUMA node 3)
numaset="1-4,^3,6" (or combinations)
syntax:
numa=strict:1-4
'''
if os.environ.has_key('numa'):
try:
mode, nodeset = os.environ['numa'].split(':')
domxml = hooking.read_domxml()
domain = domxml.getElementsByTagName('domain')[0]
numas = domxml.getElementsByTagName('numatune')
if not len(numas) > 0:
numatune = domxml.createElement('numatune')
domain.appendChild(numatune)
memory = domxml.createElement('memory')
memory.setAttribute('mode', mode)
memory.setAttribute('nodeset', nodeset)
numatune.appendChild(memory)
hooking.write_domxml(domxml)
else:
sys.stderr.write('numa: numa already exists in domain xml')
sys.exit(2)
except:
sys.stderr.write('numa: [unexpected error]: %s\n' % traceback.format_exc())
sys.exit(2)

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.