Skip to main content
Corrected indents..
Source Link

I'm trying to disable some CPUs of my server.
I've found this link: https://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/linux-turn-on-off-cpu-core-commands/, which offers me a method as below:

Here is what numactl --hardware gave me:
enter image description here

I want to disable all CPUs from 16 to 63, so I write a script named opCPUs.sh as below:

#!/bin/bash

for i in {16..63}; do
        if [[ "$1" == "enable" ]]; then
                echo 1 > /sys/devices/system/cpu/cpu$i/online
        elif [[ "$1" == "disable" ]]; then
                echo 0 > /sys/devices/system/cpu/cpu$i/online
        else
                echo 'illegal parameter'
        fi
done
grep "processor" /proc/cpuinfo

Then I execute it: ./opCPUs.sh disable and I can see the result of grep in the script:
enter image description here

It seems to work.

Now I think all of processes should be in CPU 0 - 15 because others have been disabled.
So I use the existing processes dbus to verify as below:
ps -Lo psr $(pgrep dbus)

I get this:
enter image description here

The psr tells me in which CPU the process is running, right? If so, I have disabled CPU 60, CPU 52 etc, why they are still here?

I'm trying to disable some CPUs of my server.
I've found this link: https://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/linux-turn-on-off-cpu-core-commands/, which offers me a method as below:

Here is what numactl --hardware gave me:
enter image description here

I want to disable all CPUs from 16 to 63, so I write a script named opCPUs.sh as below:

#!/bin/bash

for i in {16..63}; do
        if [[ "$1" == "enable" ]]; then
                echo 1 > /sys/devices/system/cpu/cpu$i/online
        elif [[ "$1" == "disable" ]]; then
                echo 0 > /sys/devices/system/cpu/cpu$i/online
        else
                echo 'illegal parameter'
        fi
done
grep "processor" /proc/cpuinfo

Then I execute it: ./opCPUs.sh disable and I can see the result of grep in the script:
enter image description here

It seems to work.

Now I think all of processes should be in CPU 0 - 15 because others have been disabled.
So I use the existing processes dbus to verify as below:
ps -Lo psr $(pgrep dbus)

I get this:
enter image description here

The psr tells me in which CPU the process is running, right? If so, I have disabled CPU 60, CPU 52 etc, why they are still here?

I'm trying to disable some CPUs of my server.
I've found this link: https://www.cyberciti.biz/faq/debian-rhel-centos-redhat-suse-hotplug-cpu/linux-turn-on-off-cpu-core-commands/, which offers me a method as below:

Here is what numactl --hardware gave me:
enter image description here

I want to disable all CPUs from 16 to 63, so I write a script named opCPUs.sh as below:

#!/bin/bash

for i in {16..63}; do
    if [[ "$1" == "enable" ]]; then
        echo 1 > /sys/devices/system/cpu/cpu$i/online
    elif [[ "$1" == "disable" ]]; then
        echo 0 > /sys/devices/system/cpu/cpu$i/online
    else
        echo 'illegal parameter'
    fi
done
grep "processor" /proc/cpuinfo

Then I execute it: ./opCPUs.sh disable and I can see the result of grep in the script:
enter image description here

It seems to work.

Now I think all of processes should be in CPU 0 - 15 because others have been disabled.
So I use the existing processes dbus to verify as below:
ps -Lo psr $(pgrep dbus)

I get this:
enter image description here

The psr tells me in which CPU the process is running, right? If so, I have disabled CPU 60, CPU 52 etc, why they are still here?

edited title
Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237

How to disable one CPU

edited tags
Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237
deleted 102 characters in body
Source Link
Yves
  • 3.4k
  • 8
  • 38
  • 66
Loading
deleted 536 characters in body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237
Loading
edited body
Source Link
Rui F Ribeiro
  • 58k
  • 28
  • 156
  • 237
Loading
added 34 characters in body
Source Link
Yves
  • 3.4k
  • 8
  • 38
  • 66
Loading
added 434 characters in body
Source Link
Yves
  • 3.4k
  • 8
  • 38
  • 66
Loading
added 36 characters in body
Source Link
Yves
  • 3.4k
  • 8
  • 38
  • 66
Loading
Source Link
Yves
  • 3.4k
  • 8
  • 38
  • 66
Loading