hwloc-nox set CPU affinity in Linux

sudo apt-get install  hwloc-nox
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  hwloc-nox
0 upgraded, 1 newly installed, 0 to remove and 530 not upgraded.
Need to get 151 kB of archives.
After this operation, 453 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial/universe amd64 hwloc-nox amd64 1.11.2-3 [151 kB]
Fetched 151 kB in 0s (184 kB/s)   
Selecting previously unselected package hwloc-nox.
(Reading database ... 224148 files and directories currently installed.)
Preparing to unpack .../hwloc-nox_1.11.2-3_amd64.deb ...
Unpacking hwloc-nox (1.11.2-3) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up hwloc-nox (1.11.2-3) ...
mint@mint ~ $ apt-cache search lstopo^C
mint@mint ~ $ lstopo
lstopo              lstopo-no-graphics 
mint@mint ~ $ lstopo-no-graphics
Machine (16GB total)
  NUMANode L#0 (P#0 7962MB)
    Package L#0
      L3 L#0 (6144KB)
        L2 L#0 (2048KB) + L1i L#0 (64KB) + Core L#0
          L1d L#0 (16KB) + PU L#0 (P#0)
          L1d L#1 (16KB) + PU L#1 (P#2)
        L2 L#1 (2048KB) + L1i L#1 (64KB) + Core L#1
          L1d L#2 (16KB) + PU L#2 (P#4)
          L1d L#3 (16KB) + PU L#3 (P#6)
        L2 L#2 (2048KB) + L1i L#2 (64KB) + Core L#2
          L1d L#4 (16KB) + PU L#4 (P#8)
          L1d L#5 (16KB) + PU L#5 (P#10)
        L2 L#3 (2048KB) + L1i L#3 (64KB) + Core L#3
          L1d L#6 (16KB) + PU L#6 (P#12)
          L1d L#7 (16KB) + PU L#7 (P#14)
      L3 L#1 (6144KB)
        L2 L#4 (2048KB) + L1i L#4 (64KB) + Core L#4
          L1d L#8 (16KB) + PU L#8 (P#16)
          L1d L#9 (16KB) + PU L#9 (P#18)
        L2 L#5 (2048KB) + L1i L#5 (64KB) + Core L#5
          L1d L#10 (16KB) + PU L#10 (P#20)
          L1d L#11 (16KB) + PU L#11 (P#22)
        L2 L#6 (2048KB) + L1i L#6 (64KB) + Core L#6
          L1d L#12 (16KB) + PU L#12 (P#24)
          L1d L#13 (16KB) + PU L#13 (P#26)
        L2 L#7 (2048KB) + L1i L#7 (64KB) + Core L#7
          L1d L#14 (16KB) + PU L#14 (P#28)
          L1d L#15 (16KB) + PU L#15 (P#30)
    HostBridge L#0
      PCIBridge
        PCI 14e4:1639
          Net L#0 "enp4s0f0"
        PCI 14e4:1639
          Net L#1 "enp4s0f1"
      PCIBridge
        PCI 14e4:1639
          Net L#2 "enp5s0f0"
        PCI 14e4:1639
          Net L#3 "enp5s0f1"
      PCIBridge
        PCI 103c:323a
      PCI 1002:4390
      PCI 1002:439c
        Block(Removable Media Device) L#4 "sr0"
      PCIBridge
        PCI 1002:515e
          GPU L#5 "renderD128"
          GPU L#6 "card0"
          GPU L#7 "controlD64"
  NUMANode L#1 (P#2 8032MB) + Package L#1
    L3 L#2 (6144KB)
      L2 L#8 (2048KB) + L1i L#8 (64KB) + Core L#8
        L1d L#16 (16KB) + PU L#16 (P#1)
        L1d L#17 (16KB) + PU L#17 (P#3)
      L2 L#9 (2048KB) + L1i L#9 (64KB) + Core L#9
        L1d L#18 (16KB) + PU L#18 (P#5)
        L1d L#19 (16KB) + PU L#19 (P#7)
      L2 L#10 (2048KB) + L1i L#10 (64KB) + Core L#10
        L1d L#20 (16KB) + PU L#20 (P#9)
        L1d L#21 (16KB) + PU L#21 (P#11)
      L2 L#11 (2048KB) + L1i L#11 (64KB) + Core L#11
        L1d L#22 (16KB) + PU L#22 (P#13)
        L1d L#23 (16KB) + PU L#23 (P#15)
    L3 L#3 (6144KB)
      L2 L#12 (2048KB) + L1i L#12 (64KB) + Core L#12
        L1d L#24 (16KB) + PU L#24 (P#17)
        L1d L#25 (16KB) + PU L#25 (P#19)
      L2 L#13 (2048KB) + L1i L#13 (64KB) + Core L#13
        L1d L#26 (16KB) + PU L#26 (P#21)
        L1d L#27 (16KB) + PU L#27 (P#23)
      L2 L#14 (2048KB) + L1i L#14 (64KB) + Core L#14
        L1d L#28 (16KB) + PU L#28 (P#25)
        L1d L#29 (16KB) + PU L#29 (P#27)
      L2 L#15 (2048KB) + L1i L#15 (64KB) + Core L#15
        L1d L#30 (16KB) + PU L#30 (P#29)
        L1d L#31 (16KB) + PU L#31 (P#31)

Set your affinity

 

taskset -p ps aux^C
mint mint # ps aux|grep kvm
root      1306  0.0  0.0      0     0 ?        S<   Aug17   0:00 [kvm-irqfd-clean]
root      3724  0.0  0.0  91656  5056 pts/3    S+   16:44   0:00 sudo qemu-system-x86_64 -m 11264 -smp 1 -net tap -net nic -enable-kvm -cpu host -drive file=/dev/sda
root      3725  8.7 45.2 12405860 7413032 pts/3 Sl+ 16:44  11:34 qemu-system-x86_64 -m 11264 -smp 1 -net tap -net nic -enable-kvm -cpu host -drive file=/dev/sda
root      3759  0.0  0.0      0     0 ?        S    16:44   0:00 [kvm-pit/3725]
root      5234  0.0  0.0  14224   980 pts/6    S+   18:56   0:00 grep --color=auto kvm
mint mint # taskset -pc 31 3725
pid 3725's current affinity list: 0-31
pid 3725's new affinity list: 31
mint mint # taskset -pc 30,31 3725
pid 3725's current affinity list: 31
pid 3725's new affinity list: 30,31

 

In the above command I set the affinity to core 31 and then changed it to cores 30 and 31.

Latest Articles

  • AMD Set Fan Speed and Other Powerplay Memory/CPU Timings with a Linux script
  • Ethereum Mining Claymore Nanopool Error
  • genisoimage errors with long filenames and deep directory structures
  • Linux Kernel USB Export Errors
  • How to download gajim 0.16.9 XMPP/Jabber client so you can use OMEMO encryption
  • HP DL385 G7 Linux BIOS Update Flash
  • hwloc-nox set CPU affinity in Linux
  • Firefox An error occurred during a connection to some-ip-or-domain. SSL peer reports incorrect Message Authentication Code. Error code: SSL_ERROR_BAD_MAC_ALERT Solution
  • Proxmox understanding the directory structure and why an NFS datastore appears to be missing files/isos
  • pandoc convert markdown to html
  • Proxmox error uploading an iso solution
  • Cannot install moodle
  • MySQL change for Antelope format to Barracuda error solution
  • vmkping -I vmk1 10.0.2.69 PING 10.0.2.69 (10.0.2.69): 56 data bytes sendto() failed (Host is down)
  • gvfs mount in /run/user cannot be accessed or displayed wrong permissions
  • VMWare vSphere 6.7 Errors Solution 503 Service Unavailable (Failed to connect to endpoint:
  • How To Enable Nested KVM so guests can virtualize with hardware extensions
  • vi error solution E166: Can't open linked file for writing
  • Supermicro IPMI / KVM / BMC Remote Console Screen Resizing Issue - Window Cut Off Solution
  • Linux bash shell doesn't show username, hostname or current path fix solution