PERFORCE change 39477 for review
Sam Leffler
sam at FreeBSD.org
Fri Oct 10 16:27:36 PDT 2003
http://perforce.freebsd.org/chv.cgi?CH=39477
Change 39477 by sam at sam_ebb on 2003/10/10 16:27:19
revert locking changes
Affected files ...
.. //depot/projects/netperf/sys/kern/kern_poll.c#3 edit
Differences ...
==== //depot/projects/netperf/sys/kern/kern_poll.c#3 (text+ko) ====
@@ -182,13 +182,11 @@
};
static struct pollrec pr[POLL_LIST_LEN];
-static struct mtx poll_mtx;
static void
init_device_poll(void)
{
- mtx_init(&poll_mtx, "device polling", NULL, MTX_DEF);
netisr_register(NETISR_POLL, (netisr_t *)netisr_poll, NULL);
netisr_register(NETISR_POLLMORE, (netisr_t *)netisr_pollmore, NULL);
}
@@ -225,7 +223,6 @@
else
prev_t = t;
- mtx_lock(&poll_mtx);
if (pending_polls > 100) {
/*
* Too much, assume it has stalled (not always true
@@ -245,7 +242,6 @@
}
if (pending_polls++ > 0)
lost_polls++;
- mtx_unlock(&poll_mtx);
}
/*
@@ -256,16 +252,15 @@
{
int i;
- mtx_assert(&Giant, MA_NOTOWNED);
+ mtx_lock(&Giant);
- mtx_lock(&poll_mtx);
if (count > poll_each_burst)
count = poll_each_burst;
for (i = 0 ; i < poll_handlers ; i++)
if (pr[i].handler && (IFF_UP|IFF_RUNNING) ==
(pr[i].ifp->if_flags & (IFF_UP|IFF_RUNNING)) )
pr[i].handler(pr[i].ifp, 0, count); /* quick check */
- mtx_unlock(&poll_mtx);
+ mtx_unlock(&Giant);
}
/*
@@ -293,14 +288,10 @@
int kern_load;
/* XXX run at splhigh() or equivalent */
- mtx_assert(&Giant, MA_NOTOWNED);
-
- mtx_lock(&poll_mtx);
phase = 5;
if (residual_burst > 0) {
schednetisrbits(1 << NETISR_POLL | 1 << NETISR_POLLMORE);
/* will run immediately on return, followed by netisrs */
- mtx_unlock(&poll_mtx);
return;
}
/* here we can account time spent in netisr's in this tick */
@@ -331,12 +322,12 @@
schednetisrbits(1 << NETISR_POLL | 1 << NETISR_POLLMORE);
phase = 6;
}
- mtx_unlock(&poll_mtx);
}
/*
* netisr_poll is scheduled by schednetisr when appropriate, typically once
- * per tick.
+ * per tick. It is called at splnet() so first thing to do is to upgrade to
+ * splimp(), and call all registered handlers.
*/
static void
netisr_poll(void)
@@ -344,10 +335,8 @@
static int reg_frac_count;
int i, cycles;
enum poll_cmd arg = POLL_ONLY;
+ mtx_lock(&Giant);
- mtx_assert(&Giant, MA_NOTOWNED);
-
- mtx_lock(&poll_mtx);
phase = 3;
if (residual_burst == 0) { /* first call in this tick */
microuptime(&poll_start_t);
@@ -405,7 +394,7 @@
}
/* on -stable, schednetisr(NETISR_POLLMORE); */
phase = 4;
- mtx_lock(&poll_mtx);
+ mtx_unlock(&Giant);
}
/*
@@ -419,6 +408,8 @@
int
ether_poll_register(poll_handler_t *h, struct ifnet *ifp)
{
+ int s;
+
if (polling == 0) /* polling disabled, cannot register */
return 0;
if (h == NULL || ifp == NULL) /* bad arguments */
@@ -428,7 +419,7 @@
if (ifp->if_flags & IFF_POLLING) /* already polling */
return 0;
- mtx_lock(&poll_mtx);
+ s = splhigh();
if (poll_handlers >= POLL_LIST_LEN) {
/*
* List full, cannot register more entries.
@@ -437,8 +428,8 @@
* this at runtime is expensive, and won't solve the problem
* anyways, so just report a few times and then give up.
*/
- static int verbose = 10;
- mtx_unlock(&poll_mtx);
+ static int verbose = 10 ;
+ splx(s);
if (verbose >0) {
printf("poll handlers list full, "
"maybe a broken driver ?\n");
@@ -451,7 +442,7 @@
pr[poll_handlers].ifp = ifp;
poll_handlers++;
ifp->if_flags |= IFF_POLLING;
- mtx_unlock(&poll_mtx);
+ splx(s);
if (idlepoll_sleeping)
wakeup(&idlepoll_sleeping);
return 1; /* polling enabled in next call */
@@ -468,9 +459,9 @@
{
int i;
- mtx_lock(&poll_mtx);
+ mtx_lock(&Giant);
if ( !ifp || !(ifp->if_flags & IFF_POLLING) ) {
- mtx_unlock(&poll_mtx);
+ mtx_unlock(&Giant);
return 0;
}
for (i = 0 ; i < poll_handlers ; i++)
@@ -478,8 +469,8 @@
break;
ifp->if_flags &= ~IFF_POLLING; /* found or not... */
if (i == poll_handlers) {
- mtx_unlock(&poll_mtx);
- printf("%s: ifp not found!!!\n", __func__);
+ mtx_unlock(&Giant);
+ printf("ether_poll_deregister: ifp not found!!!\n");
return 0;
}
poll_handlers--;
@@ -487,7 +478,7 @@
pr[i].handler = pr[poll_handlers].handler;
pr[i].ifp = pr[poll_handlers].ifp;
}
- mtx_unlock(&poll_mtx);
+ mtx_unlock(&Giant);
return 1;
}
@@ -508,7 +499,10 @@
for (;;) {
if (poll_in_idle_loop && poll_handlers > 0) {
idlepoll_sleeping = 0;
+ mtx_lock(&Giant);
ether_poll(poll_each_burst);
+ mtx_unlock(&Giant);
+ mtx_assert(&Giant, MA_NOTOWNED);
mtx_lock_spin(&sched_lock);
td->td_proc->p_stats->p_ru.ru_nvcsw++;
mi_switch();
More information about the p4-projects
mailing list