Re: sysctl -a is slow

From: Jaakko Heinonen <jh_at_FreeBSD.org>
Date: Tue, 19 Oct 2010 11:59:56 +0300
On 2010-09-20, David Xu wrote:
> I redirect all output to a disk file, and it still needs 1 second to
> complete, this machine is dual-core pentium E5500, faster than previous
> one which is a dual-core AMD 5000+ machine, the 5000+ needs 2
> seconds to complete.
> 
> $/usr/bin/time sysctl -b kern.geom.confdot > sysctl_geom_confdot.txt
>         1.00 real         0.00 user         0.00 sys

I couldn't reproduce the problem myself but I bet that it's a lost
wakeup in g_waitfor_event(). Can you try this patch?

%%%
Index: sys/geom/geom_event.c
===================================================================
--- sys/geom/geom_event.c	(revision 214048)
+++ sys/geom/geom_event.c	(working copy)
_at__at_ -220,11 +220,12 _at__at_ one_event(void)
 	mtx_lock(&g_eventlock);
 	TAILQ_REMOVE(&g_events, ep, events);
 	ep->flag &= ~EV_INPROGRESS;
-	mtx_unlock(&g_eventlock);
 	if (ep->flag & EV_WAKEUP) {
 		ep->flag |= EV_DONE;
 		wakeup(ep);
+		mtx_unlock(&g_eventlock);
 	} else {
+		mtx_unlock(&g_eventlock);
 		g_free(ep);
 	}
 	g_topology_unlock();
_at__at_ -365,11 +366,14 _at__at_ g_waitfor_event(g_event_t *func, void *a
 	va_end(ap);
 	if (error)
 		return (error);
-	do 
-		tsleep(ep, PRIBIO, "g_waitfor_event", hz);
-	while (!(ep->flag & EV_DONE));
+
+	mtx_lock(&g_eventlock);
+	while (!(ep->flag & EV_DONE))
+		msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz);
 	if (ep->flag & EV_CANCELED)
 		error = EAGAIN;
+	mtx_unlock(&g_eventlock);
+
 	g_free(ep);
 	return (error);
 }
%%%

-- 
Jaakko
Received on Tue Oct 19 2010 - 07:00:03 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:08 UTC