Core BSP 분석/리눅스 커널 핵심 분석
[리눅스커널] 특정 CPU를 Isolation 시키고 싶은 경우
AustinKim
2023. 5. 6. 21:03
프로젝트를 진행하다 보면 특정 CPU를 Isolation 시키고 싶을 때가 있습니다.
이 때 다음 패치(CPU2와 CPU3를 Isolation)를 적용하면 됩니다.
* 커널 4.19 버전
diff --git a/kernel/cpu.c b/kernel/cpu.c
index d9f855c..816bf4f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1126,6 +1126,10 @@ static int do_cpu_up(unsigned int cpu, enum cpuhp_state target)
{
int err = 0;
+ if(cpu == 2 | cpu ==3) {
+ return -EINVAL;
+ }
+
if (!cpu_possible(cpu)) {
pr_err("can't online cpu %d because it is not configured as may-hotadd at boot time\n",
cpu);
* 커널 3.18 버전
diff --git a/kernel/cpu.c b/kernel/cpu.c
index cd9c5c6..aeda1f8 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -518,6 +518,10 @@ int cpu_up(unsigned int cpu)
{
int err = 0;
+ if(cpu == 2 | cpu ==3) {
+ return -EINVAL;
+ }
+
if (!cpu_possible(cpu)) {
pr_err("can't online cpu %d because it is not configured as may-hotadd at boot time\n",
cpu);
이처럼 논리적인 CPU를 끄면 디바이스 노드에도 CPU2와 CPU3이 보이지 않을 것입니다.
$ ls /sys/devices/system/cpu
cpu0 cpu1
# Reference: For more information on 'Linux Kernel';
디버깅을 통해 배우는 리눅스 커널의 구조와 원리. 1
디버깅을 통해 배우는 리눅스 커널의 구조와 원리. 2
