{"id":57,"date":"2019-02-26T07:29:25","date_gmt":"2019-02-26T07:29:25","guid":{"rendered":"http:\/\/virtorbis.virtcompute.com\/?p=57"},"modified":"2019-02-26T08:28:46","modified_gmt":"2019-02-26T08:28:46","slug":"convert-a-hexadecimal-cpu-mask-into-a-bit-mask-and-identify-the-masked-cpus","status":"publish","type":"post","link":"https:\/\/virtorbis.virtcompute.com\/?p=57","title":{"rendered":"Setting DPDK parameters with Multi NUMA"},"content":{"rendered":"\n<p>Identify the NUMA node for nic cards from PCI address<br># lspci -vmms XX:XX.X | grep -i NUMANode<br><\/p>\n\n\n\n<p>Identify numa nodes on the server as below:<br><br># numactl -H<br>available: 2 nodes (0-1)<br> node 0 cpus: 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30<br> node 0 size: 16162 MB<br> node 0 free: 1468 MB<br> node 1 cpus: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31<br><\/p>\n\n\n\n<p class=\"has-medium-font-size\">DPDK Parameters:<\/p>\n\n\n\n<p>Initialize and enable dpdk ports on ovs with <strong>dpdk-init<\/strong>:<br><br><strong>#<\/strong>ovs-vsctl &#8211;no-wait set Open_vSwitch . other_config:dpdk-init=true<br><br>Set cpu pin sets for<strong> pmd-cpu-mask<\/strong>: (requires hex string for cpu sets)<br><br><strong>#<\/strong>ovs-vsctl set Open_vSwitch . other_config:pmd-cpu-mask=3c00<br>* Above example, assigning 10,12 from numa node 0 and 11,13 from numa node 1<br><br>Set memory for <strong>dpdk-socket-mem<\/strong>:<br>dpdk-socket-mem=&lt;mem allocation from numa node 0&gt;,&lt;mem allocation from numa node 1&gt;<br><br><strong>#<\/strong>ovs-vsctl &#8211;no-wait set Open_vSwitch . other_config:dpdk-socket-mem=1024,1024<br><br>Set CPU cores on which dpdk lcore threads should be spawned <strong>dpdk-lcore-mask<\/strong>: (requires hex string for cpu sets)<br><br>#ovs-vsctl &#8211;no-wait set Open_vSwitch . other_config:dpdk-lcore-mask=3c000<br>* Above example, assigning 14,16 from numa node 0 and 15,17 from numa node 1<br><\/p>\n\n\n\n<p>Below script from Red Hat will help to convert the hexadecimal cpu mask to cpu bit mask and reverse:<\/p>\n\n\n\n<p>Source: https:\/\/access.redhat.com\/solutions\/3221381<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#!\/usr\/bin\/python\n\nimport sys\n\ndef hex_to_comma_list(hex_mask):\n    binary = bin(int(hex_mask, 16))[2:]\n    reversed_binary = binary[::-1]\n    i = 0\n    output = \"\"\n    for bit in reversed_binary:\n        if bit == '1':\n            output = output + str(i) + ','\n        i = i + 1\n    return output[:-1]\n\ndef comma_list_to_hex(cpus):\n    cpu_arr = cpus.split(\",\")\n    binary_mask = 0\n    for cpu in cpu_arr:\n        binary_mask = binary_mask | (1 &lt;&lt; int(cpu))\n    return format(binary_mask, '02x')\n\nif len(sys.argv) != 2:\n    print \"Please provide a hex CPU mask or comma separated CPU list\"\n    sys.exit(2)\n\nuser_input = sys.argv[1]\n\ntry:\n  print hex_to_comma_list(user_input)\nexcept:\n  print comma_list_to_hex(user_input)<\/code><\/pre>\n\n\n\n<p>Example of above used cpu sets:<br><br># .\/converter.py 10,11,12,13<br>3c00<br># .\/converter.py 3c00<br>10,11,12,13<br># .\/converter.py 14,15,16,17<br>3c000<br># .\/converter.py 3c000<br>14,15,16,17<br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Identify the NUMA node for nic cards from PCI address# lspci -vmms XX:XX.X | grep -i NUMANode Identify numa nodes on the server as below: # numactl -Havailable: 2 nodes (0-1) node 0 cpus: 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 node 0 size: 16162 MB [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,40,4,23],"tags":[33,37,39,38,34,24,35,36],"class_list":["post-57","post","type-post","status-publish","format-standard","hentry","category-cloud","category-nfv","category-openstack","category-red-hat-openstack","tag-dpdk","tag-dpdk-lcore-mask","tag-hex-cpu-bit-mask","tag-hex-string","tag-nfv","tag-openstack","tag-ovs-dpdk","tag-pmd-cpu-mask"],"_links":{"self":[{"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=\/wp\/v2\/posts\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=57"}],"version-history":[{"count":8,"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions"}],"predecessor-version":[{"id":67,"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=\/wp\/v2\/posts\/57\/revisions\/67"}],"wp:attachment":[{"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=57"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/virtorbis.virtcompute.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}