ARM10C 68주차 후기
일시 : 2014.08.30 (68주차)
모임명 : NAVER개발자커뮤니티지원_IAMROOT.ORG_10차ARM-C
장소 : 토즈 강남 타워점
장소지원: NAVER 개발자 커뮤니티 지원 프로그램
참여인원: 5명
스터디 진도 :
- sched_init()
main.c::start_kernel()
asmlinkage void __init start_kernel(void)
{
...
boot_cpu_init();
// 현재 cpu(core id)를 얻어서 cpu_XXX_bits[] 의 cpu를 셋한다.
page_address_init();
// 128개의 page_address_htable 배열을 초기화
...
setup_arch(&command_line);
...
setup_nr_cpu_ids();
setup_per_cpu_areas();
// pcpu 구조체를 만들어 줌 (mm/percpu.c)
smp_prepare_boot_cpu(); /* arch-specific boot-cpu hooks */
// boot cpu 0의 pcpu 영역의 base주소를 core register에 설정해줌
...
page_alloc_init();
// cpu_chain에 page_alloc_cpu_notify를 연결함 (mutex lock/unlock 사용)
...
vfs_caches_init_early();
// Dentry cache, Inode-cache용 hash를 위한 메모리 공간을 각각 512kB, 256kB만큼 할당 받고,
// 131072, 65536개 만큼 hash table을 각각 만듬
...
mm_init();
// buddy와 slab 을 활성화 하고 기존 할당 받은 bootmem 은 buddy,
// pcpu 메모리, vmlist 는 slab으로 이관
sched_init();
sched_init();
스케쥴러 초기화를 분석합니다.
core.c::sched_init()
// ARM10C 20140830
void __init sched_init(void)
{
int i, j;
unsigned long alloc_size = 0, ptr;
// alloc_size: 0
#ifdef CONFIG_FAIR_GROUP_SCHED // CONFIG_FAIR_GROUP_SCHED=n
alloc_size += 2 * nr_cpu_ids * sizeof(void **);
#endif
#ifdef CONFIG_RT_GROUP_SCHED // CONFIG_RT_GROUP_SCHED=n
alloc_size += 2 * nr_cpu_ids * sizeof(void **);
#endif
#ifdef CONFIG_CPUMASK_OFFSTACK // CONFIG_CPUMASK_OFFSTACK=n
alloc_size += num_possible_cpus() * cpumask_size();
#endif
// alloc_size: 0
if (alloc_size) {
ptr = (unsigned long)kzalloc(alloc_size, GFP_NOWAIT);
#ifdef CONFIG_FAIR_GROUP_SCHED // CONFIG_FAIR_GROUP_SCHED=n
root_task_group.se = (struct sched_entity **)ptr;
ptr += nr_cpu_ids * sizeof(void **);
root_task_group.cfs_rq = (struct cfs_rq **)ptr;
ptr += nr_cpu_ids * sizeof(void **);
#endif /* CONFIG_FAIR_GROUP_SCHED */
#ifdef CONFIG_RT_GROUP_SCHED // CONFIG_RT_GROUP_SCHED=n
root_task_group.rt_se = (struct sched_rt_entity **)ptr;
ptr += nr_cpu_ids * sizeof(void **);
root_task_group.rt_rq = (struct rt_rq **)ptr;
ptr += nr_cpu_ids * sizeof(void **);
#endif /* CONFIG_RT_GROUP_SCHED */
#ifdef CONFIG_CPUMASK_OFFSTACK // CONFIG_CPUMASK_OFFSTACK=n
for_each_possible_cpu(i) {
per_cpu(load_balance_mask, i) = (void *)ptr;
ptr += cpumask_size();
}
#endif /* CONFIG_CPUMASK_OFFSTACK */
}
#ifdef CONFIG_SMP // CONFIG_SMP=y
init_defrootdomain();
// def_root_domain의 맴버 값을 초기화 수행
// (&def_root_domain->cpupri)->pri_to_cpu[0 ... 101].count: 0
// &(&def_root_domain->cpupri)->pri_to_cpu[0 ... 101].mask.bit[0]: 0
// (&def_root_domain->cpupri)->cpu_to_pri[0 ... 3]: -1
// &def_root_domain.refcount: 1
#endif
// global_rt_period(): 1000000000, global_rt_runtime(): 950000000
init_rt_bandwidth(&def_rt_bandwidth,
global_rt_period(), global_rt_runtime());
// init_rt_bandwidth에서 한일:
// (&def_rt_bandwidth)->rt_period: 1000000000
// (&def_rt_bandwidth)->rt_runtime: 950000000
// &(&def_rt_bandwidth)->rt_runtime_lock을 사용한 spinlock 초기화
// (&def_rt_bandwidth)->rt_period_timer의 값을 0으로 초기화
// &(&def_rt_bandwidth)->rt_period_timer)->base: &hrtimer_bases->clock_base[0]
// (&(&(&def_rt_bandwidth)->rt_period_timer)->node)->node의 RB Tree의 초기화
// &(&def_rt_bandwidth)->rt_period_timer.function: sched_rt_period_timer
#ifdef CONFIG_RT_GROUP_SCHED // CONFIG_RT_GROUP_SCHED=n
init_rt_bandwidth(&root_task_group.rt_bandwidth,
global_rt_period(), global_rt_runtime());
#endif /* CONFIG_RT_GROUP_SCHED */
#ifdef CONFIG_CGROUP_SCHED // CONFIG_CGROUP_SCHED=n
list_add(&root_task_group.list, &task_groups);
INIT_LIST_HEAD(&root_task_group.children);
INIT_LIST_HEAD(&root_task_group.siblings);
autogroup_init(&init_task);
#endif /* CONFIG_CGROUP_SCHED */
for_each_possible_cpu(i) {
// for ((i) = -1; (i) = cpumask_next((i), (cpu_possible_mask)), (i) < nr_cpu_ids; )
struct rq *rq;
// i: 0
// cpu_rq(0):
// &({
// do {
// const void __percpu *__vpp_verify = (typeof(&(runqueues)))NULL;
// (void)__vpp_verify;
// } while (0)
// (&(runqueues) + (pcpu_unit_offsets[0] + __per_cpu_start에서의pcpu_base_addr의 옵셋);
// })
rq = cpu_rq(i);
// rq: (&(runqueues) + (pcpu_unit_offsets[0] + __per_cpu_start에서의pcpu_base_addr의 옵셋)
// [pcp0] &rq->lock: &(runqueues)->lock
raw_spin_lock_init(&rq->lock);
// [pcp0] &rq->lock: &(runqueues)->lock 을 사용한 spinlock 초기화 수행
// [pcp0] &rq->nr_running: &(runqueues)->nr_running
rq->nr_running = 0;
// [pcp0] &rq->nr_running: &(runqueues)->nr_running: 0
// [pcp0] &rq->calc_load_active: &(runqueues)->calc_load_active
rq->calc_load_active = 0;
// [pcp0] &rq->calc_load_active: &(runqueues)->calc_load_active: 0
// [pcp0] &rq->calc_load_update: &(runqueues)->calc_load_update,
// jiffies: -30000 (0xFFFFFFFFFFFF8AD0): vmlinux.lds.S 에 있음, LOAD_FREQ: 501
rq->calc_load_update = jiffies + LOAD_FREQ;
// [pcp0] &rq->calc_load_update: &(runqueues)->calc_load_update: -29499 (0xFFFFFFFFFFFF8CC5)
// [pcp0] &rq->cfs: &(runqueues)->cfs
init_cfs_rq(&rq->cfs);
// init_cfs_rq 에서 한일:
// (&(runqueues)->cfs)->tasks_timeline: (struct rb_root) { NULL, }
// (&(runqueues)->cfs)->min_vruntime: 0xFFFFFFFFFFF00000
// (&(runqueues)->cfs)->min_vruntime_copy: 0xFFFFFFFFFFF00000
// (&(runqueues)->cfs)->decay_counter: 1
// (&(runqueues)->cfs)->removed_load: 0
// [pcp0] &rq->rt: &(runqueues)->rt, rq: &(runqueues)
init_rt_rq(&rq->rt, rq);
// init_rt_rq 에서 한일:
// (&(&(runqueues)->rt)->active)->bitmap의 0 ... 99 bit를 클리어
// (&(&(runqueues)->rt)->active)->queue[0 ... 99] 의 리스트 초기화
// (&(&(runqueues)->rt)->active)->bitmap의 100 bit를 1로 세팅
// (&(runqueues)->rt)->rt_runtime_lock 을 사용한 spinlock 초기화
// (&(runqueues)->rt)->rt_runtime: 0
// (&(runqueues)->rt)->rt_throttled: 0
// (&(runqueues)->rt)->rt_time: 0
// (&(&(runqueues)->rt)->pushable_tasks)->node_list 리스트 초기화
// (&(runqueues)->rt)->overloaded: 0
// (&(runqueues)->rt)->rt_nr_migratory: 0
// (&(runqueues)->rt)->highest_prio.next: 100
// (&(runqueues)->rt)->highest_prio.curr: 100
// 2014/08/30 종료
study log
92e2dcc..7db0df3 master -> origin/master
Updating 92e2dcc..7db0df3
Fast-forward
arch/arm/include/asm/processor.h | 3 +
arch/arm/kernel/vmlinux.lds.S | 5 +
include/asm-generic/param.h | 3 +
include/asm-generic/percpu.h | 60 +-
include/linux/bitmap.h | 2 +
include/linux/cache.h | 15 +-
include/linux/cpumask.h | 21 +-
include/linux/gfp.h | 1 +
include/linux/hrtimer.h | 12 +-
include/linux/jiffies.h | 3 +
include/linux/ktime.h | 13 +
include/linux/percpu-defs.h | 33 +
include/linux/percpu.h | 342 ++++++++
include/linux/plist.h | 4 +
include/linux/rbtree.h | 22 +-
include/linux/sched.h | 3 +
include/linux/sched/rt.h | 1 +
include/linux/slab.h | 40 +-
include/linux/slub_def.h | 1 +
include/linux/spinlock.h | 2 +
include/linux/spinlock_types.h | 1 +
include/linux/threads.h | 1 +
include/linux/time.h | 1 +
include/linux/timerqueue.h | 8 +
include/linux/types.h | 2 +
include/uapi/linux/time.h | 10 +
init/main.c | 1 +
kernel/hrtimer.c | 69 +-
kernel/sched/core.c | 118 ++-
kernel/sched/cpupri.c | 20 +
kernel/sched/cpupri.h | 14 +-
kernel/sched/fair.c | 21 +-
kernel/sched/rt.c | 66 +-
kernel/sched/sched.h | 83 +-
kernel/timer.c | 5 +
lib/kasprintf.c | 14 +-
lib/rbtree.c | 6 +-
mm/percpu.c | 12 +-
mm/slab_common.c | 393 +++++----
mm/slub.c | 1629 +++++++++++++++++++-------------------
mm/vmalloc.c | 32 +-
41 files changed, 2025 insertions(+), 1067 deletions(-)