PERFORCE change 56266 for review

John Baldwin jhb at FreeBSD.org
Thu Jul 1 21:20:20 PDT 2004


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

Change 56266 by jhb at jhb_slimer on 2004/07/02 04:13:06

	IFC @56264.

Affected files ...

.. //depot/projects/smpng/sys/alpha/alpha/busdma_machdep.c#22 integrate
.. //depot/projects/smpng/sys/kern/kern_clock.c#35 integrate
.. //depot/projects/smpng/sys/kern/subr_prof.c#25 integrate
.. //depot/projects/smpng/sys/kern/subr_trap.c#65 integrate
.. //depot/projects/smpng/sys/pci/agp_via.c#11 integrate
.. //depot/projects/smpng/sys/sys/resourcevar.h#19 integrate
.. //depot/projects/smpng/sys/vm/vm_glue.c#45 integrate

Differences ...

==== //depot/projects/smpng/sys/alpha/alpha/busdma_machdep.c#22 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/alpha/busdma_machdep.c,v 1.44 2004/03/13 15:42:59 scottl Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/alpha/busdma_machdep.c,v 1.45 2004/07/02 03:47:28 scottl Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -66,6 +66,7 @@
 	int		  map_count;
 	bus_dma_lock_t	 *lockfunc;
 	void		 *lockfuncarg;
+	bus_dma_segment_t *segments;
 };
 
 struct bounce_page {
@@ -221,7 +222,9 @@
 		newtag->lockfunc = dflt_lock;
 		newtag->lockfuncarg = NULL;
 	}
-	
+
+	newtag->segments = NULL;
+
 	/* Take into account any restrictions imposed by our parent tag */
 	if (parent != NULL) {
 		newtag->lowaddr = MIN(parent->lowaddr, newtag->lowaddr);
@@ -290,6 +293,8 @@
 			parent = dmat->parent;
 			atomic_subtract_int(&dmat->ref_count, 1);
 			if (dmat->ref_count == 0) {
+				if (dmat->segments != NULL)
+					free(dmat->segments, M_DEVBUF);
 				free(dmat, M_DEVBUF);
 				/*
 				 * Last reference count, so
@@ -332,6 +337,14 @@
 		return (0);
 	}
 
+	if (dmat->segments == NULL) {
+		dmat->segments = (bus_dma_segment_t *)malloc(
+		    sizeof(bus_dma_segment_t) * dmat->nsegments, M_DEVBUF,
+		    M_NOWAIT);
+		if (dmat->segments == NULL)
+			return (ENOMEM);
+	}
+
 	if (dmat->lowaddr < ptoa(Maxmem)) {
 		/* Must bounce */
 		int maxpages;
@@ -425,6 +438,14 @@
 	/* If we succeed, no mapping/bouncing will be required */
 	*mapp = &nobounce_dmamap;
 
+	if (dmat->segments == NULL) {
+		dmat->segments = (bus_dma_segment_t *)malloc(
+		    sizeof(bus_dma_segment_t) * dmat->nsegments, M_DEVBUF,
+		    M_NOWAIT);
+		if (dmat->segments == NULL)
+			return (ENOMEM);
+	}
+
 	if ((dmat->maxsize <= PAGE_SIZE) && dmat->lowaddr >= ptoa(Maxmem)) {
 		*vaddr = malloc(dmat->maxsize, M_DEVBUF, mflags);
 	} else {
@@ -477,11 +498,6 @@
 {
 	vm_offset_t		vaddr;
 	vm_offset_t		paddr;
-#ifdef __GNUC__
-	bus_dma_segment_t	dm_segments[dmat->nsegments];
-#else
-	bus_dma_segment_t	dm_segments[BUS_DMAMAP_NSEGS];
-#endif
 	bus_dma_segment_t      *sg;
 	int			seg;
 	int			error;
@@ -496,16 +512,16 @@
 		 * of the bus address space.
 		 */
 		vaddr = trunc_page((vm_offset_t) buf);
-		dm_segments[0].ds_addr =
+		dmat->segments[0].ds_addr =
 			map->busaddress + (vm_offset_t) buf - vaddr;
-		dm_segments[0].ds_len = buflen;
+		dmat->segments[0].ds_len = buflen;
 		buflen = round_page((vm_offset_t) buf + buflen) - vaddr;
 		sgmap_load_region(chipset.sgmap,
 				  map->busaddress,
 				  vaddr,
 				  buflen);
 		map->buflen = buflen;
-		(*callback)(callback_arg, dm_segments, 1, error);
+		(*callback)(callback_arg, dmat->segments, 1, error);
 
 		return (0);
 	}
@@ -560,7 +576,7 @@
 	}
 
 	vaddr = (vm_offset_t)buf;
-	sg = &dm_segments[0];
+	sg = &dmat->segments[0];
 	seg = 1;
 	sg->ds_len = 0;
 
@@ -604,7 +620,7 @@
 		error = EFBIG;
 	}
 
-	(*callback)(callback_arg, dm_segments, seg, error);
+	(*callback)(callback_arg, dmat->segments, seg, error);
 
 	return (0);
 }
@@ -617,7 +633,6 @@
  */
 static int
 _bus_dmamap_load_buffer(bus_dma_tag_t dmat,
-			bus_dma_segment_t segs[],
 			void *buf, bus_size_t buflen,
 			struct thread *td,
 			int flags,
@@ -625,12 +640,15 @@
 			int *segp,
 			int first)
 {
+	bus_dma_segment_t *segs;
 	bus_size_t sgsize;
 	bus_addr_t curaddr, lastaddr, baddr, bmask;
 	vm_offset_t vaddr = (vm_offset_t)buf;
 	int seg;
 	pmap_t pmap;
 
+	segs = dmat->segments;
+
 	if (td != NULL)
 		pmap = vmspace_pmap(td->td_proc->p_vmspace);
 	else
@@ -709,11 +727,6 @@
 		     bus_dmamap_callback2_t *callback, void *callback_arg,
 		     int flags)
 {
-#ifdef __GNUC__
-	bus_dma_segment_t dm_segments[dmat->nsegments];
-#else
-	bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
-#endif
 	int nsegs, error;
 
 	KASSERT(dmat->lowaddr >= ptoa(Maxmem) || map != NULL,
@@ -730,7 +743,6 @@
 		for (m = m0; m != NULL && error == 0; m = m->m_next) {
 			if (m->m_len > 0) {
 				error = _bus_dmamap_load_buffer(dmat,
-						dm_segments,
 						m->m_data, m->m_len,
 						NULL, flags, &lastaddr,
 						&nsegs, first);
@@ -743,9 +755,9 @@
 
 	if (error) {
 		/* force "no valid mappings" in callback */
-		(*callback)(callback_arg, dm_segments, 0, 0, error);
+		(*callback)(callback_arg, dmat->segments, 0, 0, error);
 	} else {
-		(*callback)(callback_arg, dm_segments,
+		(*callback)(callback_arg, dmat->segments,
 			    nsegs+1, m0->m_pkthdr.len, error);
 	}
 	return (error);
@@ -761,11 +773,6 @@
 		    int flags)
 {
 	bus_addr_t lastaddr;
-#ifdef __GNUC__
-	bus_dma_segment_t dm_segments[dmat->nsegments];
-#else
-	bus_dma_segment_t dm_segments[BUS_DMAMAP_NSEGS];
-#endif
 	int nsegs, error, first, i;
 	bus_size_t resid;
 	struct iovec *iov;
@@ -796,9 +803,7 @@
 		caddr_t addr = (caddr_t) iov[i].iov_base;
 
 		if (minlen > 0) {
-			error = _bus_dmamap_load_buffer(dmat,
-					dm_segments,
-					addr, minlen,
+			error = _bus_dmamap_load_buffer(dmat, addr, minlen,
 					td, flags, &lastaddr, &nsegs, first);
 			first = 0;
 
@@ -808,9 +813,9 @@
 
 	if (error) {
 		/* force "no valid mappings" in callback */
-		(*callback)(callback_arg, dm_segments, 0, 0, error);
+		(*callback)(callback_arg, dmat->segments, 0, 0, error);
 	} else {
-		(*callback)(callback_arg, dm_segments,
+		(*callback)(callback_arg, dmat->segments,
 			    nsegs+1, uio->uio_resid, error);
 	}
 	return (error);

==== //depot/projects/smpng/sys/kern/kern_clock.c#35 (text+ko) ====

@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/kern_clock.c,v 1.170 2004/06/16 00:26:29 julian Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/kern_clock.c,v 1.171 2004/07/02 03:48:09 jhb Exp $");
 
 #include "opt_ntp.h"
 #include "opt_ddb.h"
@@ -374,7 +374,6 @@
 statclock(frame)
 	register struct clockframe *frame;
 {
-	struct pstats *pstats;
 	struct rusage *ru;
 	struct vmspace *vm;
 	struct thread *td;
@@ -427,16 +426,16 @@
 	sched_clock(td);
 
 	/* Update resource usage integrals and maximums. */
-	if ((pstats = p->p_stats) != NULL &&
-	    (ru = &pstats->p_ru) != NULL &&
-	    (vm = p->p_vmspace) != NULL) {
-		ru->ru_ixrss += pgtok(vm->vm_tsize);
-		ru->ru_idrss += pgtok(vm->vm_dsize);
-		ru->ru_isrss += pgtok(vm->vm_ssize);
-		rss = pgtok(vmspace_resident_count(vm));
-		if (ru->ru_maxrss < rss)
-			ru->ru_maxrss = rss;
-	}
+	MPASS(p->p_stats != NULL);
+	MPASS(p->p_vmspace != NULL);
+	vm = p->p_vmspace;
+	ru = &p->p_stats->p_ru;
+	ru->ru_ixrss += pgtok(vm->vm_tsize);
+	ru->ru_idrss += pgtok(vm->vm_dsize);
+	ru->ru_isrss += pgtok(vm->vm_ssize);
+	rss = pgtok(vmspace_resident_count(vm));
+	if (ru->ru_maxrss < rss)
+		ru->ru_maxrss = rss;
 	mtx_unlock_spin_flags(&sched_lock, MTX_QUIET);
 }
 

==== //depot/projects/smpng/sys/kern/subr_prof.c#25 (text+ko) ====

@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/subr_prof.c,v 1.72 2004/05/29 01:18:14 tjr Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/subr_prof.c,v 1.73 2004/07/02 03:50:47 jhb Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -419,17 +419,19 @@
 
 	p = td->td_proc;
 	if (uap->scale == 0) {
-		PROC_LOCK(td->td_proc);
-		stopprofclock(td->td_proc);
-		PROC_UNLOCK(td->td_proc);
+		PROC_LOCK(p);
+		stopprofclock(p);
+		PROC_UNLOCK(p);
 		return (0);
 	}
+	PROC_LOCK(p);
 	upp = &td->td_proc->p_stats->p_prof;
+	mtx_lock_spin(&sched_lock);
 	upp->pr_off = uap->offset;
 	upp->pr_scale = uap->scale;
 	upp->pr_base = uap->samples;
 	upp->pr_size = uap->size;
-	PROC_LOCK(p);
+	mtx_unlock_spin(&sched_lock);
 	startprofclock(p);
 	PROC_UNLOCK(p);
 
@@ -469,16 +471,20 @@
 	if (ticks == 0)
 		return;
 	prof = &td->td_proc->p_stats->p_prof;
+	mtx_lock_spin(&sched_lock);
 	if (pc < prof->pr_off ||
-	    (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size)
+	    (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) {
+		mtx_unlock_spin(&sched_lock);		
 		return;			/* out of range; ignore */
+	}
 
 	addr = prof->pr_base + i;
+	mtx_unlock_spin(&sched_lock);
 	if ((v = fuswintr(addr)) == -1 || suswintr(addr, v + ticks) == -1) {
-		mtx_lock_spin(&sched_lock);
 		prof->pr_addr = pc;
 		prof->pr_ticks = ticks;
-		td->td_flags |= TDF_OWEUPC | TDF_ASTPENDING ;
+		mtx_lock_spin(&sched_lock);
+		td->td_flags |= TDF_OWEUPC | TDF_ASTPENDING;
 		mtx_unlock_spin(&sched_lock);
 	}
 }
@@ -506,7 +512,6 @@
 		return;
 	}
 	p->p_profthreads++;
-	PROC_UNLOCK(p);
 	prof = &p->p_stats->p_prof;
 	if (pc < prof->pr_off ||
 	    (i = PC_TO_INDEX(pc, prof)) >= prof->pr_size) {
@@ -514,15 +519,18 @@
 	}
 
 	addr = prof->pr_base + i;
+	PROC_UNLOCK(p);
 	if (copyin(addr, &v, sizeof(v)) == 0) {
 		v += ticks;
-		if (copyout(&v, addr, sizeof(v)) == 0)
+		if (copyout(&v, addr, sizeof(v)) == 0) {
+			PROC_LOCK(p);
 			goto out;
+		}
 	}
 	stop = 1;
+	PROC_LOCK(p);
 
 out:
-	PROC_LOCK(p);
 	if (--p->p_profthreads == 0) {
 		if (p->p_flag & P_STOPPROF) {
 			wakeup(&p->p_profthreads);

==== //depot/projects/smpng/sys/kern/subr_trap.c#65 (text+ko) ====

@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/kern/subr_trap.c,v 1.266 2004/03/31 08:20:44 julian Exp $");
+__FBSDID("$FreeBSD: src/sys/kern/subr_trap.c,v 1.267 2004/07/02 03:50:47 jhb Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_mac.h"
@@ -142,7 +142,7 @@
 	struct proc *p;
 	struct ksegrp *kg;
 	struct rlimit rlim;
-	u_int prticks, sticks;
+	u_int sticks;
 	int sflag;
 	int flags;
 	int sig;
@@ -180,11 +180,6 @@
 	td->td_flags &= ~(TDF_ASTPENDING | TDF_NEEDSIGCHK |
 	    TDF_NEEDRESCHED | TDF_OWEUPC | TDF_INTERRUPT);
 	cnt.v_soft++;
-	prticks = 0;
-	if (flags & TDF_OWEUPC && p->p_flag & P_PROFIL) {
-		prticks = p->p_stats->p_prof.pr_ticks;
-		p->p_stats->p_prof.pr_ticks = 0;
-	}
 	mtx_unlock_spin(&sched_lock);
 	/*
 	 * XXXKSE While the fact that we owe a user profiling
@@ -196,8 +191,11 @@
 
 	if (td->td_ucred != p->p_ucred) 
 		cred_update_thread(td);
-	if (flags & TDF_OWEUPC && p->p_flag & P_PROFIL)
-		addupc_task(td, p->p_stats->p_prof.pr_addr, prticks);
+	if (flags & TDF_OWEUPC && p->p_flag & P_PROFIL) {
+		addupc_task(td, p->p_stats->p_prof.pr_addr,
+		    p->p_stats->p_prof.pr_ticks);
+		p->p_stats->p_prof.pr_ticks = 0;
+	}
 	if (sflag & PS_ALRMPEND) {
 		PROC_LOCK(p);
 		psignal(p, SIGVTALRM);

==== //depot/projects/smpng/sys/pci/agp_via.c#11 (text+ko) ====

@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/pci/agp_via.c,v 1.15 2004/05/30 20:00:40 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/pci/agp_via.c,v 1.16 2004/07/02 03:39:33 jhb Exp $");
 
 #include "opt_bus.h"
 
@@ -89,6 +89,8 @@
 		return ("VIA 82C691 (Apollo Pro) host to PCI bridge");
 	case 0x31881106:
 		return ("VIA 8385 host to PCI bridge");
+	case 0x31891106:
+		return ("VIA 8377 (Apollo KT400/KT400A/KT600) host to PCI bridge");
 	};
 
 	if (pci_get_vendor(dev) == 0x1106)
@@ -123,6 +125,7 @@
 
 	switch (pci_get_devid(dev)) {
 	case 0x31881106:
+	case 0x31891106:
 		sc->regs = via_v3_regs;
 		break;
 	default:

==== //depot/projects/smpng/sys/sys/resourcevar.h#19 (text+ko) ====

@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *	@(#)resourcevar.h	8.4 (Berkeley) 1/9/95
- * $FreeBSD: src/sys/sys/resourcevar.h,v 1.41 2004/04/07 04:19:49 imp Exp $
+ * $FreeBSD: src/sys/sys/resourcevar.h,v 1.42 2004/07/02 03:50:48 jhb Exp $
  */
 
 #ifndef	_SYS_RESOURCEVAR_H_
@@ -43,25 +43,31 @@
 /*
  * Kernel per-process accounting / statistics
  * (not necessarily resident except when running).
+ *
+ * Locking key:
+ *      b - created at fork, never changes
+ *      c - locked by proc mtx
+ *      j - locked by sched_lock mtx
+ *      k - only accessed by curthread
  */
 struct pstats {
 #define	pstat_startzero	p_ru
-	struct	rusage p_ru;		/* stats for this proc */
-	struct	rusage p_cru;		/* sum of stats for reaped children */
-	struct	itimerval p_timer[3];	/* virtual-time timers */
+	struct	rusage p_ru;		/* Stats for this process. */
+	struct	rusage p_cru;		/* Stats for reaped children. */
+	struct	itimerval p_timer[3];	/* (j) Virtual-time timers. */
 #define	pstat_endzero	pstat_startcopy
 
 #define	pstat_startcopy	p_prof
-	struct uprof {			/* profile arguments */
-		caddr_t	pr_base;	/* buffer base */
-		u_long	pr_size;	/* buffer size */
-		u_long	pr_off;		/* pc offset */
-		u_long	pr_scale;	/* pc scaling */
-		u_long	pr_addr;	/* temp storage for addr until AST */
-		u_int	pr_ticks;	/* temp storage for ticks until AST */
+	struct uprof {			/* Profile arguments. */
+		caddr_t	pr_base;	/* (c + j) Buffer base. */
+		u_long	pr_size;	/* (c + j) Buffer size. */
+		u_long	pr_off;		/* (c + j) PC offset. */
+		u_long	pr_scale;	/* (c + j) PC scaling. */
+		u_long	pr_addr;	/* (k) Temporary addr until AST. */
+		u_int	pr_ticks;	/* (k) Temporary ticks until AST. */
 	} p_prof;
 #define	pstat_endcopy	p_start
-	struct	timeval p_start;	/* starting time */
+	struct	timeval p_start;	/* (b) Starting time. */
 };
 
 #ifdef _KERNEL

==== //depot/projects/smpng/sys/vm/vm_glue.c#45 (text+ko) ====

@@ -57,7 +57,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/vm/vm_glue.c,v 1.199 2004/06/27 01:58:12 das Exp $");
+__FBSDID("$FreeBSD: src/sys/vm/vm_glue.c,v 1.200 2004/07/02 03:45:07 jhb Exp $");
 
 #include "opt_vm.h"
 #include "opt_kstack_pages.h"
@@ -618,7 +618,6 @@
 	int flags;
 {
 	struct proc *p1 = td->td_proc;
-	struct user *up;
 
 	GIANT_REQUIRED;
 
@@ -652,22 +651,18 @@
 			shmfork(p1, p2);
 	}
 
-	/* XXXKSE this is unsatisfactory but should be adequate */
-	up = p2->p_uarea;
-	MPASS(p2->p_sigacts != NULL);
-
 	/*
-	 * p_stats currently points at fields in the user struct
-	 * but not at &u, instead at p_addr. Copy parts of
-	 * p_stats; zero the rest of p_stats (statistics).
+	 * p_stats currently points at fields in the user struct.
+	 * Copy parts of p_stats; zero the rest of p_stats (statistics).
 	 */
-	p2->p_stats = &up->u_stats;
-	bzero(&up->u_stats.pstat_startzero,
-	    (unsigned) ((caddr_t) &up->u_stats.pstat_endzero -
-		(caddr_t) &up->u_stats.pstat_startzero));
-	bcopy(&p1->p_stats->pstat_startcopy, &up->u_stats.pstat_startcopy,
-	    ((caddr_t) &up->u_stats.pstat_endcopy -
-		(caddr_t) &up->u_stats.pstat_startcopy));
+#define	RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
+
+	p2->p_stats = &p2->p_uarea->u_stats;
+	bzero(&p2->p_stats->pstat_startzero,
+	    (unsigned) RANGEOF(struct pstats, pstat_startzero, pstat_endzero));
+	bcopy(&p1->p_stats->pstat_startcopy, &p2->p_stats->pstat_startcopy,
+	    (unsigned) RANGEOF(struct pstats, pstat_startcopy, pstat_endcopy));
+#undef RANGEOF
 
 	/*
 	 * cpu_fork will copy and update the pcb, set up the kernel stack,


More information about the p4-projects mailing list