[t:/]$ 지식_

GFP_ATOMIC

2011/11/02

tasklet 에서 alloc_pages, kmalloc을 쓸 때,
자꾸 시스템이 요단강을 건너면,

보를 근사하게 건설하고 자전거 도로를 내고 축제를 하면된다.
그러면 왠지 나도 OECD 국격에 맞는 시스템 프로그래머가 된 것 같은 기분이 든다니까!

자 솔루션.

옵션으로 GFP_KERNEL을 쓰지 말고,
GFP_ATOMIC을 준다.

LDD 책을 보자.

한 줄 요약 : 프로세스 컨텍스트 밖 (태스크릿, 커널 타이머, 인터럽트 핸들러)에서는 닥치고 GFP_ATOMIC이다.


GFP_KERNEL isn’t always the right allocation flag to use; sometimes kmalloc is called from outside a process’s context. This type of call can happen, for instance, in interrupt handlers, tasklets, and kernel timers. In this case, the current process should not be put to sleep, and the driver should use a flag of GFP_ATOMIC instead. The kernel normally tries to keep some free pages around in order to fulfill atomic allocation. When GFP_ATOMIC is used, kmalloc can use even the last free page. If that last page does not exist, however, the allocation fails.

workqueue는 왜 만들었을까? http://dooeui.blogspot.com/2010/03/bottom-half.html

즉, 커널쓰레드를 따로 만들어 쓸 필요가 없다. 이짝이 훨 안전함.

인용 – “뿐만 아니라 kernel thread를 직접 만들어서 사용할 때 할 수 있는 거의 모든 일을 work queue를 사용하여 구현할 수 있다. 따라서 디바이스 드라이버 작성자가 굳이 work queue대신 kernel thread를 직접 생성하여 사용할 필요가 없다. work queue는 kernel thread로 구현되었으므로 process context에서 실행되고 따라서 sleep이 가능하다. 대신 동기화에 대해서는 디바이스 드라이버 작성자가 직접 고려해 주어야 하며, process context지만 kernel thread이므로 user space에 대한 접근은 불가능하다.”





공유하기













[t:/] is not "technology - root". dawnsea, rss