커널 소스코드 에서 자주 볼 수 있는 __init 와 __initdata 는 초기화시에만 사용하고 사용되지 않는 함수와 데이터를 지정할때 사용되어진다. 커널 소스코드의 include/linux/init.h 에 아래와 같이 정의되어 있다. include/linux/init.h #define __init __section(.init.text) __cold notrace#define __initdata __section(.init.data) include/linux/compiler.h#define __section(S) __attribute__ ((__section__(#S))) 컴파일러는 __init 로 지정된 함수와 __Initdata 로 지정된 데이터는 커널 초기화과정 이후에 해제되는 영역에 배치함으로서..
리눅스 커널 소스를 보다보면 심심치 않게 __read_mostly 매크로를 마주하게된다. unsigned long __per_cpu_offset[NR_CPUS] __read_mostly; __read_mostly 매크로를 통해서 프로그래머는 컴파일러에게 " 이 데이터는 자주 수정되지 않으며 대부분 읽기 연산만 이루어진다" 라는 것을 알려준다. __read_mostly 는 다음과 같이 정의 되어있다. #define __read_mostly __attribute__((__section__(".data.read_mostly"))) 보통 SMP 를 고려한 코드 내에서 자주 볼수가 있는데, 컴파일러는 __read_mostly 로 선언 되어있는 데이터들을 바이너리 파일의 일정 부분에 모여있게 하여, 코어(core)..