10차 ARM 리눅스 커널 스터디 52주차(2014.04.26) 후기입니다.
일시 : 2014.04.26 (52주차)
모임명 : NAVER개발자커뮤니티지원_IAMROOT.ORG_10차ARM-C
장소 : 토즈 타워점
장소지원 : NAVER 개발자 커뮤니티 지원 프로그램
참여인원 : 5명
스터디 진도 :
- start_kernel()-> mm_init()->kmem_cache_init() 분석중
스터디관련 내용
start_kernel()->mm_init()->kmem_cache_init()
create_boot_cache()
void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t size, unsigned long flags)
{
int err;
// s->name: boot_kmem_cache_node.name: NULL
s->name = name;
// s->name: boot_kmem_cache_node.name: "kmem_cache_node"
// s->size: boot_kmem_cache_node.size: 0
// s->object_size: boot_kmem_cache_node.object_size: 0
s->size = s->object_size = size;
// s->size: boot_kmem_cache_node.size: 44
// s->object_size: boot_kmem_cache_node.object_size: 44
// flags: SLAB_HWCACHE_ALIGN: 0x00002000UL, ARCH_KMALLOC_MINALIGN: 64, size: 44
// s->align: boot_kmem_cache_node.align: 0
s->align = calculate_alignment(flags, ARCH_KMALLOC_MINALIGN, size);
// s->align: boot_kmem_cache_node.align: 64
// s: &boot_kmem_cache_node, flags: SLAB_HWCACHE_ALIGN: 0x00002000UL
err = __kmem_cache_create(s, flags);
if (err)
panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n", name, size, err);
s->refcount = -1; /* Exempt from merging for now */
}
kmem_cache_open()
- if(!kmem_cache_has_cpu_partial(s))
- kmem_cache_open()
- // s: &boot_kmem_cache_node, kmem_cache_debug(&boot_kmem_cache_node): 0
- return !kmem_cache_debug(s);
- return 0
- init_kmem_cache_nodes(s)
- if(slab_state == DOWN) {
- early_kmem_cache_node_alloc(node)
- page = new_slab(kmem_cache_node, GFP_NOWAIT, node);
define GFP_NOWAIT (GFP_ATOMIC & ~__GFP_HIGH)
GFP_KERNEL 에 대하여
GFP_KERNEL가 GFP_USER보다 priority가 높다는 것은, GFP_KERNEL option으로 호출하면, kmalloc의 메모리가 부족하면 메모리가 확보될때가지 계속 시도하지만,
GFP_USER option로 호출하면, 메모리 부족하면 fail로 끝난다고 합니다.
GFP_ATOMIC
it means roughly “make the allocation operation atomic”. This means that the kernel will try to find the memory using a pile of free memory set aside for urgent allocation. If that pile doesn’t have enough free pages, the operation will fail. This flag is useful for allocation within interrupt handlers.
GFP_KERNEL
it will try a little harder to find memory. There’s a
possibility that the call to kmalloc() will sleep while the kernel is trying to find memory (thus making it unsuitable for interrupt handlers). It’s much more rare for an allocation with GFP_KERNEL to fail than with GFP_ATOMIC.
In all cases, kmalloc() should only be used allocating small amounts of memory (a few kb). vmalloc() is better for larger amounts.
Also note that in lab 1 and lab 2, it would have been arguably better to use GFP_KERNEL instead of GFP_ATOMIC. GFP_ATOMIC should be saved for those instances in which a sleep would be totally unacceptable.
싸이월드 사진 백업을 받는 프로그램
그 외
- 스터디 시작 1년을 맞아서 조촐한 저녁 축하 파티를 했습니다.
- 가족과 함께 즐거운 시간을 보내고 다음 주(5월 10일)에 소스 분석을 계속합니다.
- Ubutu 14.04 LTS가 kernel 3.13.0을 사용합니다. LTS는 2019년까지 서비스를 계속할 예정이므로 가능하다다면 LTS 커널이 좋다는 의견이었습니다. 하지만 지금까지 한 공부한 것이 많아서, 각자 연휴기간동안 저희 커널 3.11에서 3.13으로 옴겨서 분석할 수 있을지 각자가 고민해 보기로 하였습니다.
스터디 로그
3278ad9..9ce507a master -> origin/master
Updating 3278ad9..9ce507a
Fast-forward
include/linux/cpuset.h | 5 +
include/linux/gfp.h | 107 +++
include/linux/kernel.h | 1 +
include/linux/lockdep.h | 1 +
include/linux/memcontrol.h | 3 +-
include/linux/mmzone.h | 15 +++
include/linux/nodemask.h | 14 +-
include/linux/numa.h | 2 +
include/linux/types.h | 1 +
include/uapi/linux/types.h | 1 +
mm/internal.h | 4
mm/memcontrol.c | 1 +
mm/mmzone.c | 8 ++
mm/page_alloc.c | 53 +++—-
mm/slab.h | 2 +
mm/slab_common.c | 1 +
mm/slub.c | 45 ++-
17 files changed, 254 insertions(+), 10 deletions(-)