alarm: Remove IRQ alarms
authorBarret Rhoden <brho@cs.berkeley.edu>
Fri, 2 Nov 2018 01:40:45 +0000 (21:40 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Fri, 2 Nov 2018 01:51:48 +0000 (21:51 -0400)
The alarm code has some issues, and dealing with it will be easier with
only one type of alarm.

Right now, the tchain and the alarm RKMs are disconnected, but I think
we'll need to synchronize them a bit more.  It'll be simpler with just
one mechanism that runs outside of IRQ context.

We only had one user, so remove it isn't a big deal.  If we need IRQ
alarms, we can add them back in the future.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
kern/include/alarm.h
kern/src/alarm.c

index 127ba16..97933fc 100644 (file)
  * Timer chains (like off a per-core timer) are made of lists/trees of these. */
 struct alarm_waiter {
        uint64_t                                        wake_up_time;   /* ugh, this is a TSC for now */
-       union {
-               void (*func) (struct alarm_waiter *waiter);
-               void (*func_irq) (struct alarm_waiter *waiter,
-                                 struct hw_trapframe *hw_tf);
-       };
+       void (*func) (struct alarm_waiter *waiter);
        void                                            *data;
        TAILQ_ENTRY(alarm_waiter)       next;
-       bool                                            irq_ok;
        bool                                            on_tchain;
        bool                                            is_running;
        bool                                            no_rearm;
@@ -102,9 +97,6 @@ void init_timer_chain(struct timer_chain *tchain,
 /* For fresh alarm waiters.  func == 0 for kthreads */
 void init_awaiter(struct alarm_waiter *waiter,
                   void (*func) (struct alarm_waiter *));
-void init_awaiter_irq(struct alarm_waiter *waiter,
-                      void (*func_irq) (struct alarm_waiter *awaiter,
-                                        struct hw_trapframe *hw_tf));
 /* Sets the time an awaiter goes off */
 void set_awaiter_abs(struct alarm_waiter *waiter, uint64_t abs_time);
 void set_awaiter_rel(struct alarm_waiter *waiter, uint64_t usleep);
index 21afc53..168ceb9 100644 (file)
@@ -45,8 +45,11 @@ void init_timer_chain(struct timer_chain *tchain,
        reset_tchain_times(tchain);
 }
 
-static void __init_awaiter(struct alarm_waiter *waiter)
+void init_awaiter(struct alarm_waiter *waiter,
+                  void (*func) (struct alarm_waiter *awaiter))
 {
+       assert(func);
+       waiter->func = func;
        waiter->wake_up_time = ALARM_POISON_TIME;
        waiter->on_tchain = false;
        waiter->is_running = false;
@@ -54,25 +57,6 @@ static void __init_awaiter(struct alarm_waiter *waiter)
        cv_init_irqsave(&waiter->done_cv);
 }
 
-void init_awaiter(struct alarm_waiter *waiter,
-                  void (*func) (struct alarm_waiter *awaiter))
-{
-       waiter->irq_ok = FALSE;
-       assert(func);
-       waiter->func = func;
-       __init_awaiter(waiter);
-}
-
-void init_awaiter_irq(struct alarm_waiter *waiter,
-                      void (*func_irq) (struct alarm_waiter *awaiter,
-                                        struct hw_trapframe *hw_tf))
-{
-       waiter->irq_ok = TRUE;
-       assert(func_irq);
-       waiter->func_irq = func_irq;
-       __init_awaiter(waiter);
-}
-
 /* Give this the absolute time.  For now, abs_time is the TSC time that you want
  * the alarm to go off. */
 void set_awaiter_abs(struct alarm_waiter *waiter, uint64_t abs_time)
@@ -148,13 +132,8 @@ static void __run_awaiter(uint32_t srcid, long a0, long a1, long a2)
 static void wake_awaiter(struct alarm_waiter *waiter,
                          struct hw_trapframe *hw_tf)
 {
-       if (waiter->irq_ok) {
-               waiter->func_irq(waiter, hw_tf);
-               __finish_awaiter(waiter);
-       } else {
-               send_kernel_message(core_id(), __run_awaiter, (long)waiter,
-                                   0, 0, KMSG_ROUTINE);
-       }
+       send_kernel_message(core_id(), __run_awaiter, (long)waiter,
+                           0, 0, KMSG_ROUTINE);
 }
 
 /* This is called when an interrupt triggers a tchain, and needs to wake up
@@ -402,12 +381,8 @@ void print_chain(struct timer_chain *tchain)
               tchain->earliest_time,
               tchain->latest_time);
        TAILQ_FOREACH(i, &tchain->waiters, next) {
-               uintptr_t f;
+               uintptr_t f = (uintptr_t)i->func;
 
-               if (i->irq_ok)
-                       f = (uintptr_t)i->func_irq;
-               else
-                       f = (uintptr_t)i->func;
                printk("\tWaiter %p, time %llu, func %p (%s)\n", i,
                       i->wake_up_time, f, get_fn_name(f));
        }