Using CPU hotplug.

The kernel option CONFIG_HOTPLUG_CPU needs to be enabled. It is currently available on multiple architectures including ARM, MIPS, PowerPC and X86.
List all current CPUs and cores in the system:

server124:~ # ls -lh /sys/devices/system/cpu
total 0
drwxr-xr-x 5 root root 0 Jul 20 09:46 cpu0
drwxr-xr-x 5 root root 0 Jul 20 09:51 cpu1
drwxr-xr-x 2 root root 0 Jul 20 09:54 cpu2
drwxr-xr-x 2 root root 0 Jul 20 09:54 cpu3
drwxr-xr-x 2 root root 0 Jul 20 10:18 cpufreq
drwxr-xr-x 2 root root 0 Jul 20 10:18 cpuidle
-r--r--r-- 1 root root 4.0K Jul 20 09:46 kernel_max
-r--r--r-- 1 root root 4.0K Jul 20 10:12 offline
-r--r--r-- 1 root root 4.0K Jul 20 09:46 online
-r--r--r-- 1 root root 4.0K Jul 20 10:18 possible
-r--r--r-- 1 root root 4.0K Jul 20 10:18 present
--w------- 1 root root 4.0K Jul 20 10:18 probe
--w------- 1 root root 4.0K Jul 20 10:18 release

Each CPU folder contains an online file which controls the logical on (1) and off (0) state.
To logically shutdown cpu3:

server124:~ # echo 0 > /sys/devices/system/cpu/cpu3/online

and in the log file you can find something like this:

Jul 20 10:52:38 server124 kernel: [ 3969.489290] CPU 2 is now offline
Jul 20 10:52:38 server124 kernel: [ 3969.492336] CPU 3 is now offline

also by executing lscpu command:

server124:~ # lscpu |grep line
On-line CPU(s) list: 0-2
Off-line CPU(s) list: 3
server124:~ #

Once the CPU is shutdown, it will be removed from /proc/interrupts, /proc/cpuinfo and should also not be shown visible by the top command.
To bring cpu3 back online:

server124:~ # echo 1 > /sys/devices/system/cpu/cpu3/online

and in the log file:

Jul 20 11:00:01 server124 kernel: [ 4412.323732] Booting Node 0 Processor 3 APIC 0x3
Jul 20 11:00:01 server124 kernel: [ 4053.024204] mce: CPU supports 0 MCE banks

and by executing lscpu command:

server124:~ # lscpu |grep line
On-line CPU(s) list: 0-3
server124:~ #

The CPU is usable again.

Also chcpu can be used (chcpu can modify the state of CPUs. It can enable or disable CPUs, scan for new CPUs, change the CPU dispatching mode of the underlying hypervisor, and request CPUs from the hypervisor (configure) or return CPUs to thehypervisor (deconfigure)).

To disable CPUs 2 and 3:

server124:~ # chcpu -d 2,3
CPU 2 disabled
CPU 3 disabled

To enable CPUs 2 and 3:

server124:~ # chcpu -e 2,3
CPU 2 enabled
CPU 3 enabled