[커널 17차 A-2조] 15주차

2020.12.06 01:45

ㅇㅇㅇ 조회 수:134

init/main.c

 

start_kernel 진행 중

 

1) debug_objects_early_init()

 

- obj_hash의 spin lock 초기화 및 obj_pool에 obj_static_pool 추가

- list_head 자료구조 : 리눅스 커널의 연결리스트 정리 | Unknown (wordpress.com)

                            The Linux Kernel API — The Linux Kernel documentation

- hlist_head : hash table을 위한 doubly linked list 자료 구조

                  Linux Kernel Data Structure - Hash List · Jiaquan He (hejq.me)

 

2) cgroup_init_early()

 

- init_cgroup_root() 진행 중

- WRITE_ONCE() 매크로

: compiletime_assert_rwonce_type(x) : x의 type이 현재 architecture에서 atomic access 가능한 단위인지 체크. 예외적으로 long long type은 atomic type이 아니어도 build 허용. 그 외엔 build 실패하고 메시지를 출력함.

: __WRITE_ONCE(x, val) : val을 x에 쓰되 x를 volatile로 access함. 동일한 volatile 변수에 대한 접근한 compiler가 순서를 보장해주는 것으로 보임. 이를 통해 __WRITE_ONCE 이후 __READ_ONCE가 사용될 때 순서가 보장됨.

(예 : list_del_init() 이후에 list_empty()가 호출되는 경우

관련 사이트 : kernel/git/torvalds/linux.git - Linux kernel source tree

                  Volatiles (Using the GNU Compiler Collection (GCC))

- atomic_set() : atomic_t 자료구조, WRITE_ONCE로 구현됨

- init_cgroup_housekeeping()

- mutex_init() : mutex 초기화

: mutex 자료구조

- atomic_long_t owner : mutex 점유 중인 task 주소 저장

- spinlock_t wait_lock : mutex를 잡기 위한 spinlock. spinlock은 atomic_t와 locked, pending, tail이 union되어 있음.

- optimistic_spin_queue osq : tail task의 CPU number 저장?

- mutex를 기다리는 task의 list

- prev_cputime_init()

- for_each_subsys 매크로

- init_waitqueue_head()

- INIT_WORK() 매크로

 

cgroup 관련 내용

1장. 컨트롤 그룹 (Cgroups) 소개 Red Hat Enterprise Linux 6 | Red Hat Customer Portal

Linux cgroups에 대해 알아보자 1 - Lab of ryul99 (torch.vision)

 

mutex 관련 내용

- mutex_lock() 실행 시 atomic operation 기반의 fast mutex lock을 먼저 시도하고 이후 spinlock 또는 sleep 방식의 slow lock을 시도함.

- atomic operation은 cmpxchg 연산을 사용하며 ARM v8.1 이후부터 cmpxchg는 CAS 명령어로 구현됨

- MCS_LOCK : MCS Lock 이해하기 & 구현 :: Live like penguin (tistory.com)

 

 

XE Login