Looking for folks that use the serial console connection in vmd(8) and
experience the host CPU spikes & delays associated with things like
hitting the up key (to cycle shell command history) or copy/paste in X.

vmd(8) approximates edge triggered interrupts with the emulated i8259
interrupt controller. Some core devices (serial console, rtc, timer) try
"toggling" an irq...but it's pointless in how our emulated i8259 is
implemented. The deassert does nothing for edge triggered interrupts
other than causing race conditions and extra syscalls.

I've tested on two of my machines and this resolves the issue I've been
seeing off and on. It should fix the report[1] on bugs@ from months ago.

-dv

[1] https://marc.info/?l=openbsd-bugs&m=169669132915760&w=2

diff refs/heads/master refs/heads/vmd-edge
commit - 7869b2fdaac7e118bfd1783874fe25ce3b8b0f09
commit + 00d448cdbe2461f27419aaf79520a0cef720aefc
blob - b98e7bdc69ac6a12eb84eaaf97ec43ecdbe83733
blob + 248e3b161e88be505a88411156dc57a2772bd4fa
--- usr.sbin/vmd/i8253.c
+++ usr.sbin/vmd/i8253.c
@@ -371,7 +371,6 @@ i8253_fire(int fd, short type, void *arg)
        struct i8253_channel *ctr = (struct i8253_channel *)arg;

        vcpu_assert_pic_irq(ctr->vm_id, 0, 0);
-       vcpu_deassert_pic_irq(ctr->vm_id, 0, 0);

        if (ctr->mode != TIMER_INTTC) {
                timerclear(&tv);
blob - 43dce7b10d1467a5b7ac7f3308d01e32b4d0b9ee
blob + 4fc147b19c99627e386ab26355b8f90a6ae5872b
--- usr.sbin/vmd/mc146818.c
+++ usr.sbin/vmd/mc146818.c
@@ -150,7 +150,6 @@ rtc_fireper(int fd, short type, void *arg)
        rtc.regs[MC_REGC] |= MC_REGC_PF;

        vcpu_assert_pic_irq((ptrdiff_t)arg, 0, 8);
-       vcpu_deassert_pic_irq((ptrdiff_t)arg, 0, 8);

        evtimer_add(&rtc.per, &rtc.per_tv);
 }
blob - bc23876bf0392312335da0d00e143583a87549af
blob + 98ed7dbecf2120ccbf9a16198ee479cb15aebc5f
--- usr.sbin/vmd/ns8250.c
+++ usr.sbin/vmd/ns8250.c
@@ -82,7 +82,6 @@ ratelimit(int fd, short type, void *arg)
        com1_dev.regs.iir &= ~IIR_NOPEND;

        vcpu_assert_pic_irq(com1_dev.vmid, 0, com1_dev.irq);
-       vcpu_deassert_pic_irq(com1_dev.vmid, 0, com1_dev.irq);
        mutex_unlock(&com1_dev.mutex);
 }

@@ -160,7 +159,6 @@ com_rcv_event(int fd, short kind, void *arg)
        if ((com1_dev.regs.iir & IIR_NOPEND) == 0) {
                /* XXX: vcpu_id */
                vcpu_assert_pic_irq((uintptr_t)arg, 0, com1_dev.irq);
-               vcpu_deassert_pic_irq((uintptr_t)arg, 0, com1_dev.irq);
        }

        mutex_unlock(&com1_dev.mutex);

Reply via email to