init_task의 thread info의 cpu값 설정.

유경환 2011.10.21 19:15 조회 수 : 8010

원문은 아래와 같습니다.
ARM에서도 다른 아키텍처와 유사하게 아키텍처 의존적 smp_setup_processor_id() 함수를
이용하려나 봅니다. 현재 우리 3.0 코드에는 아래의 함수가 보이지 않는데
올해 8월에 커밋된걸로 봐서 최근에 ARM 아키텍쳐 의존적 smp_setup_processor_id()를
집어넣었나봅니다.

어찌되었든 이함수의 역할이 init_task에 현재 돌고있는 cpu id를 집어 넣는것으로 
아래 함수상에서는 보입니다.

그렇지만 현재 우리가 스터디하는 버젼의 리눅스에서는 아무리 찾아도 init_task의 cpu id를
설정하는부분을 찾을수 없습니다.

의미없는 컴파일 타임에서 생성된 이미지의 data area 값으로 생각됩니다.
무언가 발견한분 답글좀 달아주세요

--------------------------------------------------------------------------------------------------

 On ARM, Linux assumes that the boot CPU has ID 0. If this ends up being
out of sync with the hardware CPU number, we will configure the GIC
incorrectly and route interrupts to the CPU with hardware ID 0.

This patch implements smp_setup_processor_id for ARM, using the MPIDR to
set the CPU of the boot thread.

Signed-off-by: Will Deacon <will.deacon@xxxxxxx>
---
 arch/arm/kernel/smp.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
index d88ff02..8e60a4f 100644
--- a/arch/arm/kernel/smp.c
+++ b/arch/arm/kernel/smp.c
@@ -259,6 +259,22 @@ void __ref cpu_die(void)
 }
 #endif /* CONFIG_HOTPLUG_CPU */
 
+void __init smp_setup_processor_id(void)
+{
+ u32 mpidr;
+
+ /* Read the MPIDR to find the hardware ID of the current CPU. */
+ asm("1: mrc p15, 0, %0, c0, c0, 5n"
+    " .pushsection ".alt.smp.init", "a"n"
+    " .long 1bn"
+    " mov %0, #0n"
+    " .popsection"
+    : "=r" (mpidr));
+
+ current_thread_info()->cpu = mpidr & 0xff;
+ printk("Booting Linux on CPU %dn", current_thread_info()->cpu);
+}
+
 /*
  * Called by both boot and secondaries to move global data into
  * per-processor storage.
-- 
1.7.0.4
번호 제목 글쓴이 날짜 조회 수
공지 [공지] 커널 스터디 관련 Q&A 게시판 입니다. [5] woos 2016.04.09 2197
1585 Linux Device Model [2] file 김민호 2011.05.22 8459
1584 system_call 의 swapgs 인스트럭션에 대하여 [2] 지현구 2007.09.16 8438
1583 fork()와 vfork()의 차이점과 COW(Copy On Write) [1] 아폴로 2013.05.02 8340
1582 스핀락에 대한 나름대로의 정리와 3가지 질문.. [19] 이종인 2011.04.25 8335
1581 이번주 논의 사항 [2] 남현우 2008.05.10 8202
1580 죄송합니다. [1] 송형주 2008.05.13 8106
1579 스터디 장소 예약 했습니다. [13] 장병남 2010.04.05 8067
1578 [투표]이번주 모임 장소 투표해주세요. [15] 나영찬 2010.04.05 8014
» init_task의 thread info의 cpu값 설정. [8] 유경환 2011.10.21 8010
1576 ARM TCM Tightly Couple Memory a 2010.04.10 7954
1575 어제 sched_init()을 끝냈습니다. [1] 윤석훈 2010.08.22 7921
1574 [의미] Memory Barrier [10] 맥주 2007.12.17 7890
1573 ARMv8 아키텍쳐 관련 읽을거리 [3] K 2013.05.06 7829
1572 namespace file 유강희 2011.06.10 7824
1571 어제는 모두 잘 들어가셨나요'ㅅ' ㅎㅎㅎ [3] file 조은지 2010.04.11 7710
1570 2012.4.14 스터디 [6] 이한울 2012.04.14 7695
1569 smdk2440보드 회로도. [3] 김희근 2008.12.17 7690
1568 4/3 ARM C Study group 회의 내용 [10] file 강효민 2010.04.03 7670
1567 이제 start_kernel()에 함수가 38개밖에 안남았네요.. [4] 윤석훈 2010.11.30 7634
1566 리눅스 커널 심층분석 (4장 ~9장) 요약부분 [1] file 박재성 2011.06.03 7631
XE Login