[커널 18차] 69주차

2022.09.22 02:25

kkr 조회 수:58

git : https://github.com/iamroot18/5.10/commit/734cc5672bd98611e85a3d449d3e032632c0e56d

https://github.com/iamroot18/5.10/commit/033a40c22715ebe83010b52a669c64732503019c

https://github.com/iamroot18/5.10/commit/49bce5aeba94cb72bfcf9de4d622055861132012

 

diff --git a/include/linux/hrtimer.h b/include/linux/hrtimer.h
index 0ee140176f10..df0121d127d6 100644
--- a/include/linux/hrtimer.h
+++ b/include/linux/hrtimer.h
@@ -36,6 +36,12 @@ struct hrtimer_cpu_base;
  * HRTIMER_MODE_HARD        - Timer callback function will be executed in
  *                  hard irq context even on PREEMPT_RT.
  */
+
+/*
+ * IAMROOT, 2022.09.17:
+ * - ABS : 절대적인 시각
+ *   REL : 현재시간 + X시간 후 시각.
+ */
 enum hrtimer_mode {
     HRTIMER_MODE_ABS    = 0x00,
     HRTIMER_MODE_REL    = 0x01,
@@ -211,9 +217,28 @@ enum  hrtimer_base_type {
  *     Do not dereference the pointer because it is not reliable on
  *     cross cpu removals.
  */
+
+/*
+ * IAMROOT, 2022.09.17:
+ * @softirq_activated: softirq가 처리되고 있는 도중(interrupt). 곧 demon도작.
+ * @softirq_expires_next: 
+ */
 struct hrtimer_cpu_base {
     raw_spinlock_t            lock;
     unsigned int            cpu;
+/*
+ * IAMROOT, 2022.09.17:
+ *
+ * - base->index(enum hrtimer_base_type)에 rbtree가 하나라도 존재하는지를 표시한다.
+ * - ex) HRTIMER_BASE_REALTIME가 set이라면
+ * idx |0|1|2|3|4|5|6|7|
+ *     |0|1|0|0|0|0|0|0|
+ *        ^
+ *        rbtree
+ *         /\
+ *        .. ..
+ * 해당 base에 timer 가 존재하는지 빠르게 알아보기 위함이다.
+ */
     unsigned int            active_bases;
     unsigned int            clock_was_set_seq;
     unsigned int            hres_active        : 1,
@@ -249,6 +274,16 @@ static inline void hrtimer_set_expires_range(struct hrtimer *timer, ktime_t time
     timer->node.expires = ktime_add_safe(time, delta);
 }
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 
+ *              <-----------------------------*
+ *        _softexpires                    node.expires
+ *            @time                         @time+@delta
+ *    
+ *        _softexpires 지점으로 타이머를 등록하지만, 
+ *        node.expires 지점까지 만료 시각을 연창할 수 있습니다.
+ */
 static inline void hrtimer_set_expires_range_ns(struct hrtimer *timer, ktime_t time, u64 delta)
 {
     timer->_softexpires = time;
@@ -401,6 +436,7 @@ static inline void destroy_hrtimer_on_stack(struct hrtimer *timer) { }
 #endif
 
 /* Basic timer operations: */
+
 extern void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
                    u64 range_ns, const enum hrtimer_mode mode);
 
@@ -412,6 +448,11 @@ extern void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
  *        relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED);
  *        softirq based mode is considered for debug purpose only!
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * @tim nano sec
+ * - timer 요청.
+ */
 static inline void hrtimer_start(struct hrtimer *timer, ktime_t tim,
                  const enum hrtimer_mode mode)
 {
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 235047d7a1b5..624302e6ea11 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -161,6 +161,12 @@ static inline void rb_replace_node_cached(struct rb_node *victim,
  *
  * Returns @node when it is the new leftmost, or NULL.
  */
+/*
+ * IAMROOT, 2022.09.17: 
+ * 추가된 노드가 가장 빠른 leftmost에 등록된 경우 @node를 반환하고,
+ * 그렇지 않은 경우 NULL을 반환한다.
+ */
+
 static __always_inline struct rb_node *
 rb_add_cached(struct rb_node *node, struct rb_root_cached *tree,
           bool (*less)(struct rb_node *, const struct rb_node *))
diff --git a/include/linux/timerqueue.h b/include/linux/timerqueue.h
index 93884086f392..baed95f912dc 100644
--- a/include/linux/timerqueue.h
+++ b/include/linux/timerqueue.h
@@ -30,6 +30,10 @@ extern struct timerqueue_node *timerqueue_iterate_next(
  *
  * Returns a pointer to the timer node that has the earliest expiration time.
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - rbtree에서 제일 빠른 timer node를 가져온다.
+ */
 static inline
 struct timerqueue_node *timerqueue_getnext(struct timerqueue_head *head)
 {
@@ -53,6 +57,10 @@ static inline bool timerqueue_node_expires(struct timerqueue_node *node)
     return node->expires;
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - hrtimer는 rbtree로 되있다.
+ */
 static inline void timerqueue_init_head(struct timerqueue_head *head)
 {
     head->rb_root = RB_ROOT_CACHED;
diff --git a/include/uapi/linux/time.h b/include/uapi/linux/time.h
index 4f4b6e48e01c..eb850b2c4316 100644
--- a/include/uapi/linux/time.h
+++ b/include/uapi/linux/time.h
@@ -46,6 +46,10 @@ struct timezone {
 /*
  * The IDs of the various system clocks (for POSIX.1b interval timers):
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - posix clock은 10개가 제공된다.
+ */
 #define CLOCK_REALTIME            0
 #define CLOCK_MONOTONIC            1
 #define CLOCK_PROCESS_CPUTIME_ID    2
diff --git a/include/vdso/jiffies.h b/include/vdso/jiffies.h
index 2f9d596c8b29..b53913b6a2d9 100644
--- a/include/vdso/jiffies.h
+++ b/include/vdso/jiffies.h
@@ -6,6 +6,12 @@
 #include <vdso/time64.h>
 
 /* TICK_NSEC is the time between ticks in nsec assuming SHIFTED_HZ */
+
+/*
+ * IAMROOT, 2022.09.17:
+ * - ex) hz = 1000
+ *   (10^9 + 1000 / 2) / 1000 = 1000_000 nsec = 1 msec
+ */
 #define TICK_NSEC ((NSEC_PER_SEC+HZ/2)/HZ)
 
 #endif /* __VDSO_JIFFIES_H */
diff --git a/include/vdso/ktime.h b/include/vdso/ktime.h
index a0fd07239e0e..8d69e21436c1 100644
--- a/include/vdso/ktime.h
+++ b/include/vdso/ktime.h
@@ -10,6 +10,11 @@
  * idea of the (in)accuracy of timers. Timer values are rounded up to
  * this resolution values.
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - ex) hz = 1000
+ *   (10^9 + 1000 / 2) / 1000 = 1000_000 nsec = 1 msec
+ */
 #define LOW_RES_NSEC        TICK_NSEC
 #define KTIME_LOW_RES        (LOW_RES_NSEC)
 
diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c
index 0ea8702eb516..1019b15947ab 100644
--- a/kernel/time/hrtimer.c
+++ b/kernel/time/hrtimer.c
@@ -52,6 +52,14 @@
  * Masks for selecting the soft and hard context timers from
  * cpu_base->active
  */
+
+/*
+ * IAMROOT, 2022.09.17:
+ *           7                    4                     0
+ * |          |HRTIMER_ACTIVE_SOFT | HRTIMER_ACTIVE_HARD |
+ *
+ * - active중인 base.
+ */
 #define MASK_SHIFT        (HRTIMER_BASE_MONOTONIC_SOFT)
 #define HRTIMER_ACTIVE_HARD    ((1U << MASK_SHIFT) - 1)
 #define HRTIMER_ACTIVE_SOFT    (HRTIMER_ACTIVE_HARD << MASK_SHIFT)
@@ -65,6 +73,10 @@
  * to reach a base using a clockid, hrtimer_clockid_to_base()
  * is used to convert from clockid to the proper hrtimer_base_type.
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - hard_irq 4종류, sort_irq 4종류.
+ */
 DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
 {
     .lock = __RAW_SPIN_LOCK_UNLOCKED(hrtimer_bases.lock),
@@ -85,6 +97,11 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
             .clockid = CLOCK_BOOTTIME,
             .get_time = &ktime_get_boottime,
         },
+/*
+ * IAMROOT, 2022.09.17:
+ * - TAI(Temps Atomique International)
+ *   국제원자시.
+ */
         {
             .index = HRTIMER_BASE_TAI,
             .clockid = CLOCK_TAI,
@@ -113,6 +130,11 @@ DEFINE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases) =
     }
 };
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - 0 ~ 15까지 HRTIMER_MAX_CLOCK_BASES초기화를 해놓고, posix의 4가지에 대해서
+ *   kernel에 대응하는걸로 정의해놓는다.
+ */
 static const int hrtimer_clock_to_base_table[MAX_CLOCKS] = {
     /* Make sure we catch unsupported clockids */
     [0 ... MAX_CLOCKS - 1]    = HRTIMER_MAX_CLOCK_BASES,
@@ -161,6 +183,10 @@ static inline bool is_migration_base(struct hrtimer_clock_base *base)
  * possible to set timer->base = &migration_base and drop the lock: the timer
  * remains locked.
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - migration중이면 loop를 돌면서 확인한다.
+ */
 static
 struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
                          unsigned long *flags)
@@ -189,6 +215,15 @@ struct hrtimer_clock_base *lock_hrtimer_base(const struct hrtimer *timer,
  *
  * Called with cpu_base->lock of target cpu held.
  */
+/*
+ * IAMROOT, 2022.09.17: 
+ * @return true migrate 불가
+ *         false migrate 가능.
+ *
+ * 해당 cpu에서 대기 중인 타이머보다 더 앞쪽에 추가할 수 없으므로 
+ * 이를 확인한다. 안전하게 뒤로 들어갈 수 있으면 0을 반환하고,
+ * 그렇지 않은 경우 1을 반환하여 외부 루틴에서 다시 cpu를 선택해야 한다.
+ */
 static int
 hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base)
 {
@@ -198,6 +233,12 @@ hrtimer_check_target(struct hrtimer *timer, struct hrtimer_clock_base *new_base)
     return expires < new_base->cpu_base->expires_next;
 }
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * hrtimer가 등록될 새로운 cpu를 찾는 경우이다.
+ * nohz가 적용된 시스템에서 pinned 요청이 없으면 this cpu(우선 처리) 및 
+ * 주변 cpu들 중 busy한 cpu를 선택한다.
+ */
 static inline
 struct hrtimer_cpu_base *get_target_base(struct hrtimer_cpu_base *base,
                      int pinned)
@@ -230,6 +271,11 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
     int basenum = base->index;
 
     this_cpu_base = this_cpu_ptr(&hrtimer_bases);
+/*
+ * IAMROOT, 2022.09.17: 
+ * nohz가 적용된 시스템이라면 현재 cpu(우선순위) 또는 다른 busy한 cpu를 
+ * 찾아서 변경할 수 있다. (pinned=0인 경우에만)
+ */
     new_cpu_base = get_target_base(this_cpu_base, pinned);
 again:
     new_base = &new_cpu_base->clock_base[basenum];
@@ -244,14 +290,28 @@ switch_hrtimer_base(struct hrtimer *timer, struct hrtimer_clock_base *base,
          * completed. There is no conflict as we hold the lock until
          * the timer is enqueued.
          */
+/*
+ * IAMROOT, 2022.09.17: 
+ * 타이머가 만료되어 callback이 호출되는 중이된 경우엔 cpu base를 바꿔
+ * 등록할 필요가 없어졌으므로 이대로 base 변경없이 빠져나간다.
+ */
         if (unlikely(hrtimer_callback_running(timer)))
             return base;
 
         /* See the comment in lock_hrtimer_base() */
+/*
+ * IAMROOT, 2022.09.17: 
+ * 기존 cpu base의 락을 해지하고 새로운 cpu base에서 락을 획득한다.
+ */
         WRITE_ONCE(timer->base, &migration_base);
         raw_spin_unlock(&base->cpu_base->lock);
         raw_spin_lock(&new_base->cpu_base->lock);
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * cpu base가 현재 cpu로 바뀌지 않았고, 새로운 target으로 변경해야 하는 경우
+ * 현재 cpu로 바꿔서 again lable로 이동한다.
+ */
         if (new_cpu_base != this_cpu_base &&
             hrtimer_check_target(timer, new_base)) {
             raw_spin_unlock(&new_base->cpu_base->lock);
@@ -482,6 +542,10 @@ static inline void debug_deactivate(struct hrtimer *timer)
     trace_hrtimer_cancel(timer);
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - @active의 첫번째 bit에 대한 base를 return한다. return 되는 bit는 clear된다.
+ */
 static struct hrtimer_clock_base *
 __next_base(struct hrtimer_cpu_base *cpu_base, unsigned int *active)
 {
@@ -490,6 +554,10 @@ __next_base(struct hrtimer_cpu_base *cpu_base, unsigned int *active)
     if (!*active)
         return NULL;
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - 현재 idx를 구하고, active에서 idx를 뺀값으로 갱신한다.
+ */
     idx = __ffs(*active);
     *active &= ~(1U << idx);
 
@@ -499,6 +567,11 @@ __next_base(struct hrtimer_cpu_base *cpu_base, unsigned int *active)
 #define for_each_active_base(base, cpu_base, active)    \
     while ((base = __next_base((cpu_base), &(active))))
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - @expires_next보다 빠른 expire를 구하는걸 시도한다.
+ * 
+ */
 static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
                      const struct hrtimer *exclude,
                      unsigned int active,
@@ -521,7 +594,16 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
 
             timer = container_of(next, struct hrtimer, node);
         }
+/*
+ * IAMROOT, 2022.09.17:
+ * - base의 기준 offset시간을 뺀 시각이 실제 expire 시각.
+ */
         expires = ktime_sub(hrtimer_get_expires(timer), base->offset);
+
+/*
+ * IAMROOT, 2022.09.17:
+ * - 가장 빠른 expire 시각이면 갱ㄷ신한다.
+ */
         if (expires < expires_next) {
             expires_next = expires;
 
@@ -529,6 +611,10 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
             if (exclude)
                 continue;
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - soft면 soft, hard면 hard측을 갱신한다.
+ */
             if (timer->is_soft)
                 cpu_base->softirq_next_timer = timer;
             else
@@ -540,6 +626,14 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
      * the clock bases so the result might be negative. Fix it up
      * to prevent a false positive in clockevents_program_event().
      */
+
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   clock_was_set()이 클럭 베이스의 base->offset을 변경했을 수 있으므로 결과가
+ *   음수일 수 있습니다. clockevents_program_event()에서 거짓 긍정을 방지하도록
+ *   수정하십시오.
+ */
     if (expires_next < 0)
         expires_next = 0;
     return expires_next;
@@ -565,6 +659,48 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base,
  *  - HRTIMER_ACTIVE_SOFT, or
  *  - HRTIMER_ACTIVE_HARD.
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   cpu_base를 다시 계산합니다.::*next_timer 및 가장 빠른 expires_next를
+ *   반환하지만 cpu_base는 설정하지 않습니다. ::*expires_next, 이는
+ *   hrtimer[_force]_reprogram 및 hrtimer_interrupt에서만 수행됩니다.
+ *   cpu_base를 업데이트할 때:: *expires_next 즉시 재프로그래밍 로직이 작동하지
+ *   않습니다.
+ *
+ *   softirq가 보류 중인 경우 HRTIMER_ACTIVE_SOFT 기반을 무시할 수 있습니다.
+ *   해당 타이머는 softirq가 처리될 때마다 실행되고 hrtimer_run_softirq()가 끝날
+ *   때 hrtimer_update_softirq_timer()가 이러한 기반을 다시 추가합니다. 
+ *
+ *   따라서 softirq 값은 HRTIMER_ACTIVE_SOFT 클럭 기반의 값입니다.
+ *   !softirq 값은 실제 softirq가 보류 중인 경우(이 경우 HRTIMER_ACTIVE_HARD의
+ *   최소값)가 아닌 한 HRTIMER_ACTIVE_ALL 전체의 최소값입니다.
+ *
+ * - @active_mask 요청이 8개의 클럭들 중 soft, hard 또는 all로 요청을 하는데
+ *   해당 클럭에 대한 base들에 대해서 가장 빠른 타이머를 구한다.
+ *   각 clock base들은 각각의 offset을 가진 시각으로 관리되므로 8개 clock base에
+ *   등록된 타이머들과의 비교에는 각각의 offset을 뺀 값으로 비교되어야 한다.
+ *
+ * 예) 2개의 clock base에 있는 next 타이머들 중 빠른 타이머를 가려본다.
+ *      A) clock base->offset=1000, base->next_timer=3000
+ *      B) clock base->offset=3000, base->next_timer=4000
+ *
+ *                                a)
+ *                 <-------------->
+ *      A .........|--------------*---------------->
+ *               offset          next_timr
+ *               1000              3000
+ *
+ *                                       b) 
+ *                                <------>
+ *      B ........................|------*--------->
+ *                              offset  next_timr
+ *                              3000    4000
+ *      위의 A, B 두 클럭에서 동작하는 타이머 중 가장 빨리 만료시각이 
+ *      다가오는 타이머는 b) 타이머이다.
+ *      a) timer는 3000 - 1000 = 2000 ns의 시간 후에 expire될 예정
+ *      b) timer는 4000 - 3000 = 1000 ns의 시간 후에 expire될 예정
+ */
 static ktime_t
 __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, unsigned int active_mask)
 {
@@ -573,6 +709,10 @@ __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, unsigned int active_
     ktime_t expires_next = KTIME_MAX;
 
     if (!cpu_base->softirq_activated && (active_mask & HRTIMER_ACTIVE_SOFT)) {
+/*
+ * IAMROOT, 2022.09.17:
+ * - soft base중에 actvie중인 base.
+ */
         active = cpu_base->active_bases & HRTIMER_ACTIVE_SOFT;
         cpu_base->softirq_next_timer = NULL;
         expires_next = __hrtimer_next_event_base(cpu_base, NULL,
@@ -591,6 +731,12 @@ __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, unsigned int active_
     return expires_next;
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - soft일 경우 softirq_next_timer, hard일 경우 next_timer를 update한다.
+ *   softirq가 동작중일때는 hard base clock들중에서 가장 expire 시간을 가져온다.
+ *   그렇지 않을 경우 둘중에 가장빠른 expire 시간을 가져온다.
+ */
 static ktime_t hrtimer_update_next_event(struct hrtimer_cpu_base *cpu_base)
 {
     ktime_t expires_next, soft = KTIME_MAX;
@@ -600,6 +746,10 @@ static ktime_t hrtimer_update_next_event(struct hrtimer_cpu_base *cpu_base)
      * soft bases. They will be handled in the already raised soft
      * interrupt.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - soft irq요청이 된게 없는 상황.  softirq_expires_next를 갱신한다.
+ */
     if (!cpu_base->softirq_activated) {
         soft = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_SOFT);
         /*
@@ -614,6 +764,10 @@ static ktime_t hrtimer_update_next_event(struct hrtimer_cpu_base *cpu_base)
      * If a softirq timer is expiring first, update cpu_base->next_timer
      * and program the hardware with the soft expiry time.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - softirq가 activate 아닐때만 hard, soft중에 빠른걸로 갱신한다.
+ */
     if (expires_next > soft) {
         cpu_base->next_timer = cpu_base->softirq_next_timer;
         expires_next = soft;
@@ -641,6 +795,10 @@ static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base)
 /*
  * Is the high resolution mode active ?
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - hres가 동작중인지의 여부.
+ */
 static inline int __hrtimer_hres_active(struct hrtimer_cpu_base *cpu_base)
 {
     return IS_ENABLED(CONFIG_HIGH_RES_TIMERS) ?
@@ -652,6 +810,10 @@ static inline int hrtimer_hres_active(void)
     return __hrtimer_hres_active(this_cpu_ptr(&hrtimer_bases));
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - force reporgram을 수행한다. hres을 미지원하거나 hang중이면 안한다.
+ */
 static void __hrtimer_reprogram(struct hrtimer_cpu_base *cpu_base,
                 struct hrtimer *next_timer,
                 ktime_t expires_next)
@@ -675,9 +837,31 @@ static void __hrtimer_reprogram(struct hrtimer_cpu_base *cpu_base,
      * set. So we'd effectively block all timers until the T2 event
      * fires.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   hres가 활성 상태가 아니면 하드웨어를 아직 다시 프로그래밍할 필요가 없습니다.
+ *
+ *   마지막 타이머 인터럽트에서 hang이 감지되면 하드웨어에서 hang delay을 활성
+ *   상태로 둡니다. 우리는 시스템이 발전하기를 바랍니다. 또한 다음 시나리오를
+ *   방지합니다.
+ *
+ *   scenario:
+ *   T1은 지금부터 50ms 후에 만료됩니다.
+ *   T2는 지금부터 5초 후에 만료됩니다.
+ *
+ *   따라서 이 코드가 호출되고 하드웨어를 지금부터 5초로 다시 프로그래밍합니다.
+ *   그 이후의 hrtimer_start는 hang_detected가 설정되어 있기 때문에 하드웨어를
+ *   다시 프로그래밍하지 않습니다. 따라서 T2 이벤트가 발생할 때까지 모든 타이머를
+ *   효과적으로 차단합니다.
+ */
     if (!__hrtimer_hres_active(cpu_base) || cpu_base->hang_detected)
         return;
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - expires_next로 force reprogram 요청.
+ */
     tick_program_event(expires_next, 1);
 }
 
@@ -686,6 +870,10 @@ static void __hrtimer_reprogram(struct hrtimer_cpu_base *cpu_base,
  * next event
  * Called with interrupts disabled and base->lock held
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - force reprogram.
+ */
 static void
 hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
 {
@@ -693,6 +881,11 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal)
 
     expires_next = hrtimer_update_next_event(cpu_base);
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - update후 가져온 expire시간이 변경되지 않았다면 return.
+ *   그게 아니라면 reporgram.
+ */
     if (skip_equal && expires_next == cpu_base->expires_next)
         return;
 
@@ -805,6 +998,23 @@ static void retrigger_next_event(void *arg)
  *
  * Called with interrupts disabled and base->cpu_base.lock held
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - timer reprogram을 수행한다.
+ * - reprogram을 하지 않은 경우
+ *   1. @timer가 soft irq일때
+ *   1-1. soft irq가 activate일 경우 : soft irq가 끝나고 알아서 처리할것이므로 여기서
+ *                                안한다.
+ *   1-2. @timer의 softirq_expires_next보다 느린 경우.
+ *   1-3. @timer의 hard base clock보다 느린 경우.
+ *   1-4. @reprogram요청이 없는 경우.
+ *
+ *   2. hard, soft 둘다 해당.
+ *   2-1 @timer->base의 cpu_base와 this_cpu base와 같지 않은 경우
+ *        : 해당 cpu에서 언젠가 처리할것이므로 안함.
+ *   2-2 this cpu base의 hard base clock보다 느린 경우.
+ *   2-3 hrtimer가 expire 진행중인 경우 : 끝나면 알아서 reevaluate를 할것이다.
+ */
 static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
 {
     struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
@@ -820,6 +1030,14 @@ static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
     if (expires < 0)
         expires = 0;
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - return
+ * 1. activated중. 
+ * 2. 현재 등록된 softirq_expires_next보다 이후라면.
+ * 3. softirq next를 갱신하고나서, 현재 등록된 hardirq보다 이후라면 return.
+ * 4. reporgram 요청이 없으면 return.
+ */
     if (timer->is_soft) {
         /*
          * soft hrtimer could be started on a remote CPU. In this
@@ -828,6 +1046,14 @@ static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
          * first hard hrtimer on the remote CPU -
          * hrtimer_check_target() prevents this case.
          */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   soft hrtimer는 원격 CPU에서 시작할 수 있습니다. 이 경우 원격 CPU에서
+ *   softirq_expires_next를 업데이트해야 합니다. 소프트 hrtimer는 원격 CPU의
+ *   첫 번째 하드 hrtimer 전에 만료되지 않습니다. hrtimer_check_target()은
+ *   이 경우를 방지합니다.
+ */
         struct hrtimer_cpu_base *timer_cpu_base = base->cpu_base;
 
         if (timer_cpu_base->softirq_activated)
@@ -836,6 +1062,10 @@ static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
         if (!ktime_before(expires, timer_cpu_base->softirq_expires_next))
             return;
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - expires가 가장빠른 softirq_expires_next보다 빠른상태이므로 갱신해준다.
+ */
         timer_cpu_base->softirq_next_timer = timer;
         timer_cpu_base->softirq_expires_next = expires;
 
@@ -844,10 +1074,18 @@ static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
             return;
     }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - 여기까지 왔을때 hard base clock보다 빠른상태일 것이다.
+ */
     /*
      * If the timer is not on the current cpu, we cannot reprogram
      * the other cpus clock event device.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - @timer의 base 와 this cpu의 base가 같은 경우에만 reprogram 가능.
+ */
     if (base->cpu_base != cpu_base)
         return;
 
@@ -858,6 +1096,11 @@ static void hrtimer_reprogram(struct hrtimer *timer, bool reprogram)
      * If the hrtimer interrupt is running, then it will reevaluate the
      * clock bases and reprogram the clock event device.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - 이미 hrtimer가 expire되서 진행되고 있는 경우. 끝나면 어짜피 reevaluate를
+ *   할거이므로 그냥 return.
+ */
     if (cpu_base->in_hrtirq)
         return;
 
@@ -1077,17 +1320,33 @@ EXPORT_SYMBOL_GPL(hrtimer_forward);
  *
  * Returns 1 when the new timer is the leftmost timer in the tree.
  */
+/*
+ * IAMROOT, 2022.09.17: 
+ * clock base의 RB 트리 자료구조에 hrtimer를 추가한다.
+ * clock base의 hrtimer들 중 가장 빠른 만료시간을 가진 경우라면 1을 반환한다. 
+ */
+
 static int enqueue_hrtimer(struct hrtimer *timer,
                struct hrtimer_clock_base *base,
                enum hrtimer_mode mode)
 {
     debug_activate(timer, mode);
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 8개의 clock base 비트맵인 active_bases에서 해당 clock base의 비트를
+ * set한다. 타이머가 추가된 상태라면 해당 clock base에 hrtimer가 
+ * 존재함을 의미한다.
+ */
     base->cpu_base->active_bases |= 1 << base->index;
 
     /* Pairs with the lockless read in hrtimer_is_queued() */
     WRITE_ONCE(timer->state, HRTIMER_STATE_ENQUEUED);
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 등록된 hrtimer가 가장 빠른 타이머로 등록되는 경우 1을 반환된다.
+ */
     return timerqueue_add(&base->active, &timer->node);
 }
 
@@ -1101,6 +1360,19 @@ static int enqueue_hrtimer(struct hrtimer *timer,
  * reprogram to zero. This is useful, when the context does a reprogramming
  * anyway (e.g. timer interrupt)
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   __remove_hrtimer - 타이머를 제거하는 내부 함수.
+ *
+ *   caller base lock을 잡고 있어야 합니다.
+ *
+ *   고해상도 타이머 모드는 타이머가 다음에 만료되는 타이머일 때 clock event device를
+ *   다시 프로그래밍합니다. 호출자는 reprogram을 0으로 설정하여 이를 비활성화할
+ *   수 있습니다. 이것은 컨텍스트가 어쨌든 재프로그래밍을 수행할 때
+ *   (예: 타이머 인터럽트) 유용합니다.
+ *
+ */
 static void __remove_hrtimer(struct hrtimer *timer,
                  struct hrtimer_clock_base *base,
                  u8 newstate, int reprogram)
@@ -1113,6 +1385,10 @@ static void __remove_hrtimer(struct hrtimer *timer,
     if (!(state & HRTIMER_STATE_ENQUEUED))
         return;
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - 삭제했는데 비어있다면. 즉 첫 timer라면 bitmap에서 해당 base의 bit를 clear 해준다.
+ */
     if (!timerqueue_del(&base->active, &timer->node))
         cpu_base->active_bases &= ~(1 << base->index);
 
@@ -1124,6 +1400,15 @@ static void __remove_hrtimer(struct hrtimer *timer,
      * an superfluous call to hrtimer_force_reprogram() on the
      * remote cpu later on if the same timer gets enqueued again.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papgo
+ *   Note: reprogram이 false이면 cpu_base->next_timer를 업데이트하지 않습니다.
+ *   이것은 remote CPU에서 첫 번째 타이머를 제거할 때 발생합니다.
+ *   cpu_base->next_timer를 역참조하지 않으므로 아무런 해가 없습니다. 따라서 발생할
+ *   수 있는 최악의 상황은 나중에 동일한 타이머가 다시 대기열에 추가될 경우 원격
+ *   CPU에서 hrtimer_force_reprogram()을 불필요하게 호출하는 것입니다.
+ */
     if (reprogram && timer == cpu_base->next_timer)
         hrtimer_force_reprogram(cpu_base, 1);
 }
@@ -1131,6 +1416,10 @@ static void __remove_hrtimer(struct hrtimer *timer,
 /*
  * remove hrtimer, called with base lock held
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - 
+ */
 static inline int
 remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base,
            bool restart, bool keep_local)
@@ -1148,6 +1437,16 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base,
          * reprogramming happens in the interrupt handler. This is a
          * rare case and less expensive than a smp call.
          */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   고해상도 모드가 활성화되고 타이머가 현재 CPU에 있을 때 타이머를 제거하고
+ *   강제로 재프로그래밍합니다. 다른 CPU에서 타이머를 제거하면 재프로그래밍을
+ *   건너뜁니다. 이 CPU의 인터럽트 이벤트가 발생하고 인터럽트 핸들러에서
+ *   재프로그래밍이 발생합니다. 이것은 드문 경우이며 smp 호출보다 저렴합니다.*
+ *
+ * - @base가 this_cpu base인 경우 reprogram을 수행한다.
+ */
         debug_deactivate(timer);
         reprogram = base->cpu_base == this_cpu_ptr(&hrtimer_bases);
 
@@ -1157,6 +1456,19 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base,
          * to be restarted, avoid programming it twice (on removal
          * and a moment later when it's requeued).
          */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   타이머가 다시 시작되지 않으면 타이머가 로컬이면 다시 프로그래밍해야 합니다.
+ *   로컬이고 다시 시작하려고 하는 경우 두 번 프로그래밍하지 마십시오(제거 시와
+ *   잠시 후 다시 큐에 추가됨).
+ *
+ * - reporgram이 이전에 true였을경우(this_cpu와 @base가 동일한상태)
+ *   계속 true가 되는 상태.
+ *   1. restart요청을 안한 경우.
+ *   2. keep_local이 false인 경우.(true라면 여기서 reporgram을 안하고 불렀던
+ *   곳에서 reprogram을 수행할것이다.)
+ */
         if (!restart)
             state = HRTIMER_STATE_INACTIVE;
         else
@@ -1171,6 +1483,11 @@ remove_hrtimer(struct hrtimer *timer, struct hrtimer_clock_base *base,
 static inline ktime_t hrtimer_update_lowres(struct hrtimer *timer, ktime_t tim,
                         const enum hrtimer_mode mode)
 {
+/*
+ * IAMROOT, 2022.09.17: 
+ * 낮은 해상도를 가진 타이머를 사용하는 시스템에서는 상대 시간 요청으로 
+ * 타이머를 등록한 경우 타이머가 처리할 수 있는 최하 해상도를 추가합니다.
+ */
 #ifdef CONFIG_TIME_LOW_RES
     /*
      * CONFIG_TIME_LOW_RES indicates that the system has no way to return
@@ -1209,6 +1526,10 @@ hrtimer_update_softirq_timer(struct hrtimer_cpu_base *cpu_base, bool reprogram)
     hrtimer_reprogram(cpu_base->softirq_next_timer, reprogram);
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - 타이머를 새롭게 추가하여 시작 or 만료 시각을 변경하는 경우.
+ */
 static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
                     u64 delta_ns, const enum hrtimer_mode mode,
                     struct hrtimer_clock_base *base)
@@ -1224,7 +1545,25 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
      * and enforce reprogramming after it is queued no matter whether
      * it is the new first expiring timer again or not.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   타이머가 로컬 CPU 기반에 있고 첫 번째 만료 타이머인 경우 하드웨어를
+ *   두 번(제거 및 대기열에 넣을 때) 다시 프로그래밍하게 될 수 있습니다. 제거 시
+ *   재프로그래밍을 방지하여 이를 방지하려면 타이머를 현재 CPU에 로컬로 유지하고
+ *   새로운 첫 번째 만료 타이머인지 여부에 관계없이 대기열에 넣은 후 재프로그래밍을
+ *   시행하십시오.
+ * - lock걸고 들어온 base가 현재 cpu인지 force_local에 저장한다.
+ */
     force_local = base->cpu_base == this_cpu_ptr(&hrtimer_bases);
+
+/*
+ * IAMROOT, 2022.09.17:
+ * - next_timer(가장 빠른 timer)인 경우인지를 한번더 확인한다.
+ *  
+ * - 이미 등록된 가장 만료시각이 빠른 타이머의 만료시각을 변경하러 들어온
+ *   force_local=1이 된다.(조건은 cpu가 변경되지 않았다는 것)
+ */
     force_local &= base->cpu_base->next_timer == timer;
 
     /*
@@ -1238,16 +1577,52 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
      * avoids programming the underlying clock event twice (once at
      * removal and once after enqueue).
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   대기열에서 활성 타이머를 제거합니다. 현재 CPU에 대기 중이 아닌 경우
+ *   remove_hrtimer()가 원격 데이터를 올바르게 업데이트하는지 확인하십시오.
+ *
+ *   현재 CPU에 있고 첫 번째 만료 타이머에 있는 경우 재프로그래밍을 건너뛰고
+ *   타이머를 로컬로 유지하고 첫 번째 만료 타이머인 경우 나중에 재프로그래밍을
+ *   시행합니다. 이렇게 하면 기본 클록 이벤트를 두 번(제거 시 한 번, 대기열에
+ *   넣은 후 한 번) 프로그래밍하지 않아도 됩니다.
+ *
+ * - force_local이 false라면 remove_hrtimer()안에서 reprogram, true라면 현재함수
+ *   맨 뒤에서 reprogram을 수행한다.
+ *   두번 reprogram을 할 수 있는 경우를 방지하는것.
+ */
     remove_hrtimer(timer, base, true, force_local);
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 상대 시간을 요청한 경우 clock base에서 현재 시각을 알아온 후 요청한 @time을
+ * 더해 절대 시각을 구한다.
+ */
     if (mode & HRTIMER_MODE_REL)
         tim = ktime_add_safe(tim, base->get_time());
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 고해상도 타이머에서는 @tim 값이 변경되지 않지만,
+ * 저해상도 타이머를 사용하는 시스템에서는 최하 해상도 단위 값을 추가합니다.
+ */
     tim = hrtimer_update_lowres(timer, tim, mode);
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 타이머의 만료시각(softexpires)과 연장가능한 슬랙 타임이 추가된 
+ *          만료시각(node.expires)를 지정한다.
+ * 최소 softexpires에서부터 최대 node.expires까지 만료될 수 있다.
+ */
     hrtimer_set_expires_range_ns(timer, tim, delta_ns);
 
     /* Switch the timer base, if necessary: */
+/*
+ * IAMROOT, 2022.09.17: 
+ * 반드시 local cpu에서 처리해야하는 경우가 아니면 필요에 따라 cpu를 
+ * 스위치 할 수 있다.
+ */
     if (!force_local) {
         new_base = switch_hrtimer_base(timer, base,
                            mode & HRTIMER_MODE_PINNED);
@@ -1255,6 +1630,12 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
         new_base = base;
     }
 
+/*
+ * IAMROOT, 2022.09.17: 
+ * 등록된 hrtimer가 가장 빠른(first) 타이머로 등록되는 경우 1을 반환된다.
+ * force_local이 0인 경우에는 first 여부를 반환하여 리프로그램 여부를
+ * 결정합니다.
+ */
     first = enqueue_hrtimer(timer, new_base, mode);
     if (!force_local)
         return first;
@@ -1264,6 +1645,10 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
      * reprogramming on removal and enqueue. Force reprogram the
      * hardware by evaluating the new first expiring timer.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - 현재 cpu에서 반드시 처리해야되는 경우. reprogramming.
+ */
     hrtimer_force_reprogram(new_base->cpu_base, 1);
     return 0;
 }
@@ -1277,6 +1662,28 @@ static int __hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
  *        relative (HRTIMER_MODE_REL), and pinned (HRTIMER_MODE_PINNED);
  *        softirq based mode is considered for debug purpose only!
  */
+/*
+ * IAMROOT, 2022.09.17: 
+ * 타이머 시작은 @tim 시각에 expire될 예정으로 등록되는데, 
+ * @delta_ns를 0으로 요청하면 정확히 해당 시각에 expire되고,
+ * 이 값이 별도의 slack 시간으로 주어지면 slack시간 만큼 깨어나는 시각을
+ * 유보할수있다. 즉 다른 타이머로 인해 등록한 타이머까지 같이 깨어날 수 있습니다.
+ *
+ * 이 시간을 슬랙 타임이라고 하는데 슬랙이 적용되면 여러 개의 타이머 
+ * 인터럽트들을 영역이 겹치는 시각에 모두 expire 시킬 수 있습니다.
+ *
+ * 예) *=expire 시각, <---------- 범위가 슬랙시간을 주어준 경우 
+ *
+ *                                    한꺼번에 expire
+ *                                      |
+ *    timer 1)               <----------|-----*
+ *    timer 2)                       <--|---------------*
+ *    timer 3)                          |  <-----*
+ *    timer 4)                  <-------*
+ * 
+ *    위의 4 타이머들 중 4)번 타이머가 가장 먼저 꺠어나게 되는데
+ *    슬랙 범위안에 든 타이머 1), 2) 4)번을 같이 깨워 처리합니다.
+ */
 void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
                 u64 delta_ns, const enum hrtimer_mode mode)
 {
@@ -1288,6 +1695,13 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
      * match on CONFIG_PREEMPT_RT = n. With PREEMPT_RT check the hard
      * expiry mode because unmarked timers are moved to softirq expiry.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - 일반 kernel
+ *   soft 요청과 is_soft가 일치해야된다.
+ * - rt kernel
+ *   hard 요청과 is_hard가 일치해야된다.
+ */
     if (!IS_ENABLED(CONFIG_PREEMPT_RT))
         WARN_ON_ONCE(!(mode & HRTIMER_MODE_SOFT) ^ !timer->is_soft);
     else
@@ -1295,6 +1709,10 @@ void hrtimer_start_range_ns(struct hrtimer *timer, ktime_t tim,
 
     base = lock_hrtimer_base(timer, &flags);
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - return 0인경우 이미 reprogram을 한상태이다.
+ */
     if (__hrtimer_start_range_ns(timer, tim, delta_ns, mode, base))
         hrtimer_reprogram(timer, true);
 
@@ -1435,6 +1853,10 @@ static inline void hrtimer_sync_wait_running(struct hrtimer_cpu_base *base,
  *  0 when the timer was not active
  *  1 when the timer was active
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - TODO
+ */
 int hrtimer_cancel(struct hrtimer *timer)
 {
     int ret;
@@ -1526,6 +1948,10 @@ u64 hrtimer_next_event_without(const struct hrtimer *exclude)
 }
 #endif
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - clock_id를 kernel에서 사용하는 base로 변경한다.
+ */
 static inline int hrtimer_clockid_to_base(clockid_t clock_id)
 {
     if (likely(clock_id < MAX_CLOCKS)) {
@@ -1534,10 +1960,23 @@ static inline int hrtimer_clockid_to_base(clockid_t clock_id)
         if (likely(base != HRTIMER_MAX_CLOCK_BASES))
             return base;
     }
+/*
+ * prifri, 2022.09.17:
+ * - 할당이 안된 clock_id. monotonic으로 고정시켜버린다.
+ */
     WARN(1, "Invalid clockid %d. Using MONOTONIC\n", clock_id);
     return HRTIMER_BASE_MONOTONIC;
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ *                   |           CONFIG_PREEMPT_RT             |
+ *                   |       false       |       true        |
+ *                   | is_soft   is_hard | is_soft   is_hard |
+ *     OPTION 없음   | false   | false   | true    | false   |
+ * HRTIMER_MODE_SOFT | true    | false   | true    | false   |
+ * HRTIMER_MODE_HARD | false   | true    | false   | true    |
+ */
 static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
                enum hrtimer_mode mode)
 {
@@ -1551,6 +1990,26 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
      * interrupt context for latency reasons and because the callbacks
      * can invoke functions which might sleep on RT, e.g. spin_lock().
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - papago
+ *   PREEMPT_RT가 활성화된 커널에서 명시적으로 하드 인터럽트 만료 모드로 표시되지
+ *   않은 hrtimer는 대기 시간과 콜백이 RT에서 휴면할 수 있는 기능을 호출할 수 있기
+ *   때문에 소프트 인터럽트 컨텍스트로 이동됩니다. spin_lock().
+ *
+ * - 사용자 요청에 상관없이. preempt rt kernel이면,  HRTIMER_MODE_HARD가
+ *   아닐대 softtimer로 고정한다.
+ * ---
+ * - 기존 kernel
+ *   hrtimer는 hard irq에서 무조건 동작
+ *
+ * - 현재 kernel
+ *   rt 에서는 hard로 요청하지 않는한 soft irq로 동작.
+ *
+ * - hard irq : isr에서 timer에서 등록되있는 callback 호출.
+ *   soft irq : isr에서 soft irq raise를 시켜서 soft irq task(bottomhalf)가
+ *              callback 호출
+ */
     if (IS_ENABLED(CONFIG_PREEMPT_RT) && !(mode & HRTIMER_MODE_HARD))
         softtimer = true;
 
@@ -1563,11 +2022,28 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
      * clock modifications, so they needs to become CLOCK_MONOTONIC to
      * ensure POSIX compliance.
      */
+/*
+ * IAMROOT, 2022.09.17:
+ * - user측에서 잘못 설정(realtime을 기준으로 relative 요청)
+ *   MONOTONIC 기준으로 하는게 정상이므로(realtime이 임의로 바뀔경우
+ *   오류동작 하기 때문에) 바꿔준다.
+ */
     if (clock_id == CLOCK_REALTIME && mode & HRTIMER_MODE_REL)
         clock_id = CLOCK_MONOTONIC;
 
+/*
+ * prifri, 2022.09.17:
+ * - softimer 요청이면 HRTIMER_BASE_MONOTONIC_SOFT(4)를 base로, 아니면
+ *   HRTIMER_BASE_MONOTONIC(0)를 base로 시작한다.
+ */
     base = softtimer ? HRTIMER_MAX_CLOCK_BASES / 2 : 0;
+
+/*
+ * IAMROOT, 2022.09.17:
+ * - clock_id(9개)를 기준으로 monotonic, realtime,boottime, tai(2 * 4개)를 고른다.
+ */
     base += hrtimer_clockid_to_base(clock_id);
+
     timer->is_soft = softtimer;
     timer->is_hard = !!(mode & HRTIMER_MODE_HARD);
     timer->base = &cpu_base->clock_base[base];
@@ -1586,6 +2062,10 @@ static void __hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
  *              but the PINNED bit is ignored as pinning happens
  *              when the hrtimer is started
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - hrtimer 초기화.
+ */
 void hrtimer_init(struct hrtimer *timer, clockid_t clock_id,
           enum hrtimer_mode mode)
 {
@@ -1753,6 +2233,10 @@ static void __hrtimer_run_queues(struct hrtimer_cpu_base *cpu_base, ktime_t now,
     }
 }
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - TODO
+ */
 static __latent_entropy void hrtimer_run_softirq(struct softirq_action *h)
 {
     struct hrtimer_cpu_base *cpu_base = this_cpu_ptr(&hrtimer_bases);
@@ -2157,6 +2641,10 @@ SYSCALL_DEFINE2(nanosleep_time32, struct old_timespec32 __user *, rqtp,
 /*
  * Functions related to boot-time initialization:
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * - 자료구조 초기화
+ */
 int hrtimers_prepare_cpu(unsigned int cpu)
 {
     struct hrtimer_cpu_base *cpu_base = &per_cpu(hrtimer_bases, cpu);
@@ -2261,6 +2749,10 @@ int hrtimers_dead_cpu(unsigned int scpu)
 
 #endif /* CONFIG_HOTPLUG_CPU */
 
+/*
+ * IAMROOT, 2022.09.17:
+ * - hrtimers init.
+ */
 void __init hrtimers_init(void)
 {
     hrtimers_prepare_cpu(smp_processor_id());
diff --git a/lib/timerqueue.c b/lib/timerqueue.c
index cdb9c7658478..8034bfda310a 100644
--- a/lib/timerqueue.c
+++ b/lib/timerqueue.c
@@ -32,6 +32,11 @@ static inline bool __timerqueue_less(struct rb_node *a, const struct rb_node *b)
  * value. Returns true if the newly added timer is the first expiring timer in
  * the queue.
  */
+/*
+ * IAMROOT, 2022.09.17: 
+ * 추가된 노드가 가장 빠른 leftmost에 등록된 경우 true를 반환하고,
+ * 그렇지 않은 경우 false를 반환한다.
+ */
 bool timerqueue_add(struct timerqueue_head *head, struct timerqueue_node *node)
 {
     /* Make sure we don't add nodes that are already added */
@@ -50,6 +55,10 @@ EXPORT_SYMBOL_GPL(timerqueue_add);
  * Removes the timer node from the timerqueue. Returns true if the queue is
  * not empty after the remove.
  */
+/*
+ * IAMROOT, 2022.09.17:
+ * @return 삭제후 rbtree가 비어있으면 false. 한개라도 있으면 true
+ */
 bool timerqueue_del(struct timerqueue_head *head, struct timerqueue_node *node)
 {
     WARN_ON_ONCE(RB_EMPTY_NODE(&node->node));
 

번호 제목 글쓴이 날짜 조회 수
공지 [공지] 스터디 정리 노트 공간입니다. woos 2016.05.14 626
167 [커널 18차] 80주차 kkr 2022.12.03 156
166 [커널 19차] 28 ~ 29 주차 Min 2022.12.03 35
165 [커널 19차] 27 주차 Min 2022.11.22 82
164 [커널 18차] 78주차 kkr 2022.11.19 187
163 [커널 19차] 25 ~ 26 주차 Min 2022.11.14 72
162 [커널 18차] 76-77주차 kkr 2022.11.12 386
161 [커널 19차] 24주차 Min 2022.10.31 108
160 [커널 17차] 112주차 ㅇㅇㅇ 2022.10.30 81
159 [커널 18차] 75주차 kkr 2022.10.29 40
158 [커널 17차] 107 ~ 111주차 ㅇㅇㅇ 2022.10.23 77
157 [커널 19차] 22주차 Min 2022.10.17 76
156 [커널 18차] 73주차 kkr 2022.10.15 45
155 [커널 18차] 72주차 kkr 2022.10.09 183
154 [커널 18차] 71주차 kkr 2022.10.01 75
153 [커널 18차] 70주차 kkr 2022.09.24 77
» [커널 18차] 69주차 kkr 2022.09.22 58
151 [커널 17차] 105~106주차 ㅇㅇㅇ 2022.09.18 50
150 [커널 17차] 104주차 ㅇㅇㅇ 2022.09.04 88
149 [커널 18차] 67주차 kkr 2022.09.03 138
148 [커널 17차] 103주차 ㅇㅇㅇ 2022.08.28 35
XE Login