PERFORCE change 82528 for review

Robert Watson rwatson at FreeBSD.org
Thu Aug 25 13:25:03 GMT 2005


http://perforce.freebsd.org/chv.cgi?CH=82528

Change 82528 by rwatson at rwatson_paprika on 2005/08/25 13:24:14

	Integrate netsmp: minor bug fixes.

Affected files ...

.. //depot/projects/netsmp/src/sys/dev/acpica/acpi_thermal.c#4 integrate
.. //depot/projects/netsmp/src/sys/dev/hme/if_hme.c#8 integrate
.. //depot/projects/netsmp/src/sys/kern/subr_witness.c#7 integrate
.. //depot/projects/netsmp/src/sys/libkern/iconv.c#3 integrate
.. //depot/projects/netsmp/src/sys/netgraph/ng_ksocket.c#2 integrate

Differences ...

==== //depot/projects/netsmp/src/sys/dev/acpica/acpi_thermal.c#4 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_thermal.c,v 1.56 2005/08/17 17:01:25 ume Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/acpica/acpi_thermal.c,v 1.58 2005/08/25 11:31:30 ume Exp $");
 
 #include "opt_acpi.h"
 #include <sys/param.h>
@@ -347,7 +347,14 @@
 	    AcpiOsFree(sc->tz_zone.al[i].Pointer);
     if (sc->tz_zone.psl.Pointer != NULL)
 	AcpiOsFree(sc->tz_zone.psl.Pointer);
-    bzero(&sc->tz_zone, sizeof(sc->tz_zone));
+
+    /*
+     * XXX: We initialize only ACPI_BUFFER to avoid race condition
+     * with passive cooling thread which refers psv, tc1, tc2 and tsp.
+     */
+    bzero(sc->tz_zone.ac, sizeof(sc->tz_zone.ac));
+    bzero(sc->tz_zone.al, sizeof(sc->tz_zone.al));
+    bzero(&sc->tz_zone.psl, sizeof(sc->tz_zone.psl));
 
     /* Evaluate thermal zone parameters. */
     for (i = 0; i < TZ_NUMLEVELS; i++) {
@@ -408,6 +415,28 @@
 }
 
 /*
+ * Get the current temperature.
+ */
+static int
+acpi_tz_get_temperature(struct acpi_tz_softc *sc)
+{
+    int		temp;
+    ACPI_STATUS	status;
+
+    status = acpi_GetInteger(sc->tz_handle, "_TMP", &temp);
+    if (ACPI_FAILURE(status)) {
+	ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
+	    "error fetching current temperature -- %s\n",
+	     AcpiFormatException(status));
+	return (FALSE);
+    }
+
+    ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "got %d.%dC\n", TZ_KELVTOC(temp)));
+    sc->tz_temperature = temp;
+    return (TRUE);
+}
+
+/*
  * Evaluate the condition of a thermal zone, take appropriate actions.
  */
 static void
@@ -418,25 +447,18 @@
     int		temp;
     int		i;
     int		newactive, newflags;
-    ACPI_STATUS	status;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     sc = (struct acpi_tz_softc *)Context;
 
     /* Get the current temperature. */
-    status = acpi_GetInteger(sc->tz_handle, "_TMP", &temp);
-    if (ACPI_FAILURE(status)) {
-	ACPI_VPRINT(sc->tz_dev, acpi_device_get_parent_softc(sc->tz_dev),
-	    "error fetching current temperature -- %s\n",
-	     AcpiFormatException(status));
+    if (!acpi_tz_get_temperature(sc)) {
 	/* XXX disable zone? go to max cooling? */
 	return_VOID;
     }
+    temp = sc->tz_temperature;
 
-    ACPI_DEBUG_PRINT((ACPI_DB_VALUES, "got %d.%dC\n", TZ_KELVTOC(temp)));
-    sc->tz_temperature = temp;
-
     /*
      * Work out what we ought to be doing right now.
      *
@@ -972,19 +994,22 @@
 acpi_tz_cooling_thread(void *arg)
 {
     struct acpi_tz_softc *sc;
-    int error, perf, temperature;
+    int error, perf, curr_temp, prev_temp;
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
     sc = (struct acpi_tz_softc *)arg;
 
-    temperature = sc->tz_temperature;
+    prev_temp = sc->tz_temperature;
     while (sc->tz_cooling_enabled) {
-	if (sc->tz_temperature >= sc->tz_zone.psv)
+	if (sc->tz_cooling_active)
+	    (void)acpi_tz_get_temperature(sc);
+	curr_temp = sc->tz_temperature;
+	if (curr_temp >= sc->tz_zone.psv)
 	    sc->tz_cooling_active = TRUE;
 	if (sc->tz_cooling_active) {
-	    perf = sc->tz_zone.tc1 * (sc->tz_temperature - temperature) +
-		   sc->tz_zone.tc2 * (sc->tz_temperature - sc->tz_zone.psv);
+	    perf = sc->tz_zone.tc1 * (curr_temp - prev_temp) +
+		   sc->tz_zone.tc2 * (curr_temp - sc->tz_zone.psv);
 	    perf /= 10;
 
 	    if (perf != 0) {
@@ -1001,7 +1026,7 @@
 		}
 	    }
 	}
-	temperature = sc->tz_temperature;
+	prev_temp = curr_temp;
 	tsleep(&sc->tz_cooling_proc, PZERO, "cooling",
 	    hz * sc->tz_zone.tsp / 10);
     }

==== //depot/projects/netsmp/src/sys/dev/hme/if_hme.c#8 (text+ko) ====

@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/hme/if_hme.c,v 1.41 2005/08/17 17:44:32 jhb Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/hme/if_hme.c,v 1.42 2005/08/24 20:28:56 jhb Exp $");
 
 /*
  * HME Ethernet module driver.
@@ -199,14 +199,13 @@
 	 *
 	 */
 
-	HME_LOCK_ASSERT(sc, MA_NOTOWNED);
+	callout_init_mtx(&sc->sc_tick_ch, &sc->sc_lock, 0);
+
 	/* Make sure the chip is stopped. */
 	HME_LOCK(sc);
 	hme_stop(sc);
 	HME_UNLOCK(sc);
 
-	callout_init_mtx(&sc->sc_tick_ch, &sc->sc_lock, 0);
-
 	/*
 	 * Allocate DMA capable memory
 	 * Buffer descriptors must be aligned on a 2048 byte boundary;
@@ -381,8 +380,6 @@
 	struct ifnet *ifp = sc->sc_ifp;
 	int i;
 
-	HME_LOCK_ASSERT(sc, MA_NOTOWNED);
-
 	ether_ifdetach(ifp);
 	if_free(ifp);
 	HME_LOCK(sc);

==== //depot/projects/netsmp/src/sys/kern/subr_witness.c#7 (text+ko) ====

@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/subr_witness.c,v 1.197 2005/08/09 13:27:50 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/subr_witness.c,v 1.198 2005/08/25 03:47:37 truckman Exp $");
 
 #include "opt_ddb.h"
 #include "opt_witness.h"
@@ -165,10 +165,7 @@
 static int	isitmychild(struct witness *parent, struct witness *child);
 static int	isitmydescendant(struct witness *parent, struct witness *child);
 static int	itismychild(struct witness *parent, struct witness *child);
-static int	rebalancetree(struct witness_list *list);
 static void	removechild(struct witness *parent, struct witness *child);
-static int	reparentchildren(struct witness *newparent,
-		    struct witness *oldparent);
 static int	sysctl_debug_witness_watch(SYSCTL_HANDLER_ARGS);
 static void	witness_displaydescendants(void(*)(const char *fmt, ...),
 					   struct witness *, int indent);
@@ -194,11 +191,8 @@
 SYSCTL_NODE(_debug, OID_AUTO, witness, CTLFLAG_RW, 0, "Witness Locking");
 
 /*
- * If set to 0, witness is disabled.  If set to 1, witness performs full lock
- * order checking for all locks.  If set to 2 or higher, then witness skips
- * the full lock order check if the lock being acquired is at a higher level
- * (i.e. farther down in the tree) than the current lock.  This last mode is
- * somewhat experimental and not considered fully safe.  At runtime, this
+ * If set to 0, witness is disabled.  If set to a non-zero value, witness
+ * performs full lock order checking for all locks.  At runtime, this
  * value may be set to 0 to turn off witness.  witness is not allowed be
  * turned on once it is turned off, however.
  */
@@ -250,6 +244,16 @@
 static struct witness_child_list_entry *w_child_free = NULL;
 static struct lock_list_entry *w_lock_list_free = NULL;
 
+static int w_free_cnt, w_spin_cnt, w_sleep_cnt, w_child_free_cnt, w_child_cnt;
+SYSCTL_INT(_debug_witness, OID_AUTO, free_cnt, CTLFLAG_RD, &w_free_cnt, 0, "");
+SYSCTL_INT(_debug_witness, OID_AUTO, spin_cnt, CTLFLAG_RD, &w_spin_cnt, 0, "");
+SYSCTL_INT(_debug_witness, OID_AUTO, sleep_cnt, CTLFLAG_RD, &w_sleep_cnt, 0,
+    "");
+SYSCTL_INT(_debug_witness, OID_AUTO, child_free_cnt, CTLFLAG_RD,
+    &w_child_free_cnt, 0, "");
+SYSCTL_INT(_debug_witness, OID_AUTO, child_cnt, CTLFLAG_RD, &w_child_cnt, 0,
+    "");
+
 static struct witness w_data[WITNESS_COUNT];
 static struct witness_child_list_entry w_childdata[WITNESS_CHILDCOUNT];
 static struct lock_list_entry w_locklistdata[LOCK_CHILDCOUNT];
@@ -820,18 +824,11 @@
 	MPASS(!mtx_owned(&w_mtx));
 	mtx_lock_spin(&w_mtx);
 	/*
-	 * If we have a known higher number just say ok
-	 */
-	if (witness_watch > 1 && w->w_level > w1->w_level) {
-		mtx_unlock_spin(&w_mtx);
-		return;
-	}
-	/*
 	 * If we know that the the lock we are acquiring comes after
 	 * the lock we most recently acquired in the lock order tree,
 	 * then there is no need for any further checks.
 	 */
-	if (isitmydescendant(w1, w)) {
+	if (isitmychild(w1, w)) {
 		mtx_unlock_spin(&w_mtx);
 		return;
 	}
@@ -1312,11 +1309,13 @@
 	w->w_class = lock_class;
 	w->w_refcount = 1;
 	STAILQ_INSERT_HEAD(&w_all, w, w_list);
-	if (lock_class->lc_flags & LC_SPINLOCK)
+	if (lock_class->lc_flags & LC_SPINLOCK) {
 		STAILQ_INSERT_HEAD(&w_spin, w, w_typelist);
-	else if (lock_class->lc_flags & LC_SLEEPLOCK)
+		w_spin_cnt++;
+	} else if (lock_class->lc_flags & LC_SLEEPLOCK) {
 		STAILQ_INSERT_HEAD(&w_sleep, w, w_typelist);
-	else {
+		w_sleep_cnt++;
+	} else {
 		mtx_unlock_spin(&w_mtx);
 		panic("lock class %s is not sleep or spin",
 		    lock_class->lc_name);
@@ -1334,10 +1333,13 @@
 	struct witness *parent;
 
 	MPASS(w->w_refcount == 0);
-	if (w->w_class->lc_flags & LC_SLEEPLOCK)
+	if (w->w_class->lc_flags & LC_SLEEPLOCK) {
 		list = &w_sleep;
-	else
+		w_sleep_cnt--;
+	} else {
 		list = &w_spin;
+		w_spin_cnt--;
+	}
 	/*
 	 * First, we run through the entire tree looking for any
 	 * witnesses that the outgoing witness is a child of.  For
@@ -1348,8 +1350,6 @@
 		if (!isitmychild(parent, w))
 			continue;
 		removechild(parent, w);
-		if (!reparentchildren(parent, w))
-			return (0);
 	}
 
 	/*
@@ -1358,6 +1358,7 @@
 	 */
 	for (wcl = w->w_children; wcl != NULL; wcl = nwcl) {
 		nwcl = wcl->wcl_next;
+        	w_child_cnt--;
 		witness_child_free(wcl);
 	}
 
@@ -1368,34 +1369,6 @@
 	STAILQ_REMOVE(&w_all, w, witness, w_list);
 	witness_free(w);
 
-	/* Finally, fixup the tree. */
-	return (rebalancetree(list));
-}
-
-/*
- * Prune an entire lock order tree.  We look for cases where a lock
- * is now both a descendant and a direct child of a given lock.  In
- * that case, we want to remove the direct child link from the tree.
- *
- * Returns false if insertchild() fails.
- */
-static int
-rebalancetree(struct witness_list *list)
-{
-	struct witness *child, *parent;
-
-	STAILQ_FOREACH(child, list, w_typelist) {
-		STAILQ_FOREACH(parent, list, w_typelist) {
-			if (!isitmychild(parent, child))
-				continue;
-			removechild(parent, child);
-			if (isitmydescendant(parent, child))
-				continue;
-			if (!insertchild(parent, child))
-				return (0);
-		}
-	}
-	witness_levelall();
 	return (1);
 }
 
@@ -1420,31 +1393,13 @@
 		*wcl = witness_child_get();
 		if (*wcl == NULL)
 			return (0);
+        	w_child_cnt++;
 	}
 	(*wcl)->wcl_children[(*wcl)->wcl_count++] = child;
 
 	return (1);
 }
 
-/*
- * Make all the direct descendants of oldparent be direct descendants
- * of newparent.
- */
-static int
-reparentchildren(struct witness *newparent, struct witness *oldparent)
-{
-	struct witness_child_list_entry *wcl;
-	int i;
-
-	/* Avoid making a witness a child of itself. */
-	MPASS(!isitmychild(oldparent, newparent));
-	
-	for (wcl = oldparent->w_children; wcl != NULL; wcl = wcl->wcl_next)
-		for (i = 0; i < wcl->wcl_count; i++)
-			if (!insertchild(newparent, wcl->wcl_children[i]))
-				return (0);
-	return (1);
-}
 
 static int
 itismychild(struct witness *parent, struct witness *child)
@@ -1466,7 +1421,7 @@
 		list = &w_sleep;
 	else
 		list = &w_spin;
-	return (rebalancetree(list));
+	return (1);
 }
 
 static void
@@ -1490,6 +1445,7 @@
 		return;
 	wcl1 = *wcl;
 	*wcl = wcl1->wcl_next;
+	w_child_cnt--;
 	witness_child_free(wcl1);
 }
 
@@ -1648,6 +1604,7 @@
 	}
 	w = STAILQ_FIRST(&w_free);
 	STAILQ_REMOVE_HEAD(&w_free, w_list);
+	w_free_cnt--;
 	bzero(w, sizeof(*w));
 	return (w);
 }
@@ -1657,6 +1614,7 @@
 {
 
 	STAILQ_INSERT_HEAD(&w_free, w, w_list);
+	w_free_cnt++;
 }
 
 static struct witness_child_list_entry *
@@ -1676,6 +1634,7 @@
 		return (NULL);
 	}
 	w_child_free = wcl->wcl_next;
+	w_child_free_cnt--;
 	bzero(wcl, sizeof(*wcl));
 	return (wcl);
 }
@@ -1686,6 +1645,7 @@
 
 	wcl->wcl_next = w_child_free;
 	w_child_free = wcl;
+	w_child_free_cnt++;
 }
 
 static struct lock_list_entry *

==== //depot/projects/netsmp/src/sys/libkern/iconv.c#3 (text+ko) ====

@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/libkern/iconv.c,v 1.10 2005/07/23 16:52:57 imura Exp $");
+__FBSDID("$FreeBSD: src/sys/libkern/iconv.c,v 1.11 2005/08/24 12:38:26 imura Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -379,6 +379,12 @@
 		return EINVAL;
 	if (din.ia_datalen > ICONV_CSMAXDATALEN)
 		return EINVAL;
+	if (strlen(din.ia_from) >= ICONV_CSNMAXLEN)
+		return EINVAL;
+	if (strlen(din.ia_to) >= ICONV_CSNMAXLEN)
+		return EINVAL;
+	if (strlen(din.ia_converter) >= ICONV_CNVNMAXLEN)
+		return EINVAL;
 	if (iconv_lookupconv(din.ia_converter, &dcp) != 0)
 		return EINVAL;
 	error = iconv_register_cspair(din.ia_to, din.ia_from, dcp, NULL, &csp);

==== //depot/projects/netsmp/src/sys/netgraph/ng_ksocket.c#2 (text+ko) ====

@@ -37,7 +37,7 @@
  *
  * Author: Archie Cobbs <archie at freebsd.org>
  *
- * $FreeBSD: src/sys/netgraph/ng_ksocket.c,v 1.55 2005/05/16 17:07:39 glebius Exp $
+ * $FreeBSD: src/sys/netgraph/ng_ksocket.c,v 1.56 2005/08/25 07:21:15 glebius Exp $
  * $Whistle: ng_ksocket.c,v 1.1 1999/11/16 20:04:40 archie Exp $
  */
 
@@ -1001,8 +1001,6 @@
  * the request has at least been done, but the 'so' may not be so lucky.
  * handle this by checking the validity of the node in the target function
  * before dereferencing the socket pointer.
- *
- * To decouple stack, we use queue version of ng_send_fn().
  */
 
 static void
@@ -1013,7 +1011,7 @@
 
 	wait = (waitflag & M_WAITOK) ? NG_WAITOK : 0;
 	ng_send_fn1(node, NULL, &ng_ksocket_incoming2, so, waitflag,
-	    wait | NG_QUEUE);
+	    wait);
 }
 
 


More information about the p4-projects mailing list