tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: select/poll optimization



Andrew Doran wrote:
On Fri, Mar 21, 2008 at 03:55:05PM +0000, Andrew Doran wrote:

percpu:         744993 / 60 = 12416.550000
HEAD:           502141 / 60 = 8369.016667
combined:       224090 / 60 = 3734.833333

Updated patch for 4.99.56:

882989 / 60 = 14716.483333

http://www.netbsd.org/~ad/percpu-select-56.diff

There is a missing mutex_spin_exit() in this
file

RCS file: /cvsroot/src/sys/kern/sys_generic.c,v
retrieving revision 1.115
diff -u -p -r1.115 sys_generic.c
--- kern/sys_generic.c  21 Mar 2008 21:55:00 -0000      1.115
+++ kern/sys_generic.c  21 Mar 2008 23:53:48 -0000

in this hunk:

@@ -808,30 +828,43 @@ selcommon(lwp_t *l, register_t *retval,


What you intend might be this:

                if (tv && (timo = gettimeleft(tv, &sleeptv)) <= 0)
                        break;
-               if (l->l_selflag != SEL_SCANNING || ncoll != nselcoll)
+               mutex_spin_enter(&sc->sc_lock);
+               if (l->l_selflag != SEL_SCANNING || sc->sc_ncoll != ncoll) {
+                       mutex_spin_exit(&sc->sc_lock);
                        continue;
+               }
                l->l_selflag = SEL_BLOCKING;
-               error = cv_timedwait_sig(&select_cv, &select_lock, timo);
+               lwp_lock(l);
+               lwp_unlock_to(l, &sc->sc_lock);
+               sleepq_enqueue(&sc->sc_sleepq, sc, "select", &select_sobj);

        ---> mutex_spin_exit(&sc->sc_lock);   <---

+               KERNEL_UNLOCK_ALL(NULL, &l->l_biglocks); /* XXX */
+               error = sleepq_block(timo, true);
                if (error != 0)
                        break;
        }





Home | Main Index | Thread Index | Old Index