timeout_pending followed by timeot_del is pointless, as timeout_del
effectively does the pending check itself.

now that timeout_del returns whether the timeout was actually
removed, you can make decisions based on that rather than race with
timeout_pending

checking timeout_pending shortly after you already went timeout_del
is a waste of time too.

Index: arch/loongson/dev/kb3310.c
===================================================================
RCS file: /cvs/src/sys/arch/loongson/dev/kb3310.c,v
retrieving revision 1.18
diff -u -p -r1.18 kb3310.c
--- arch/loongson/dev/kb3310.c  3 Oct 2012 21:44:51 -0000       1.18
+++ arch/loongson/dev/kb3310.c  9 Dec 2013 10:30:36 -0000
@@ -520,8 +520,7 @@ ykbec_bell(void *arg, u_int pitch, u_int
 
        s = spltty();
        bctrl = ykbec_read(sc, REG_BEEP_CONTROL);
-       if (volume == 0 || timeout_pending(&sc->sc_bell_tmo)) {
-               timeout_del(&sc->sc_bell_tmo);
+       if (volume == 0 || timeout_del(&sc->sc_bell_tmo)) {
                /* inline ykbec_bell_stop(arg); */
                ykbec_write(sc, REG_BEEP_CONTROL, bctrl & ~BEEP_ENABLE);
        }
Index: arch/sgi/dev/iockbc.c
===================================================================
RCS file: /cvs/src/sys/arch/sgi/dev/iockbc.c,v
retrieving revision 1.8
diff -u -p -r1.8 iockbc.c
--- arch/sgi/dev/iockbc.c       10 Aug 2012 17:49:31 -0000      1.8
+++ arch/sgi/dev/iockbc.c       9 Dec 2013 10:30:36 -0000
@@ -441,7 +441,7 @@ iockbcintr_internal(struct pckbc_interna
        uint32_t val;
 
        /* Reschedule timeout further into the idle times. */
-       if (timeout_pending(&t->t_poll))
+       if (timeout_del(&t->t_poll))
                timeout_add_sec(&t->t_poll, 1);
 
        /*
Index: arch/sgi/dev/mkbc.c
===================================================================
RCS file: /cvs/src/sys/arch/sgi/dev/mkbc.c,v


retrieving revision 1.12
diff -u -p -r1.12 mkbc.c
--- arch/sgi/dev/mkbc.c 10 Aug 2012 17:49:31 -0000      1.12
+++ arch/sgi/dev/mkbc.c 9 Dec 2013 10:30:36 -0000
@@ -322,7 +322,7 @@ mkbcintr_internal(struct pckbc_internal 
        u_int64_t data;
 
        /* Reschedule timeout further into the idle times. */
-       if (timeout_pending(&t->t_poll))
+       if (timeout_del(&t->t_poll))
                timeout_add_sec(&t->t_poll, 1);
 
        /*
Index: arch/sparc/dev/be.c
===================================================================
RCS file: /cvs/src/sys/arch/sparc/dev/be.c,v
retrieving revision 1.45
diff -u -p -r1.45 be.c
--- arch/sparc/dev/be.c 27 Nov 2013 08:56:31 -0000      1.45
+++ arch/sparc/dev/be.c 9 Dec 2013 10:30:37 -0000
@@ -323,8 +323,7 @@ bestop(sc)
        int tries;
 
        sc->sc_arpcom.ac_if.if_timer = 0;
-       if (timeout_pending(&sc->sc_tick))
-               timeout_del(&sc->sc_tick);
+       timeout_del(&sc->sc_tick);
 
        tries = 32;
        sc->sc_br->tx_cfg = 0;
Index: dev/ic/cy.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/cy.c,v
retrieving revision 1.33
diff -u -p -r1.33 cy.c
--- dev/ic/cy.c 18 Nov 2010 21:15:15 -0000      1.33
+++ dev/ic/cy.c 9 Dec 2013 10:30:37 -0000
@@ -348,8 +348,7 @@ cyopen(dev, flag, mode, p)
 
                cy->cy_channel_control = 0;
 
-               if (!timeout_pending(&sc->sc_poll_to))
-                       timeout_add(&sc->sc_poll_to, 1);
+               timeout_add(&sc->sc_poll_to, 1);
 
                /* this sets parameters and raises DTR */
                cyparam(tp, &tp->t_termios);
Index: dev/ic/pckbc.c
===================================================================
RCS file: /cvs/src/sys/dev/ic/pckbc.c,v
retrieving revision 1.37
diff -u -p -r1.37 pckbc.c
--- dev/ic/pckbc.c      24 Sep 2013 08:33:50 -0000      1.37
+++ dev/ic/pckbc.c      9 Dec 2013 10:30:37 -0000
@@ -976,7 +976,7 @@ pckbcintr_internal(struct pckbc_internal
        int served = 0, data;
 
        /* reschedule timeout further into the idle times */
-       if (timeout_pending(&t->t_poll))
+       if (timeout_del(&t->t_poll))
                timeout_add_sec(&t->t_poll, 1);
 
        for(;;) {
Index: dev/pci/if_txp.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_txp.c,v
retrieving revision 1.108
diff -u -p -r1.108 if_txp.c
--- dev/pci/if_txp.c    26 Nov 2013 09:50:33 -0000      1.108
+++ dev/pci/if_txp.c    9 Dec 2013 10:30:37 -0000
@@ -1250,8 +1250,7 @@ txp_init(struct txp_softc *sc)
        ifp->if_flags |= IFF_RUNNING;
        ifp->if_flags &= ~IFF_OACTIVE;
 
-       if (!timeout_pending(&sc->sc_tick))
-               timeout_add_sec(&sc->sc_tick, 1);
+       timeout_add_sec(&sc->sc_tick, 1);
 
        splx(s);
 }
Index: dev/pci/if_vge.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_vge.c,v
retrieving revision 1.57
diff -u -p -r1.57 if_vge.c
--- dev/pci/if_vge.c    21 Aug 2013 05:21:44 -0000      1.57
+++ dev/pci/if_vge.c    9 Dec 2013 10:30:37 -0000
@@ -1678,8 +1678,7 @@ vge_init(struct ifnet *ifp)
 
        sc->vge_link = 0;
 
-       if (!timeout_pending(&sc->timer_handle))
-               timeout_add_sec(&sc->timer_handle, 1);
+       timeout_add_sec(&sc->timer_handle, 1);
 
        return (0);
 }
Index: dev/pci/if_vr.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_vr.c,v
retrieving revision 1.131
diff -u -p -r1.131 if_vr.c
--- dev/pci/if_vr.c     6 Dec 2013 21:03:04 -0000       1.131
+++ dev/pci/if_vr.c     9 Dec 2013 10:30:37 -0000
@@ -1510,8 +1510,7 @@ vr_init(void *xsc)
        ifp->if_flags |= IFF_RUNNING;
        ifp->if_flags &= ~IFF_OACTIVE;
 
-       if (!timeout_pending(&sc->sc_to))
-               timeout_add_sec(&sc->sc_to, 1);
+       timeout_add_sec(&sc->sc_to, 1);
 
        splx(s);
 }
Index: kern/kern_synch.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_synch.c,v
retrieving revision 1.111
diff -u -p -r1.111 kern_synch.c
--- kern/kern_synch.c   25 Nov 2013 15:24:18 -0000      1.111
+++ kern/kern_synch.c   9 Dec 2013 10:30:37 -0000
@@ -263,9 +263,8 @@ sleep_finish_timeout(struct sleep_state 
        if (p->p_flag & P_TIMEOUT) {
                atomic_clearbits_int(&p->p_flag, P_TIMEOUT);
                return (EWOULDBLOCK);
-       } else if (timeout_pending(&p->p_sleep_to)) {
+       } else
                timeout_del(&p->p_sleep_to);
-       }
 
        return (0);
 }

Reply via email to