Hello everyone.
When I use gdb to trace qemu-xen-traditional, I have a little doubt
about host_alarm_handler.  I already understand that it can implement
a dynamic tick, through tickless to save CPU cost. However,  I found
that the following code has never run when I use qemu-xen-traditional
with xen(See attachment master.cfg).
        if (env) {
            /* stop the currently executing cpu because a timer occured */
            cpu_interrupt(env, CPU_INTERRUPT_EXIT);
        }
So I wonder if this code is useful when I use xen?

Moreover, I use this following function host_alarm_handler_empty
instead of host_alarm_handler as SIGALRM signal handler. Then I change
dynticks_timer from one-shot timer to period timer, and set
ev.sigev_notify = SIGEV_NONE when I create dynticks_timer (See
attachment period_timer.patch). I found that no problem except for usb
mouse slowness.
static void host_alarm_handler_empty(int host_signum)
{
        return;
}
Finally, I use the following bash command to send the SIGALRM signal
to qemu-dm at 1ms intervals, the usb mouse also recovers fluency. I
can't understand how SIGALRM works, because SIGALRM just call
host_alarm_handler_empty  function?
# QEMU_PID=`pgrep qemu-dm`; while true; do kill -s SIGALRM $QEMU_PID;
sleep 0.001; done

I would appreciate it if anyone could provide me some ideas.
-------------------------------------------------------------
Thanks,
Lu
diff --git a/vl.c b/vl.c
index f9c4d7e..105ce6e 100644
--- a/vl.c
+++ b/vl.c
@@ -1340,6 +1340,11 @@ static int timer_load(QEMUFile *f, void *opaque, int version_id)
 void CALLBACK host_alarm_handler(UINT uTimerID, UINT uMsg,
                                  DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2)
 #else
+static void host_alarm_handler_empty(int host_signum)
+{
+	return;
+}
+
 static void host_alarm_handler(int host_signum)
 #endif
 {
@@ -1571,15 +1576,15 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t)
     struct sigevent ev = { { 0 } };
     timer_t host_timer;
     struct sigaction act;
+    struct itimerspec timeout;
 
     sigfillset(&act.sa_mask);
     act.sa_flags = 0;
-    act.sa_handler = host_alarm_handler;
+    act.sa_handler = host_alarm_handler_empty;
 
     sigaction(SIGALRM, &act, NULL);
 
-    ev.sigev_notify = SIGEV_SIGNAL;
-    ev.sigev_signo = SIGALRM;
+    ev.sigev_notify = SIGEV_NONE;
 
     if (timer_create(CLOCK_REALTIME, &ev, &host_timer)) {
         perror("timer_create");
@@ -1589,6 +1594,11 @@ static int dynticks_start_timer(struct qemu_alarm_timer *t)
 
         return -1;
     }
+    timeout.it_interval.tv_sec = 0;
+    timeout.it_interval.tv_nsec = 10000; /* 0 for one-shot timer */
+    timeout.it_value.tv_sec =  0;
+    timeout.it_value.tv_nsec = 10000;
+    timer_settime(host_timer, 0 /* RELATIVE */, &timeout, NULL);
 
     t->priv = (void *)(long)host_timer;
 
@@ -1604,6 +1614,7 @@ static void dynticks_stop_timer(struct qemu_alarm_timer *t)
 
 static void dynticks_rearm_timer(struct qemu_alarm_timer *t)
 {
+    return;
     timer_t host_timer = (timer_t)(long)t->priv;
     struct itimerspec timeout;
     int64_t nearest_delta_us = INT64_MAX;

Attachment: master.cfg
Description: Binary data

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to