Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Mar 2008 00:48:54 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 137889 for review
Message-ID:  <200803170048.m2H0msks092012@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=137889

Change 137889 by marcel@marcel_xcllnt on 2008/03/17 00:48:28

	IFC @137888

Affected files ...

.. //depot/projects/powerpc/share/man/man4/man4.i386/ar.4#2 integrate
.. //depot/projects/powerpc/share/man/man4/man4.i386/pnp.4#2 integrate
.. //depot/projects/powerpc/share/man/man9/atomic.9#2 integrate
.. //depot/projects/powerpc/sys/amd64/include/atomic.h#3 integrate
.. //depot/projects/powerpc/sys/i386/cpufreq/p4tcc.c#2 integrate
.. //depot/projects/powerpc/sys/i386/include/atomic.h#6 integrate
.. //depot/projects/powerpc/sys/ia64/include/atomic.h#6 integrate
.. //depot/projects/powerpc/sys/kern/kern_resource.c#16 integrate
.. //depot/projects/powerpc/sys/netgraph/ng_base.c#16 integrate
.. //depot/projects/powerpc/sys/netgraph/ng_l2tp.c#6 integrate
.. //depot/projects/powerpc/sys/powerpc/include/atomic.h#6 integrate
.. //depot/projects/powerpc/sys/powerpc/include/gdb_machdep.h#2 integrate
.. //depot/projects/powerpc/sys/powerpc/powerpc/gdb_machdep.c#3 integrate
.. //depot/projects/powerpc/sys/sparc64/include/atomic.h#5 integrate
.. //depot/projects/powerpc/sys/sun4v/include/atomic.h#2 integrate
.. //depot/projects/powerpc/sys/sys/resourcevar.h#7 integrate
.. //depot/projects/powerpc/usr.sbin/adduser/adduser.8#4 integrate
.. //depot/projects/powerpc/usr.sbin/fifolog/lib/miniobj.h#2 integrate

Differences ...

==== //depot/projects/powerpc/share/man/man4/man4.i386/ar.4#2 (text+ko) ====

@@ -25,17 +25,16 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/share/man/man4/man4.i386/ar.4,v 1.28 2005/01/21 08:36:38 ru Exp $
+.\" $FreeBSD: src/share/man/man4/man4.i386/ar.4,v 1.29 2008/03/16 22:26:17 brueffer Exp $
 .\"
-.Dd November 19, 1995
+.Dd March 16, 2008
 .Dt AR 4 i386
 .Os
 .Sh NAME
 .Nm ar
 .Nd synchronous Digi/Arnet device driver
 .Sh SYNOPSIS
-.Cd "device ar0 at isa? port 0x300 irq 10 iomem 0xd0000"
-.Cd "device ar1 at isa? port 0x310 irq 11 iomem 0xd0000"
+.Cd "device ar"
 .Pp
 .Cd "device sppp"
 .Sh DESCRIPTION
@@ -83,14 +82,6 @@
 The node will have the same name as the device with ``sync_''
 prepended, e.g.,
 .Dv sync_ar0 .
-.Sh FILES
-.Bl -tag -width /sys/i386/isa/ic/hd64570.h -compact
-.It Pa /sys/i386/isa/ic/hd64570.h
-.It Pa /sys/i386/isa/if_arregs.h
-.It Pa /sys/i386/isa/if_ar.c
-.It Pa /sys/i386/isa/if_ar.h
-.It Pa /sys/pci/if_ar_p.c
-.El
 .Sh DIAGNOSTICS
 .Bl -diag
 .It "ar%d: Warning illegal interrupt %d."

==== //depot/projects/powerpc/share/man/man4/man4.i386/pnp.4#2 (text+ko) ====

@@ -25,7 +25,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/share/man/man4/man4.i386/pnp.4,v 1.17 2005/07/15 17:35:26 hrs Exp $
+.\" $FreeBSD: src/share/man/man4/man4.i386/pnp.4,v 1.18 2008/03/16 22:51:30 brueffer Exp $
 .\"
 .Dd September 20, 2001
 .Dt PNP 4 i386
@@ -80,6 +80,7 @@
 .Fx 2.2.5 .
 It has been substantially updated in subsequent versions.
 .Sh AUTHORS
+.An -nosplit
 PnP support was originally written
 for
 .Fx 2.2.5

==== //depot/projects/powerpc/share/man/man9/atomic.9#2 (text+ko) ====

@@ -21,7 +21,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/share/man/man9/atomic.9,v 1.13 2005/11/18 10:52:24 ru Exp $
+.\" $FreeBSD: src/share/man/man9/atomic.9,v 1.14 2008/03/16 21:20:50 pjd Exp $
 .\"
 .Dd September 27, 2005
 .Os
@@ -211,7 +211,8 @@
 The
 .Fn atomic_fetchadd
 functions are only implemented for the types
-.Dq Li int
+.Dq Li int ,
+.Dq Li long
 and
 .Dq Li 32
 and do not have any variants with memory barriers at this time.

==== //depot/projects/powerpc/sys/amd64/include/atomic.h#3 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/amd64/include/atomic.h,v 1.44 2006/12/29 15:29:49 bde Exp $
+ * $FreeBSD: src/sys/amd64/include/atomic.h,v 1.45 2008/03/16 21:20:48 pjd Exp $
  */
 #ifndef _MACHINE_ATOMIC_H_
 #define	_MACHINE_ATOMIC_H_
@@ -74,6 +74,7 @@
 int	atomic_cmpset_int(volatile u_int *dst, u_int exp, u_int src);
 int	atomic_cmpset_long(volatile u_long *dst, u_long exp, u_long src);
 u_int	atomic_fetchadd_int(volatile u_int *p, u_int v);
+u_long	atomic_fetchadd_long(volatile u_long *p, u_long v);
 
 #define	ATOMIC_STORE_LOAD(TYPE, LOP, SOP)			\
 u_##TYPE	atomic_load_acq_##TYPE(volatile u_##TYPE *p);	\
@@ -174,6 +175,25 @@
 	return (v);
 }
 
+/*
+ * Atomically add the value of v to the long integer pointed to by p and return
+ * the previous value of *p.
+ */
+static __inline u_long
+atomic_fetchadd_long(volatile u_long *p, u_long v)
+{
+
+	__asm __volatile(
+	"	" MPLOCKED "		"
+	"	xaddq	%0, %1 ;	"
+	"# atomic_fetchadd_long"
+	: "+r" (v),			/* 0 (result) */
+	  "=m" (*p)			/* 1 */
+	: "m" (*p));			/* 2 */
+
+	return (v);
+}
+
 #if defined(_KERNEL) && !defined(SMP)
 
 /*

==== //depot/projects/powerpc/sys/i386/cpufreq/p4tcc.c#2 (text+ko) ====

@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/i386/cpufreq/p4tcc.c,v 1.12 2005/10/23 19:38:06 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/i386/cpufreq/p4tcc.c,v 1.13 2008/03/17 00:36:16 phk Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -164,7 +164,7 @@
 	 */
 	sc->auto_mode = TRUE;
 
-	switch (cpu_id & 0xf) {
+	switch (cpu_id & 0xff) {
 	case 0x22:
 	case 0x24:
 	case 0x25:

==== //depot/projects/powerpc/sys/i386/include/atomic.h#6 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/i386/include/atomic.h,v 1.47 2006/12/29 15:48:18 bde Exp $
+ * $FreeBSD: src/sys/i386/include/atomic.h,v 1.48 2008/03/16 21:20:49 pjd Exp $
  */
 #ifndef _MACHINE_ATOMIC_H_
 #define	_MACHINE_ATOMIC_H_
@@ -278,6 +278,13 @@
 	    (u_int)src));
 }
 
+static __inline u_long
+atomic_fetchadd_long(volatile u_long *p, u_long v)
+{
+
+	return (atomic_fetchadd_int((volatile u_int *)p, (u_int)v));
+}
+
 /* Read the current value and store a zero in the destination. */
 #ifdef __GNUCLIKE_ASM
 

==== //depot/projects/powerpc/sys/ia64/include/atomic.h#6 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/ia64/include/atomic.h,v 1.12 2007/11/27 06:34:15 jasone Exp $
+ * $FreeBSD: src/sys/ia64/include/atomic.h,v 1.13 2008/03/16 21:20:49 pjd Exp $
  */
 
 #ifndef _MACHINE_ATOMIC_H_
@@ -371,4 +371,15 @@
 
 #define	atomic_fetchadd_int		atomic_fetchadd_32
 
+static __inline u_long
+atomic_fetchadd_long(volatile u_long *p, u_long v)
+{
+	u_long value;
+
+	do {
+		value = *p;
+	} while (!atomic_cmpset_64(p, value, value + v));
+	return (value);
+}
+
 #endif /* ! _MACHINE_ATOMIC_H_ */

==== //depot/projects/powerpc/sys/kern/kern_resource.c#16 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.185 2008/03/16 18:26:59 pjd Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_resource.c,v 1.187 2008/03/16 21:32:20 pjd Exp $");
 
 #include "opt_compat.h"
 
@@ -51,6 +51,7 @@
 #include <sys/proc.h>
 #include <sys/refcount.h>
 #include <sys/resourcevar.h>
+#include <sys/rwlock.h>
 #include <sys/sched.h>
 #include <sys/sx.h>
 #include <sys/syscallsubr.h>
@@ -67,7 +68,7 @@
 static MALLOC_DEFINE(M_PLIMIT, "plimit", "plimit structures");
 static MALLOC_DEFINE(M_UIDINFO, "uidinfo", "uidinfo structures");
 #define	UIHASH(uid)	(&uihashtbl[(uid) & uihash])
-static struct mtx uihashtbl_mtx;
+static struct rwlock uihashtbl_lock;
 static LIST_HEAD(uihashhead, uidinfo) *uihashtbl;
 static u_long uihash;		/* size of hash table - 1 */
 
@@ -263,7 +264,7 @@
 		n = PRIO_MAX;
 	if (n < PRIO_MIN)
 		n = PRIO_MIN;
- 	if (n < p->p_nice && priv_check(td, PRIV_SCHED_SETPRIORITY) != 0)
+	if (n < p->p_nice && priv_check(td, PRIV_SCHED_SETPRIORITY) != 0)
 		return (EACCES);
 	PROC_SLOCK(p);
 	sched_nice(p, n);
@@ -331,7 +332,7 @@
  * due to a CPU-bound normal process).  Fix me!  XXX
  */
 #if 0
- 		if (RTP_PRIO_IS_REALTIME(rtp.type)) {
+		if (RTP_PRIO_IS_REALTIME(rtp.type)) {
 #else
 		if (rtp.type != RTP_PRIO_NORMAL) {
 #endif
@@ -402,7 +403,7 @@
 		/*
 		 * Return OUR priority if no pid specified,
 		 * or if one is, report the highest priority
-		 * in the process.  There isn't much more you can do as 
+		 * in the process.  There isn't much more you can do as
 		 * there is only room to return a single priority.
 		 * Note: specifying our own pid is not the same
 		 * as leaving it zero.
@@ -889,13 +890,13 @@
 		if (su < ruxp->rux_su)
 			su = ruxp->rux_su;
 	} else if (tu + 3 > ruxp->rux_tu || 101 * tu > 100 * ruxp->rux_tu) {
-		/* 
+		/*
 		 * When we calibrate the cputicker, it is not uncommon to
 		 * see the presumably fixed frequency increase slightly over
 		 * time as a result of thermal stabilization and NTP
 		 * discipline (of the reference clock).  We therefore ignore
 		 * a bit of backwards slop because we  expect to catch up
- 		 * shortly.  We use a 3 microsecond limit to catch low
+		 * shortly.  We use a 3 microsecond limit to catch low
 		 * counts and a 1% limit for high counts.
 		 */
 		uu = ruxp->rux_uu;
@@ -1171,12 +1172,12 @@
 {
 
 	uihashtbl = hashinit(maxproc / 16, M_UIDINFO, &uihash);
-	mtx_init(&uihashtbl_mtx, "uidinfo hash", NULL, MTX_DEF);
+	rw_init(&uihashtbl_lock, "uidinfo hash");
 }
 
 /*
  * Look up a uidinfo struct for the parameter uid.
- * uihashtbl_mtx must be locked.
+ * uihashtbl_lock must be locked.
  */
 static struct uidinfo *
 uilookup(uid)
@@ -1185,7 +1186,7 @@
 	struct uihashhead *uipp;
 	struct uidinfo *uip;
 
-	mtx_assert(&uihashtbl_mtx, MA_OWNED);
+	rw_assert(&uihashtbl_lock, RA_LOCKED);
 	uipp = UIHASH(uid);
 	LIST_FOREACH(uip, uipp, ui_hash)
 		if (uip->ui_uid == uid)
@@ -1205,12 +1206,12 @@
 {
 	struct uidinfo *old_uip, *uip;
 
-	mtx_lock(&uihashtbl_mtx);
+	rw_rlock(&uihashtbl_lock);
 	uip = uilookup(uid);
 	if (uip == NULL) {
-		mtx_unlock(&uihashtbl_mtx);
+		rw_runlock(&uihashtbl_lock);
 		uip = malloc(sizeof(*uip), M_UIDINFO, M_WAITOK | M_ZERO);
-		mtx_lock(&uihashtbl_mtx);
+		rw_wlock(&uihashtbl_lock);
 		/*
 		 * There's a chance someone created our uidinfo while we
 		 * were in malloc and not holding the lock, so we have to
@@ -1221,13 +1222,14 @@
 			free(uip, M_UIDINFO);
 			uip = old_uip;
 		} else {
-			uip->ui_mtxp = mtx_pool_alloc(mtxpool_sleep);
+			refcount_init(&uip->ui_ref, 0);
 			uip->ui_uid = uid;
 			LIST_INSERT_HEAD(UIHASH(uid), uip, ui_hash);
 		}
+		uihold(uip);
 	}
 	uihold(uip);
-	mtx_unlock(&uihashtbl_mtx);
+	rw_unlock(&uihashtbl_lock);
 	return (uip);
 }
 
@@ -1239,9 +1241,7 @@
 	struct uidinfo *uip;
 {
 
-	UIDINFO_LOCK(uip);
-	uip->ui_ref++;
-	UIDINFO_UNLOCK(uip);
+	refcount_acquire(&uip->ui_ref);
 }
 
 /*-
@@ -1263,43 +1263,32 @@
 uifree(uip)
 	struct uidinfo *uip;
 {
+	int old;
 
 	/* Prepare for optimal case. */
-	UIDINFO_LOCK(uip);
-
-	if (--uip->ui_ref != 0) {
-		UIDINFO_UNLOCK(uip);
+	old = uip->ui_ref;
+	if (old > 1 && atomic_cmpset_int(&uip->ui_ref, old, old - 1))
 		return;
-	}
 
 	/* Prepare for suboptimal case. */
-	uip->ui_ref++;
-	UIDINFO_UNLOCK(uip);
-	mtx_lock(&uihashtbl_mtx);
-	UIDINFO_LOCK(uip);
-
-	/*
-	 * We must subtract one from the count again because we backed out
-	 * our initial subtraction before dropping the lock.
-	 * Since another thread may have added a reference after we dropped the
-	 * initial lock we have to test for zero again.
-	 */
-	if (--uip->ui_ref == 0) {
+	rw_wlock(&uihashtbl_lock);
+	if (refcount_release(&uip->ui_ref)) {
 		LIST_REMOVE(uip, ui_hash);
-		mtx_unlock(&uihashtbl_mtx);
+		rw_wunlock(&uihashtbl_lock);
 		if (uip->ui_sbsize != 0)
-			printf("freeing uidinfo: uid = %d, sbsize = %jd\n",
-			    uip->ui_uid, (intmax_t)uip->ui_sbsize);
+			printf("freeing uidinfo: uid = %d, sbsize = %ld\n",
+			    uip->ui_uid, uip->ui_sbsize);
 		if (uip->ui_proccnt != 0)
 			printf("freeing uidinfo: uid = %d, proccnt = %ld\n",
 			    uip->ui_uid, uip->ui_proccnt);
-		UIDINFO_UNLOCK(uip);
 		FREE(uip, M_UIDINFO);
 		return;
 	}
-
-	mtx_unlock(&uihashtbl_mtx);
-	UIDINFO_UNLOCK(uip);
+	/*
+	 * Someone added a reference between atomic_cmpset_int() and
+	 * rw_wlock(&uihashtbl_lock).
+	 */
+	rw_wunlock(&uihashtbl_lock);
 }
 
 /*
@@ -1310,19 +1299,20 @@
 chgproccnt(uip, diff, max)
 	struct	uidinfo	*uip;
 	int	diff;
-	int	max;
+	rlim_t	max;
 {
 
-	UIDINFO_LOCK(uip);
 	/* Don't allow them to exceed max, but allow subtraction. */
-	if (diff > 0 && uip->ui_proccnt + diff > max && max != 0) {
-		UIDINFO_UNLOCK(uip);
-		return (0);
+	if (diff > 0 && max != 0) {
+		if (atomic_fetchadd_long(&uip->ui_proccnt, (long)diff) + diff > max) {
+			atomic_subtract_long(&uip->ui_proccnt, (long)diff);
+			return (0);
+		}
+	} else {
+		atomic_add_long(&uip->ui_proccnt, (long)diff);
+		if (uip->ui_proccnt < 0)
+			printf("negative proccnt for uid = %d\n", uip->ui_uid);
 	}
-	uip->ui_proccnt += diff;
-	if (uip->ui_proccnt < 0)
-		printf("negative proccnt for uid = %d\n", uip->ui_uid);
-	UIDINFO_UNLOCK(uip);
 	return (1);
 }
 
@@ -1336,19 +1326,19 @@
 	u_int	to;
 	rlim_t	max;
 {
-	rlim_t new;
+	int diff;
 
-	UIDINFO_LOCK(uip);
-	new = uip->ui_sbsize + to - *hiwat;
-	/* Don't allow them to exceed max, but allow subtraction. */
-	if (to > *hiwat && new > max) {
-		UIDINFO_UNLOCK(uip);
-		return (0);
+	diff = to - *hiwat;
+	if (diff > 0) {
+		if (atomic_fetchadd_long(&uip->ui_sbsize, (long)diff) + diff > max) {
+			atomic_subtract_long(&uip->ui_sbsize, (long)diff);
+			return (0);
+		}
+	} else {
+		atomic_add_long(&uip->ui_sbsize, (long)diff);
+		if (uip->ui_sbsize < 0)
+			printf("negative sbsize for uid = %d\n", uip->ui_uid);
 	}
-	uip->ui_sbsize = new;
-	UIDINFO_UNLOCK(uip);
 	*hiwat = to;
-	if (new < 0)
-		printf("negative sbsize for uid = %d\n", uip->ui_uid);
 	return (1);
 }

==== //depot/projects/powerpc/sys/netgraph/ng_base.c#16 (text+ko) ====

@@ -38,7 +38,7 @@
  * Authors: Julian Elischer <julian@freebsd.org>
  *          Archie Cobbs <archie@freebsd.org>
  *
- * $FreeBSD: src/sys/netgraph/ng_base.c,v 1.150 2008/03/11 21:58:48 mav Exp $
+ * $FreeBSD: src/sys/netgraph/ng_base.c,v 1.151 2008/03/16 23:12:17 mav Exp $
  * $Whistle: ng_base.c,v 1.39 1999/01/28 23:54:53 julian Exp $
  */
 
@@ -3577,7 +3577,6 @@
 	 */
 	if ((hook == NULL)
 	|| NG_HOOK_NOT_VALID(hook)
-	|| (NG_HOOK_PEER(hook) == NULL)
 	|| NG_HOOK_NOT_VALID(NG_HOOK_PEER(hook))
 	|| NG_NODE_NOT_VALID(NG_PEER_NODE(hook))) {
 		NG_FREE_ITEM(item);

==== //depot/projects/powerpc/sys/netgraph/ng_l2tp.c#6 (text+ko) ====

@@ -36,7 +36,7 @@
  * 
  * Author: Archie Cobbs <archie@freebsd.org>
  *
- * $FreeBSD: src/sys/netgraph/ng_l2tp.c,v 1.24 2008/03/09 11:17:00 mav Exp $
+ * $FreeBSD: src/sys/netgraph/ng_l2tp.c,v 1.25 2008/03/16 21:33:12 mav Exp $
  */
 
 /*
@@ -100,6 +100,20 @@
 /* Compare sequence numbers using circular math */
 #define L2TP_SEQ_DIFF(x, y)	((int)((int16_t)(x) - (int16_t)(y)))
 
+#define SESSHASHSIZE		0x0020
+#define SESSHASH(x)		(((x) ^ ((x) >> 8)) & (SESSHASHSIZE - 1))
+
+/* Hook private data (data session hooks only) */
+struct ng_l2tp_hook_private {
+	struct ng_l2tp_sess_config	conf;	/* hook/session config */
+	struct ng_l2tp_session_stats	stats;	/* per sessions statistics */
+	hook_p				hook;	/* hook reference */
+	u_int16_t			ns;	/* data ns sequence number */
+	u_int16_t			nr;	/* data nr sequence number */
+	LIST_ENTRY(ng_l2tp_hook_private) sessions;
+};
+typedef struct ng_l2tp_hook_private *hookpriv_p;
+
 /*
  * Sequence number state
  *
@@ -141,18 +155,10 @@
 	struct ng_l2tp_stats	stats;		/* node statistics */
 	struct l2tp_seq		seq;		/* ctrl sequence number state */
 	ng_ID_t			ftarget;	/* failure message target */
+	LIST_HEAD(, ng_l2tp_hook_private) sesshash[SESSHASHSIZE];
 };
 typedef struct ng_l2tp_private *priv_p;
 
-/* Hook private data (data session hooks only) */
-struct ng_l2tp_hook_private {
-	struct ng_l2tp_sess_config	conf;	/* hook/session config */
-	struct ng_l2tp_session_stats	stats;	/* per sessions statistics */
-	u_int16_t			ns;	/* data ns sequence number */
-	u_int16_t			nr;	/* data nr sequence number */
-};
-typedef struct ng_l2tp_hook_private *hookpriv_p;
-
 /* Netgraph node methods */
 static ng_constructor_t	ng_l2tp_constructor;
 static ng_rcvmsg_t	ng_l2tp_rcvmsg;
@@ -179,7 +185,7 @@
 static void	ng_l2tp_seq_rack_timeout(node_p node, hook_p hook,
 		    void *arg1, int arg2);
 
-static ng_fn_eachhook	ng_l2tp_find_session;
+static hookpriv_p	ng_l2tp_find_session(priv_p privp, u_int16_t sid);
 static ng_fn_eachhook	ng_l2tp_reset_session;
 
 #ifdef INVARIANTS
@@ -355,6 +361,7 @@
 ng_l2tp_constructor(node_p node)
 {
 	priv_p priv;
+	int	i;
 
 	/* Allocate private structure */
 	MALLOC(priv, priv_p, sizeof(*priv), M_NETGRAPH_L2TP, M_NOWAIT | M_ZERO);
@@ -371,6 +378,9 @@
 	/* Initialize sequence number state */
 	ng_l2tp_seq_init(priv);
 
+	for (i = 0; i < SESSHASHSIZE; i++)
+	    LIST_INIT(&priv->sesshash[i]);
+
 	/* Done */
 	return (0);
 }
@@ -398,6 +408,7 @@
 		static const char hexdig[16] = "0123456789abcdef";
 		u_int16_t session_id;
 		hookpriv_p hpriv;
+		uint16_t hash;
 		const char *hex;
 		int i;
 		int j;
@@ -424,7 +435,10 @@
 		hpriv->conf.session_id = htons(session_id);
 		hpriv->conf.control_dseq = L2TP_CONTROL_DSEQ;
 		hpriv->conf.enable_dseq = L2TP_ENABLE_DSEQ;
+		hpriv->hook = hook;
 		NG_HOOK_SET_PRIVATE(hook, hpriv);
+		hash = SESSHASH(hpriv->conf.session_id);
+		LIST_INSERT_HEAD(&priv->sesshash[hash], hpriv, sessions);
 	}
 
 	/* Done */
@@ -502,7 +516,6 @@
 			struct ng_l2tp_sess_config *const conf =
 			    (struct ng_l2tp_sess_config *)msg->data;
 			hookpriv_p hpriv;
-			hook_p hook;
 
 			/* Check for invalid or illegal config. */
 			if (msg->header.arglen != sizeof(*conf)) {
@@ -515,13 +528,11 @@
 			conf->peer_id = htons(conf->peer_id);
 
 			/* Find matching hook */
-			NG_NODE_FOREACH_HOOK(node, ng_l2tp_find_session,
-			    (void *)(uintptr_t)conf->session_id, hook);
-			if (hook == NULL) {
+			hpriv = ng_l2tp_find_session(priv, conf->session_id);
+			if (hpriv == NULL) {
 				error = ENOENT;
 				break;
 			}
-			hpriv = NG_HOOK_PRIVATE(hook);
 
 			/* Update hook's config */
 			hpriv->conf = *conf;
@@ -532,7 +543,6 @@
 			struct ng_l2tp_sess_config *conf;
 			u_int16_t session_id;
 			hookpriv_p hpriv;
-			hook_p hook;
 
 			/* Get session ID */
 			if (msg->header.arglen != sizeof(session_id)) {
@@ -543,13 +553,11 @@
 			session_id = htons(session_id);
 
 			/* Find matching hook */
-			NG_NODE_FOREACH_HOOK(node, ng_l2tp_find_session,
-			    (void *)(uintptr_t)session_id, hook);
-			if (hook == NULL) {
+			hpriv = ng_l2tp_find_session(priv, session_id);
+			if (hpriv == NULL) {
 				error = ENOENT;
 				break;
 			}
-			hpriv = NG_HOOK_PRIVATE(hook);
 
 			/* Send response */
 			NG_MKRESPONSE(resp, msg, sizeof(hpriv->conf), M_NOWAIT);
@@ -589,7 +597,6 @@
 		    {
 			uint16_t session_id;
 			hookpriv_p hpriv;
-			hook_p hook;
 
 			/* Get session ID. */
 			if (msg->header.arglen != sizeof(session_id)) {
@@ -600,13 +607,11 @@
 			session_id = htons(session_id);
 
 			/* Find matching hook. */
-			NG_NODE_FOREACH_HOOK(node, ng_l2tp_find_session,
-			    (void *)(uintptr_t)session_id, hook);
-			if (hook == NULL) {
+			hpriv = ng_l2tp_find_session(priv, session_id);
+			if (hpriv == NULL) {
 				error = ENOENT;
 				break;
 			}
-			hpriv = NG_HOOK_PRIVATE(hook);
 
 			if (msg->header.cmd != NGM_L2TP_CLR_SESSION_STATS) {
 				NG_MKRESPONSE(resp, msg,
@@ -700,7 +705,9 @@
 	else if (hook == priv->lower)
 		priv->lower = NULL;
 	else {
-		FREE(NG_HOOK_PRIVATE(hook), M_NETGRAPH_L2TP);
+		const hookpriv_p hpriv = NG_HOOK_PRIVATE(hook);
+		LIST_REMOVE(hpriv, sessions);
+		FREE(hpriv, M_NETGRAPH_L2TP);
 		NG_HOOK_SET_PRIVATE(hook, NULL);
 	}
 
@@ -715,17 +722,20 @@
 *************************************************************************/
 
 /*
- * Find the hook with a given session ID.
+ * Find the hook with a given session ID (in network order).
  */
-static int
-ng_l2tp_find_session(hook_p hook, void *arg)
+static hookpriv_p
+ng_l2tp_find_session(priv_p privp, u_int16_t sid)
 {
-	const hookpriv_p hpriv = NG_HOOK_PRIVATE(hook);
-	const u_int16_t sid = (u_int16_t)(uintptr_t)arg;
+	uint16_t	hash = SESSHASH(sid);
+	hookpriv_p	hpriv = NULL;
+
+	LIST_FOREACH(hpriv, &privp->sesshash[hash], sessions) {
+		if (hpriv->conf.session_id == sid)
+			break;
+	}
 
-	if (hpriv == NULL || hpriv->conf.session_id != sid)
-		return (-1);
-	return (0);
+	return (hpriv);
 }
 
 /*
@@ -861,15 +871,14 @@
 
 	/* Check session ID (for data packets only) */
 	if ((hdr & L2TP_HDR_CTRL) == 0) {
-		NG_NODE_FOREACH_HOOK(node, ng_l2tp_find_session,
-		    (void *)(uintptr_t)ids[1], hook);
-		if (hook == NULL) {
+		hpriv = ng_l2tp_find_session(priv, ids[1]);
+		if (hpriv == NULL) {
 			priv->stats.recvUnknownSID++;
 			NG_FREE_ITEM(item);
 			NG_FREE_M(m);
 			ERROUT(ENOTCONN);
 		}
-		hpriv = NG_HOOK_PRIVATE(hook);
+		hook = hpriv->hook;
 	}
 
 	/* Get Ns, Nr fields if present */

==== //depot/projects/powerpc/sys/powerpc/include/atomic.h#6 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/powerpc/include/atomic.h,v 1.18 2007/11/27 06:34:15 jasone Exp $
+ * $FreeBSD: src/sys/powerpc/include/atomic.h,v 1.19 2008/03/16 21:20:49 pjd Exp $
  */
 
 #ifndef _MACHINE_ATOMIC_H_
@@ -502,5 +502,7 @@
 }
 
 #define	atomic_fetchadd_int	atomic_fetchadd_32
+#define	atomic_fetchadd_long(p, v)	\
+    (u_long)atomic_fetchadd_32((volatile u_int *)(p), (u_int)(v))
 
 #endif /* ! _MACHINE_ATOMIC_H_ */

==== //depot/projects/powerpc/sys/powerpc/include/gdb_machdep.h#2 (text+ko) ====

@@ -23,26 +23,38 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/powerpc/include/gdb_machdep.h,v 1.1 2006/08/24 21:52:11 marcel Exp $
+ * $FreeBSD: src/sys/powerpc/include/gdb_machdep.h,v 1.2 2008/03/17 00:46:52 marcel Exp $
  */
 
 #ifndef _MACHINE_GDB_MACHDEP_H_
 #define	_MACHINE_GDB_MACHDEP_H_
 
-#define GDB_NREGS	153
+#define	PPC_GDB_NREGS4	(32 + 7 + 2)
+#define	PPC_GDB_NREGS8	32
+#define	PPC_GDB_NREGS16	32
+
+#define GDB_NREGS	(PPC_GDB_NREGS4 + PPC_GDB_NREGS8 + PPC_GDB_NREGS16)
 #define	GDB_REG_PC	64
 
-#define	GDB_BUFSZ	(GDB_NREGS*4)
+#define	GDB_BUFSZ	(PPC_GDB_NREGS4 * 8 +	\
+			 PPC_GDB_NREGS8 * 16 +	\
+			 PPC_GDB_NREGS16 * 32)
 
 static __inline size_t
 gdb_cpu_regsz(int regnum)
 {
-	return (sizeof(int));
+
+	if (regnum >= 32 && regnum <= 63)
+		return (8);
+	if (regnum >= 71 && regnum <= 102)
+		return (16);
+	return (4);
 }
 
 static __inline int
 gdb_cpu_query(void)
 {
+
 	return (0);
 }
 

==== //depot/projects/powerpc/sys/powerpc/powerpc/gdb_machdep.c#3 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/gdb_machdep.c,v 1.2 2008/03/03 22:00:46 raj Exp $");
+__FBSDID("$FreeBSD: src/sys/powerpc/powerpc/gdb_machdep.c,v 1.3 2008/03/17 00:46:52 marcel Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -53,48 +53,20 @@
 	*regsz = gdb_cpu_regsz(regnum);
 
 	if (kdb_thread == curthread) {
-		switch (regnum) {
-		case 0: return (&kdb_frame->fixreg[0]);
-		case 2: return (&kdb_frame->fixreg[2]);
-		case 3: return (&kdb_frame->fixreg[3]);
-		case 4: return (&kdb_frame->fixreg[4]);
-		case 5: return (&kdb_frame->fixreg[5]);
-		case 6: return (&kdb_frame->fixreg[6]);
-		case 7: return (&kdb_frame->fixreg[7]);
-		case 8: return (&kdb_frame->fixreg[8]);
-		case 9: return (&kdb_frame->fixreg[9]);
-		case 10: return (&kdb_frame->fixreg[10]);
-		case 11: return (&kdb_frame->fixreg[11]);
-		case 12: return (&kdb_frame->fixreg[12]);
-		case 13: return (&kdb_frame->fixreg[13]);
-		case 64: return (&kdb_frame->srr0);
-		case 67: return (&kdb_frame->lr);
-
-		}
+		if (regnum == 0 || (regnum >= 2 && regnum <= 31))
+			return (kdb_frame->fixreg + regnum);
+		if (regnum == 64)
+			return (&kdb_frame->srr0);
+		if (regnum == 67)
+			return (&kdb_frame->lr);
 	}
 
-	switch (regnum) {
-	case 1: return (&kdb_thrctx->pcb_sp);
-	case 14: return (&kdb_thrctx->pcb_context[0]);
-	case 15: return (&kdb_thrctx->pcb_context[1]);
-	case 16: return (&kdb_thrctx->pcb_context[2]);
-	case 17: return (&kdb_thrctx->pcb_context[3]);
-	case 18: return (&kdb_thrctx->pcb_context[4]);
-	case 19: return (&kdb_thrctx->pcb_context[5]);
-	case 20: return (&kdb_thrctx->pcb_context[6]);
-	case 21: return (&kdb_thrctx->pcb_context[7]);
-	case 22: return (&kdb_thrctx->pcb_context[8]);
-	case 23: return (&kdb_thrctx->pcb_context[9]);
-	case 24: return (&kdb_thrctx->pcb_context[10]);
-	case 25: return (&kdb_thrctx->pcb_context[11]);
-	case 26: return (&kdb_thrctx->pcb_context[12]);
-	case 27: return (&kdb_thrctx->pcb_context[13]);
-	case 28: return (&kdb_thrctx->pcb_context[14]);
-	case 29: return (&kdb_thrctx->pcb_context[15]);
-	case 30: return (&kdb_thrctx->pcb_context[16]);
-	case 31: return (&kdb_thrctx->pcb_context[17]);
-	case 64: return (&kdb_thrctx->pcb_lr);
-	}
+	if (regnum == 1)
+		return (&kdb_thrctx->pcb_sp);
+	if (regnum >= 14 && regnum <= 31)
+		return (kdb_thrctx->pcb_context + (regnum - 14));
+	if (regnum == 64)
+		return (&kdb_thrctx->pcb_lr);
 
 	return (NULL);
 }

==== //depot/projects/powerpc/sys/sparc64/include/atomic.h#5 (text+ko) ====

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  *	from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11
- * $FreeBSD: src/sys/sparc64/include/atomic.h,v 1.10 2005/09/27 17:39:11 jhb Exp $
+ * $FreeBSD: src/sys/sparc64/include/atomic.h,v 1.11 2008/03/16 21:20:49 pjd Exp $
  */
 
 #ifndef	_MACHINE_ATOMIC_H_
@@ -279,6 +279,8 @@
 
 #define	atomic_fetchadd_int	atomic_add_int
 #define	atomic_fetchadd_32	atomic_add_32
+#define	atomic_fetchadd_long(p, v) \
+	(u_long)atomic_add_int((volatile u_int *)(p), (u_int)(v))
 
 #undef ATOMIC_GEN
 #undef atomic_cas

==== //depot/projects/powerpc/sys/sun4v/include/atomic.h#2 (text+ko) ====

@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  *	from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11
- * $FreeBSD: src/sys/sun4v/include/atomic.h,v 1.1 2006/10/05 06:14:25 kmacy Exp $
+ * $FreeBSD: src/sys/sun4v/include/atomic.h,v 1.2 2008/03/16 21:20:49 pjd Exp $
  */
 
 #ifndef	_MACHINE_ATOMIC_H_
@@ -279,6 +279,8 @@
 
 #define	atomic_fetchadd_int	atomic_add_int
 #define	atomic_fetchadd_32	atomic_add_32
+#define	atomic_fetchadd_long(p, v) \
+	(u_long)atomic_add_int((volatile u_int *)(p), (u_int)(v))
 
 #undef ATOMIC_GEN
 #undef atomic_cas

==== //depot/projects/powerpc/sys/sys/resourcevar.h#7 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)resourcevar.h	8.4 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/resourcevar.h,v 1.52 2007/06/09 21:48:44 attilio Exp $
+ * $FreeBSD: src/sys/sys/resourcevar.h,v 1.53 2008/03/16 21:29:02 pjd Exp $
  */
 
 #ifndef	_SYS_RESOURCEVAR_H_
@@ -84,21 +84,17 @@
  *
  * Locking guide:
  * (a) Constant from inception
- * (b) Locked by ui_mtxp
+ * (b) Lockless, updated using atomics
  * (c) Locked by global uihashtbl_mtx
  */
 struct uidinfo {
 	LIST_ENTRY(uidinfo) ui_hash;	/* (c) hash chain of uidinfos */
-	rlim_t	ui_sbsize;		/* (b) socket buffer space consumed */
+	long	ui_sbsize;		/* (b) socket buffer space consumed */
 	long	ui_proccnt;		/* (b) number of processes */
 	uid_t	ui_uid;			/* (a) uid */
 	u_int	ui_ref;			/* (b) reference count */
-	struct mtx *ui_mtxp;		/* protect all counts/limits */
 };
 
-#define	UIDINFO_LOCK(ui)	mtx_lock((ui)->ui_mtxp)
-#define	UIDINFO_UNLOCK(ui)	mtx_unlock((ui)->ui_mtxp)
-
 struct proc;
 struct rusage_ext;
 struct thread;
@@ -107,7 +103,7 @@
 void	 addupc_task(struct thread *td, uintfptr_t pc, u_int ticks);
 void	 calccru(struct proc *p, struct timeval *up, struct timeval *sp);
 void	 calcru(struct proc *p, struct timeval *up, struct timeval *sp);
-int	 chgproccnt(struct uidinfo *uip, int diff, int maxval);
+int	 chgproccnt(struct uidinfo *uip, int diff, rlim_t maxval);
 int	 chgsbsize(struct uidinfo *uip, u_int *hiwat, u_int to,
 	    rlim_t maxval);
 int	 fuswintr(void *base);

==== //depot/projects/powerpc/usr.sbin/adduser/adduser.8#4 (text+ko) ====

@@ -24,9 +24,9 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: src/usr.sbin/adduser/adduser.8,v 1.61 2008/01/27 10:15:36 mtm Exp $
+.\" $FreeBSD: src/usr.sbin/adduser/adduser.8,v 1.62 2008/03/16 21:36:05 brueffer Exp $
 .\"
-.Dd June 7, 2006
+.Dd March 16, 2008
 .Dt ADDUSER 8
 .Os
 .Sh NAME
@@ -396,7 +396,7 @@
 empty, its contents will be used
 as a password.
 This field will be ignored if the
-.Fl p
+.Fl w
 option is used with a
 .Cm no
 or

==== //depot/projects/powerpc/usr.sbin/fifolog/lib/miniobj.h#2 (text+ko) ====

@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/usr.sbin/fifolog/lib/miniobj.h,v 1.1 2008/03/09 19:14:36 phk Exp $
+ * $FreeBSD: src/usr.sbin/fifolog/lib/miniobj.h,v 1.2 2008/03/16 23:00:43 phk Exp $
  */
 
 #define ALLOC_OBJ(to, type_magic) 					\
@@ -55,12 +55,12 @@
 		(to) = (from);						\

>>> TRUNCATED FOR MAIL (1000 lines) <<<



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200803170048.m2H0msks092012>