[FreeBSD-CVS] cvs commit: src/sys/dev/twa twa_cam.c twa_globals.c twa_ioctl.h

Ralf S. Engelschall rse at FreeBSD.org
Fri Feb 11 13:22:17 GMT 2005


On Thu, Feb 10, 2005, Vinod Kashyap wrote:

> [...]
>     sys/dev/twa          twa_cam.c twa_globals.c twa_ioctl.h
>   Log:
>   1. Revert back to the way the older driver handled XPT_PATH_INQ.  This seems to
>      fix the problem with device discovery seen by some people.
> [...]
> Index: src/sys/dev/twa/twa_cam.c
> diff -u src/sys/dev/twa/twa_cam.c:1.4 src/sys/dev/twa/twa_cam.c:1.5
> --- src/sys/dev/twa/twa_cam.c:1.4	Wed Jan  5 19:04:28 2005
> +++ src/sys/dev/twa/twa_cam.c	Thu Feb 10 18:07:33 2005
> @@ -409,9 +409,9 @@
>  		twa_dbg_dprint(3, sc, "XPT_PATH_INQ request");
>
>  		path_inq->version_num = 1;
> -		path_inq->hba_inquiry = PI_WIDE_16;
> +		path_inq->hba_inquiry = 0;
>  		path_inq->target_sprt = 0;
> -		path_inq->hba_misc |= PIM_NOBUSRESET;
> +		path_inq->hba_misc = 0;
>  		path_inq->hba_eng_cnt = 0;
>  		path_inq->max_target = TWA_MAX_UNITS;
>  		path_inq->max_lun = 0;
> [...]

The same problem (3ware controller found, but device /dev/daX not
discovered on booting and hence no root mount point) popped up for
me yesterday under RELENG_5, too. The problem can be traced back to
changes between 2005-02-03 (date of my old still working kernel) and
2005-02-10 (date of my new broken kernel). The whole diff to sys/
of RELENG_5 is about 350 KB (I used "cvs diff -jRELENG_5:2005-02-03
-jRELENG_5:2005-02-10") and I was at least able to reduce the origin of
the problem to the appended 29 KB change set.

With the latest RELENG_5 as of 2005-02-11 (today) but with this appended
patch again backed out, the twa(4) problem is solved, too. Similarily,
if I do not back out those changes and just use plain RELENG_5 as of
2005-02-11 with your patch above applied it is also solved.

I guess your patch workarounds the problem, but the real origin of the
problem is somewhere in the changes we can see in the appended patch.
Unfortunately I do not understand the side-effects of those changes so I
was not able to figure out myself which part of the change is actually
causing the trouble for the twa(4) driver.

Perhaps someone else can jump in and fix the origin of the problem...

--
rse at FreeBSD.org                        Ralf S. Engelschall
FreeBSD.org/~rse                       rse at engelschall.com
FreeBSD committer                      www.engelschall.com

-------------- next part --------------
Index: i386/i386/genassym.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/i386/i386/genassym.c,v
retrieving revision 1.148
retrieving revision 1.148.2.1
diff -u -d -r1.148 -r1.148.2.1
--- i386/i386/genassym.c	23 May 2004 16:50:55 -0000	1.148
+++ i386/i386/genassym.c	5 Feb 2005 01:02:05 -0000	1.148.2.1
@@ -50,8 +50,8 @@
 #include <sys/mutex.h>
 #include <sys/socket.h>
 #include <sys/resourcevar.h>
+#include <sys/signalvar.h>
 #include <sys/ucontext.h>
-#include <sys/user.h>
 #include <machine/bootinfo.h>
 #include <machine/tss.h>
 #include <sys/vmmeter.h>
@@ -59,7 +59,6 @@
 #include <vm/vm_param.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
-#include <sys/user.h>
 #include <sys/proc.h>
 #include <net/if.h>
 #include <netinet/in.h>
@@ -71,6 +70,7 @@
 #include <machine/apicreg.h>
 #endif
 #include <machine/cpu.h>
+#include <machine/pcb.h>
 #include <machine/sigframe.h>
 #include <machine/vm86.h>
 #include <machine/proc.h>
@@ -79,7 +79,6 @@
 ASSYM(VM_PMAP, offsetof(struct vmspace, vm_pmap));
 ASSYM(PM_ACTIVE, offsetof(struct pmap, pm_active));
 ASSYM(P_SFLAG, offsetof(struct proc, p_sflag));
-ASSYM(P_UAREA, offsetof(struct proc, p_uarea));
 
 ASSYM(TD_FLAGS, offsetof(struct thread, td_flags));
 ASSYM(TD_PCB, offsetof(struct thread, td_pcb));
@@ -96,7 +95,6 @@
 ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall));
 ASSYM(V_INTR, offsetof(struct vmmeter, v_intr));
 /* ASSYM(UPAGES, UPAGES);*/
-ASSYM(UAREA_PAGES, UAREA_PAGES);
 ASSYM(KSTACK_PAGES, KSTACK_PAGES);
 ASSYM(PAGE_SIZE, PAGE_SIZE);
 ASSYM(NPTEPG, NPTEPG);
Index: i386/i386/locore.s
===================================================================
RCS file: /v/freebsd/cvs/src/sys/i386/i386/locore.s,v
retrieving revision 1.184
retrieving revision 1.184.2.1
diff -u -d -r1.184 -r1.184.2.1
--- i386/i386/locore.s	8 Jul 2004 22:35:34 -0000	1.184
+++ i386/i386/locore.s	5 Feb 2005 01:01:40 -0000	1.184.2.1
@@ -129,10 +129,10 @@
 #endif
 KPTphys:	.long	0		/* phys addr of kernel page tables */
 
-	.globl	proc0uarea, proc0kstack
-proc0uarea:	.long	0		/* address of proc 0 uarea space */
+	.globl	proc0kstack
+proc0uarea:	.long	0		/* address of proc 0 uarea (unused)*/
 proc0kstack:	.long	0		/* address of proc 0 kstack space */
-p0upa:		.long	0		/* phys addr of proc0's UAREA */
+p0upa:		.long	0		/* phys addr of proc0 UAREA (unused) */
 p0kpa:		.long	0		/* phys addr of proc0's STACK */
 
 vm86phystk:	.long	0		/* PA of vm86/bios stack */
@@ -748,12 +748,7 @@
 	ALLOCPAGES(NPGPTD)
 	movl	%esi,R(IdlePTD)
 
-/* Allocate UPAGES */
-	ALLOCPAGES(UAREA_PAGES)
-	movl	%esi,R(p0upa)
-	addl	$KERNBASE, %esi
-	movl	%esi, R(proc0uarea)
-
+/* Allocate KSTACK */
 	ALLOCPAGES(KSTACK_PAGES)
 	movl	%esi,R(p0kpa)
 	addl	$KERNBASE, %esi
@@ -847,11 +842,6 @@
 	movl	$NPGPTD, %ecx
 	fillkptphys($PG_RW)
 
-/* Map proc0's UPAGES in the physical way ... */
-	movl	R(p0upa), %eax
-	movl	$(UAREA_PAGES), %ecx
-	fillkptphys($PG_RW)
-
 /* Map proc0's KSTACK in the physical way ... */
 	movl	R(p0kpa), %eax
 	movl	$(KSTACK_PAGES), %ecx
Index: i386/i386/machdep.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/i386/i386/machdep.c,v
retrieving revision 1.597.2.2
retrieving revision 1.597.2.3
diff -u -d -r1.597.2.2 -r1.597.2.3
--- i386/i386/machdep.c	23 Nov 2004 21:08:13 -0000	1.597.2.2
+++ i386/i386/machdep.c	5 Feb 2005 01:01:47 -0000	1.597.2.3
@@ -91,7 +91,6 @@
 #include <vm/vm_pager.h>
 #include <vm/vm_extern.h>
 
-#include <sys/user.h>
 #include <sys/exec.h>
 #include <sys/cons.h>
 
@@ -114,7 +113,8 @@
 #include <machine/intr_machdep.h>
 #include <machine/md_var.h>
 #include <machine/pc/bios.h>
-#include <machine/pcb_ext.h>		/* pcb.h included via sys/user.h */
+#include <machine/pcb.h>
+#include <machine/pcb_ext.h>
 #include <machine/proc.h>
 #ifdef PERFMON
 #include <machine/perfmon.h>
@@ -1236,7 +1236,6 @@
 static struct i386tss dblfault_tss;
 static char dblfault_stack[PAGE_SIZE];
 
-extern  struct user	*proc0uarea;
 extern  vm_offset_t	proc0kstack;
 
 
@@ -1943,7 +1942,6 @@
 	int gsel_tss, metadata_missing, off, x;
 	struct pcpu *pc;
 
-	proc0.p_uarea = proc0uarea;
 	thread0.td_kstack = proc0kstack;
 	thread0.td_pcb = (struct pcb *)
 	   (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
Index: i386/include/param.h
===================================================================
RCS file: /v/freebsd/cvs/src/sys/i386/include/param.h,v
retrieving revision 1.72.2.1
retrieving revision 1.72.2.2
diff -u -d -r1.72.2.1 -r1.72.2.2
--- i386/include/param.h	10 Sep 2004 00:04:17 -0000	1.72.2.1
+++ i386/include/param.h	5 Feb 2005 01:01:53 -0000	1.72.2.2
@@ -103,7 +103,6 @@
 #define KSTACK_PAGES 2		/* Includes pcb! */
 #endif
 #define KSTACK_GUARD_PAGES 1	/* pages of kstack guard; 0 disables */
-#define UAREA_PAGES 1		/* holds struct user WITHOUT PCB (see def.) */
 
 /*
  * Ceiling on amount of swblock kva space, can be changed via
Index: kern/init_main.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/kern/init_main.c,v
retrieving revision 1.246.2.3
retrieving revision 1.246.2.4
diff -u -d -r1.246.2.3 -r1.246.2.4
--- kern/init_main.c	31 Jan 2005 23:26:15 -0000	1.246.2.3
+++ kern/init_main.c	5 Feb 2005 00:59:42 -0000	1.246.2.4
@@ -80,7 +80,6 @@
 #include <vm/vm_param.h>
 #include <vm/pmap.h>
 #include <vm/vm_map.h>
-#include <sys/user.h>
 #include <sys/copyright.h>
 
 void mi_startup(void);				/* Should be elsewhere */
@@ -433,6 +432,8 @@
 	p->p_limit->pl_rlimit[RLIMIT_MEMLOCK].rlim_cur = i / 3;
 	p->p_cpulimit = RLIM_INFINITY;
 
+	p->p_stats = pstats_alloc();
+
 	/* Allocate a prototype map so we have something to fork. */
 	pmap_pinit0(vmspace_pmap(&vmspace0));
 	p->p_vmspace = &vmspace0;
@@ -442,12 +443,6 @@
 	vmspace0.vm_map.pmap = vmspace_pmap(&vmspace0);
 
 	/*
-	 * We continue to place resource usage info
-	 * in the user struct so that it's pageable.
-	 */
-	p->p_stats = &p->p_uarea->u_stats;
-
-	/*
 	 * Charge root for one process.
 	 */
 	(void)chgproccnt(p->p_ucred->cr_ruidinfo, 1, 0);
Index: kern/kern_fork.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.234.2.6
retrieving revision 1.234.2.7
diff -u -d -r1.234.2.6 -r1.234.2.7
--- kern/kern_fork.c	31 Jan 2005 23:26:15 -0000	1.234.2.6
+++ kern/kern_fork.c	5 Feb 2005 00:59:46 -0000	1.234.2.7
@@ -64,6 +64,7 @@
 #include <sys/ktrace.h>
 #include <sys/unistd.h>	
 #include <sys/sx.h>
+#include <sys/signalvar.h>
 
 #include <vm/vm.h>
 #include <vm/pmap.h>
@@ -71,7 +72,6 @@
 #include <vm/vm_extern.h>
 #include <vm/uma.h>
 
-#include <sys/user.h>
 #include <machine/critical.h>
 
 #ifndef _SYS_SYSPROTO_H_
@@ -473,29 +473,25 @@
 	PROC_LOCK(p2);
 	PROC_LOCK(p1);
 
-#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
-
 	bzero(&p2->p_startzero,
-	    (unsigned) RANGEOF(struct proc, p_startzero, p_endzero));
+	    __rangeof(struct proc, p_startzero, p_endzero));
 	bzero(&td2->td_startzero,
-	    (unsigned) RANGEOF(struct thread, td_startzero, td_endzero));
+	    __rangeof(struct thread, td_startzero, td_endzero));
 	bzero(&kg2->kg_startzero,
-	    (unsigned) RANGEOF(struct ksegrp, kg_startzero, kg_endzero));
+	    __rangeof(struct ksegrp, kg_startzero, kg_endzero));
 
 	bcopy(&p1->p_startcopy, &p2->p_startcopy,
-	    (unsigned) RANGEOF(struct proc, p_startcopy, p_endcopy));
+	    __rangeof(struct proc, p_startcopy, p_endcopy));
 	bcopy(&td->td_startcopy, &td2->td_startcopy,
-	    (unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy));
+	    __rangeof(struct thread, td_startcopy, td_endcopy));
 	bcopy(&td->td_ksegrp->kg_startcopy, &kg2->kg_startcopy,
-	    (unsigned) RANGEOF(struct ksegrp, kg_startcopy, kg_endcopy));
-#undef RANGEOF
+	    __rangeof(struct ksegrp, kg_startcopy, kg_endcopy));
 
 	td2->td_sigstk = td->td_sigstk;
 
 	/*
 	 * Duplicate sub-structures as needed.
 	 * Increase reference counts on shared objects.
-	 * The p_stats substruct is set in vm_forkproc.
 	 */
 	p2->p_flag = 0;
 	if (p1->p_flag & P_PROFIL)
@@ -533,6 +529,9 @@
 	 * p_limit is copy-on-write.  Bump its refcount.
 	 */
 	p2->p_limit = lim_hold(p1->p_limit);
+
+	pstats_fork(p1->p_stats, p2->p_stats);
+
 	PROC_UNLOCK(p1);
 	PROC_UNLOCK(p2);
 
Index: kern/kern_kse.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/kern/kern_kse.c,v
retrieving revision 1.193.2.11
retrieving revision 1.193.2.12
diff -u -d -r1.193.2.11 -r1.193.2.12
--- kern/kern_kse.c	31 Jan 2005 23:26:15 -0000	1.193.2.11
+++ kern/kern_kse.c	5 Feb 2005 01:04:45 -0000	1.193.2.12
@@ -60,8 +60,6 @@
 extern struct mtx kse_zombie_lock;
 
 
-#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
-
 TAILQ_HEAD(, kse_upcall) zombie_upcalls =
 	TAILQ_HEAD_INITIALIZER(zombie_upcalls);
 
@@ -582,10 +580,10 @@
 
 	if (uap->newgroup) {
 		newkg = ksegrp_alloc();
-		bzero(&newkg->kg_startzero, RANGEOF(struct ksegrp,
-		      kg_startzero, kg_endzero));
+		bzero(&newkg->kg_startzero,
+		    __rangeof(struct ksegrp, kg_startzero, kg_endzero));
 		bcopy(&kg->kg_startcopy, &newkg->kg_startcopy,
-		      RANGEOF(struct ksegrp, kg_startcopy, kg_endcopy));
+		    __rangeof(struct ksegrp, kg_startcopy, kg_endcopy));
 		sched_init_concurrency(newkg);
 		PROC_LOCK(p);
 		if (p->p_numksegrps >= max_groups_per_proc) {
@@ -1014,7 +1012,7 @@
 	spare = thread_alloc();
 	td->td_standin = spare;
 	bzero(&spare->td_startzero,
-	    (unsigned) RANGEOF(struct thread, td_startzero, td_endzero));
+	    __rangeof(struct thread, td_startzero, td_endzero));
 	spare->td_proc = td->td_proc;
 	spare->td_ucred = crhold(td->td_ucred);
 }
@@ -1049,7 +1047,7 @@
 	 * do the crhold here because we are in schedlock already.
 	 */
 	bcopy(&td->td_startcopy, &td2->td_startcopy,
-	    (unsigned) RANGEOF(struct thread, td_startcopy, td_endcopy));
+	    __rangeof(struct thread, td_startcopy, td_endcopy));
 	thread_link(td2, ku->ku_ksegrp);
 	/* inherit parts of blocked thread's context as a good template */
 	cpu_set_upcall(td2, td);
Index: kern/kern_proc.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.215.2.2
retrieving revision 1.215.2.3
diff -u -d -r1.215.2.2 -r1.215.2.3
--- kern/kern_proc.c	31 Jan 2005 23:26:16 -0000	1.215.2.2
+++ kern/kern_proc.c	5 Feb 2005 00:59:49 -0000	1.215.2.3
@@ -96,9 +96,7 @@
 uma_zone_t ithread_zone;
 
 int kstack_pages = KSTACK_PAGES;
-int uarea_pages = UAREA_PAGES;
 SYSCTL_INT(_kern, OID_AUTO, kstack_pages, CTLFLAG_RD, &kstack_pages, 0, "");
-SYSCTL_INT(_kern, OID_AUTO, uarea_pages, CTLFLAG_RD, &uarea_pages, 0, "");
 
 CTASSERT(sizeof(struct kinfo_proc) == KINFO_PROC_SIZE);
 
@@ -179,11 +177,11 @@
 
 	p = (struct proc *)mem;
 	p->p_sched = (struct p_sched *)&p[1];
-	vm_proc_new(p);
 	td = thread_alloc();
 	kg = ksegrp_alloc();
 	bzero(&p->p_mtx, sizeof(struct mtx));
 	mtx_init(&p->p_mtx, "process lock", NULL, MTX_DEF | MTX_DUPOK);
+	p->p_stats = pstats_alloc();
 	proc_linkup(p, kg, td);
 	sched_newproc(p, kg, td);
 	return (0);
@@ -206,7 +204,6 @@
 	KASSERT((td != NULL), ("proc_fini: bad thread pointer"));
         kg = FIRST_KSEGRP_IN_PROC(p);
 	KASSERT((kg != NULL), ("proc_fini: bad kg pointer"));
-	vm_proc_dispose(p);
 	sched_destroyproc(p);
 	thread_free(td);
 	ksegrp_free(kg);
@@ -672,8 +669,6 @@
 
 		kp->ki_size = vm->vm_map.size;
 		kp->ki_rssize = vmspace_resident_count(vm); /*XXX*/
-		if (p->p_sflag & PS_INMEM)
-			kp->ki_rssize += UAREA_PAGES;
 		FOREACH_THREAD_IN_PROC(p, td0) {
 			if (!TD_IS_SWAPPED(td0))
 				kp->ki_rssize += td0->td_kstack_pages;
@@ -817,6 +812,33 @@
 		kp->ki_ppid = p->p_pptr->p_pid;
 }
 
+struct pstats *
+pstats_alloc(void)
+{
+
+	return (malloc(sizeof(struct pstats), M_SUBPROC, M_ZERO|M_WAITOK));
+}
+
+/*
+ * Copy parts of p_stats; zero the rest of p_stats (statistics).
+ */
+void
+pstats_fork(struct pstats *src, struct pstats *dst)
+{
+
+	bzero(&dst->pstat_startzero,
+	    __rangeof(struct pstats, pstat_startzero, pstat_endzero));
+	bcopy(&src->pstat_startcopy, &dst->pstat_startcopy,
+	    __rangeof(struct pstats, pstat_startcopy, pstat_endcopy));
+}
+
+void
+pstats_free(struct pstats *ps)
+{
+
+	free(ps, M_SUBPROC);
+}
+
 /*
  * Locate a zombie process by number
  */
Index: kern/kern_switch.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/kern/kern_switch.c,v
retrieving revision 1.78.2.15
retrieving revision 1.78.2.18
diff -u -d -r1.78.2.15 -r1.78.2.18
--- kern/kern_switch.c	31 Jan 2005 23:26:16 -0000	1.78.2.15
+++ kern/kern_switch.c	5 Feb 2005 01:04:45 -0000	1.78.2.18
@@ -456,6 +456,9 @@
 	struct ksegrp *kg;
 	struct thread *td2;
 	struct thread *tda;
+	CTR5(KTR_SCHED, "setrunqueue: %p(%s) prio %d by %p(%s)",
+            td, td->td_proc->p_comm, td->td_priority, curthread,
+            curthread->td_proc->p_comm);
 
 	CTR3(KTR_RUNQ, "setrunqueue: td:%p kg:%p pid:%d",
 	    td, td->td_ksegrp, td->td_proc->p_pid);
@@ -910,7 +913,6 @@
 
 /****** functions that are temporarily here ***********/
 #include <vm/uma.h>
-#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
 extern struct mtx kse_zombie_lock;
 
 /*
@@ -945,7 +947,6 @@
 	KASSERT((p->p_numksegrps == 1), ("Cached proc with > 1 ksegrp "));
 }
 
-#define RANGEOF(type, start, end) (offsetof(type, end) - offsetof(type, start))
 /*
  * thread is being either created or recycled.
  * Fix up the per-scheduler resources associated with it.
@@ -963,7 +964,6 @@
 	bzero(ke, sizeof(*ke));
 	td->td_sched     = ke;
 	ke->ke_thread	= td;
-	ke->ke_oncpu	= NOCPU;
 	ke->ke_state	= KES_THREAD;
 }
 
Index: pc98/i386/machdep.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/pc98/i386/machdep.c,v
retrieving revision 1.342.2.2
retrieving revision 1.342.2.3
diff -u -d -r1.342.2.2 -r1.342.2.3
--- pc98/i386/machdep.c	23 Nov 2004 21:08:14 -0000	1.342.2.2
+++ pc98/i386/machdep.c	5 Feb 2005 01:01:47 -0000	1.342.2.3
@@ -88,7 +88,6 @@
 #include <vm/vm_pager.h>
 #include <vm/vm_extern.h>
 
-#include <sys/user.h>
 #include <sys/exec.h>
 #include <sys/cons.h>
 
@@ -111,7 +110,8 @@
 #include <machine/intr_machdep.h>
 #include <machine/md_var.h>
 #include <machine/pc/bios.h>
-#include <machine/pcb_ext.h>		/* pcb.h included via sys/user.h */
+#include <machine/pcb.h>
+#include <machine/pcb_ext.h>
 #include <machine/proc.h>
 #ifdef PERFMON
 #include <machine/perfmon.h>
@@ -1253,7 +1253,6 @@
 static struct i386tss dblfault_tss;
 static char dblfault_stack[PAGE_SIZE];
 
-extern  struct user	*proc0uarea;
 extern  vm_offset_t	proc0kstack;
 
 
@@ -2002,7 +2001,6 @@
 	int gsel_tss, metadata_missing, off, x;
 	struct pcpu *pc;
 
-	proc0.p_uarea = proc0uarea;
 	thread0.td_kstack = proc0kstack;
 	thread0.td_pcb = (struct pcb *)
 	   (thread0.td_kstack + KSTACK_PAGES * PAGE_SIZE) - 1;
Index: sys/ktr.h
===================================================================
RCS file: /v/freebsd/cvs/src/sys/sys/ktr.h,v
retrieving revision 1.22.2.4
retrieving revision 1.22.2.5
diff -u -d -r1.22.2.4 -r1.22.2.5
--- sys/ktr.h	30 Jan 2005 03:02:09 -0000	1.22.2.4
+++ sys/ktr.h	4 Feb 2005 19:59:43 -0000	1.22.2.5
@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- *	from BSDI $Id: ktr.h,v 1.22.2.4 2005/01/30 03:02:09 rwatson Exp $
+ *	from BSDI $Id: ktr.h,v 1.22.2.5 2005/02/04 19:59:43 jeff Exp $
  * $FreeBSD$
  */
 
@@ -77,7 +77,8 @@
 #define	KTR_GEOM	0x04000000		/* GEOM I/O events */
 #define	KTR_BUSDMA	0x08000000		/* busdma(9) events */
 #define	KTR_CRITICAL	0x10000000		/* Critical sections */
-#define	KTR_ALL		0x1fffffff
+#define	KTR_SCHED	0x20000000		/* Machine parsed sched info. */
+#define	KTR_ALL		0x3fffffff
 
 /*
  * Trace classes which can be assigned to particular use at compile time
Index: sys/proc.h
===================================================================
RCS file: /v/freebsd/cvs/src/sys/sys/proc.h,v
retrieving revision 1.392.2.13
retrieving revision 1.392.2.14
diff -u -d -r1.392.2.13 -r1.392.2.14
--- sys/proc.h	22 Oct 2004 18:48:42 -0000	1.392.2.13
+++ sys/proc.h	5 Feb 2005 01:02:31 -0000	1.392.2.14
@@ -502,7 +502,7 @@
 					/* Accumulated stats for all threads? */
 	struct pstats	*p_stats;	/* (b) Accounting/statistics (CPU). */
 	struct plimit	*p_limit;	/* (c) Process limits. */
-	struct vm_object *p_upages_obj; /* (a) Upages object. */
+	struct vm_object *p_unused1;	/* (a) Former upages object */
 	struct sigacts	*p_sigacts;	/* (x) Signal actions, state (CPU). */
 	/*
 	 * The following don't make too much sense..
@@ -579,7 +579,7 @@
 	int		p_numksegrps;	/* (c) number of ksegrps */
 	struct mdproc	p_md;		/* Any machine-dependent fields. */
 	struct callout	p_itcallout;	/* (h + c) Interval timer callout. */
-	struct user	*p_uarea;	/* (k) Kernel VA of u-area (CPU). */
+	struct user	*p_unused2;	/* (k) Formerly U-area. */
 	u_short		p_acflag;	/* (c) Accounting flags. */
 	struct rusage	*p_ru;		/* (a) Exit information. XXX */
 	struct proc	*p_peers;	/* (r) */
@@ -843,6 +843,9 @@
 void	threadinit(void);
 void	proc_linkup(struct proc *p, struct ksegrp *kg, struct thread *td);
 void	proc_reparent(struct proc *child, struct proc *newparent);
+struct pstats *pstats_alloc(void);
+void	pstats_fork(struct pstats *src, struct pstats *dst);
+void	pstats_free(struct pstats *ps);
 int	securelevel_ge(struct ucred *cr, int level);
 int	securelevel_gt(struct ucred *cr, int level);
 void	setrunnable(struct thread *);
Index: sys/systm.h
===================================================================
RCS file: /v/freebsd/cvs/src/sys/sys/systm.h,v
retrieving revision 1.213
retrieving revision 1.213.2.1
diff -u -d -r1.213 -r1.213.2.1
--- sys/systm.h	5 Aug 2004 07:15:35 -0000	1.213
+++ sys/systm.h	5 Feb 2005 01:02:34 -0000	1.213.2.1
@@ -53,7 +53,6 @@
 extern char version[];		/* system version */
 extern char copyright[];	/* system copyright */
 extern int kstack_pages;	/* number of kernel stack pages */
-extern int uarea_pages;		/* number of user struct pages */
 
 extern int nswap;		/* size of swap space */
 
Index: vm/swap_pager.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/vm/swap_pager.c,v
retrieving revision 1.256.2.3
retrieving revision 1.256.2.4
diff -u -d -r1.256.2.3 -r1.256.2.4
--- vm/swap_pager.c	31 Jan 2005 23:27:02 -0000	1.256.2.3
+++ vm/swap_pager.c	5 Feb 2005 00:59:57 -0000	1.256.2.4
@@ -2211,9 +2211,6 @@
 	/*
 	 * Page in the contents of the device and close it.
 	 */
-#ifndef NO_SWAPPING
-       	vm_proc_swapin_all(sp);
-#endif /* !NO_SWAPPING */
 	swap_pager_swapoff(sp);
 
 	sp->sw_close(td, sp);
Index: vm/vm_extern.h
===================================================================
RCS file: /v/freebsd/cvs/src/sys/vm/vm_extern.h,v
retrieving revision 1.74
retrieving revision 1.74.2.1
diff -u -d -r1.74 -r1.74.2.1
--- vm/vm_extern.h	25 Jul 2004 20:08:59 -0000	1.74
+++ vm/vm_extern.h	5 Feb 2005 00:59:57 -0000	1.74.2.1
@@ -86,8 +86,6 @@
 void vm_object_print(/* db_expr_t */ long, boolean_t, /* db_expr_t */ long,
 			  char *);
 int vm_fault_quick(caddr_t v, int prot);
-void vm_proc_new(struct proc *p);
-void vm_proc_dispose(struct proc *p);
 void vm_thread_dispose(struct thread *td);
 void vm_thread_dispose_altkstack(struct thread *td);
 void vm_thread_new(struct thread *td, int pages);
Index: vm/vm_glue.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/vm/vm_glue.c,v
retrieving revision 1.202.2.3
retrieving revision 1.202.2.4
diff -u -d -r1.202.2.3 -r1.202.2.4
--- vm/vm_glue.c	31 Jan 2005 23:27:02 -0000	1.202.2.3
+++ vm/vm_glue.c	5 Feb 2005 01:01:19 -0000	1.202.2.4
@@ -91,8 +91,6 @@
 #include <vm/vm_pager.h>
 #include <vm/swap_pager.h>
 
-#include <sys/user.h>
-
 extern int maxslp;
 
 /*
@@ -113,8 +111,6 @@
 
 #ifndef NO_SWAPPING
 static void swapout(struct proc *);
-static void vm_proc_swapin(struct proc *p);
-static void vm_proc_swapout(struct proc *p);
 #endif
 
 /*
@@ -234,181 +230,6 @@
 	    VM_MAP_WIRE_SYSTEM | VM_MAP_WIRE_NOHOLES);
 }
 
-/*
- * Create the U area for a new process.
- * This routine directly affects the fork perf for a process.
- */
-void
-vm_proc_new(struct proc *p)
-{
-	vm_page_t ma[UAREA_PAGES];
-	vm_object_t upobj;
-	vm_offset_t up;
-	vm_page_t m;
-	u_int i;
-
-	/*
-	 * Get a kernel virtual address for the U area for this process.
-	 */
-	up = kmem_alloc_nofault(kernel_map, UAREA_PAGES * PAGE_SIZE);
-	if (up == 0)
-		panic("vm_proc_new: upage allocation failed");
-	p->p_uarea = (struct user *)up;
-
-	/*
-	 * Allocate object and page(s) for the U area.
-	 */
-	upobj = vm_object_allocate(OBJT_DEFAULT, UAREA_PAGES);
-	p->p_upages_obj = upobj;
-	VM_OBJECT_LOCK(upobj);
-	for (i = 0; i < UAREA_PAGES; i++) {
-		m = vm_page_grab(upobj, i, VM_ALLOC_NOBUSY |
-		    VM_ALLOC_NORMAL | VM_ALLOC_RETRY | VM_ALLOC_WIRED);
-		ma[i] = m;
-		m->valid = VM_PAGE_BITS_ALL;
-	}
-	VM_OBJECT_UNLOCK(upobj);
-
-	/*
-	 * Enter the pages into the kernel address space.
-	 */
-	pmap_qenter(up, ma, UAREA_PAGES);
-}
-
-/*
- * Dispose the U area for a process that has exited.
- * This routine directly impacts the exit perf of a process.
- * XXX proc_zone is marked UMA_ZONE_NOFREE, so this should never be called.
- */
-void
-vm_proc_dispose(struct proc *p)
-{
-	vm_object_t upobj;
-	vm_offset_t up;
-	vm_page_t m;
-
-	upobj = p->p_upages_obj;
-	VM_OBJECT_LOCK(upobj);
-	if (upobj->resident_page_count != UAREA_PAGES)
-		panic("vm_proc_dispose: incorrect number of pages in upobj");
-	vm_page_lock_queues();
-	while ((m = TAILQ_FIRST(&upobj->memq)) != NULL) {
-		vm_page_unwire(m, 0);
-		vm_page_free(m);
-	}
-	vm_page_unlock_queues();
-	VM_OBJECT_UNLOCK(upobj);
-	up = (vm_offset_t)p->p_uarea;
-	pmap_qremove(up, UAREA_PAGES);
-	kmem_free(kernel_map, up, UAREA_PAGES * PAGE_SIZE);
-	vm_object_deallocate(upobj);
-}
-
-#ifndef NO_SWAPPING
-/*
- * Allow the U area for a process to be prejudicially paged out.
- */
-static void
-vm_proc_swapout(struct proc *p)
-{
-	vm_object_t upobj;
-	vm_offset_t up;
-	vm_page_t m;
-
-	upobj = p->p_upages_obj;
-	VM_OBJECT_LOCK(upobj);
-	if (upobj->resident_page_count != UAREA_PAGES)
-		panic("vm_proc_dispose: incorrect number of pages in upobj");
-	vm_page_lock_queues();
-	TAILQ_FOREACH(m, &upobj->memq, listq) {
-		vm_page_dirty(m);
-		vm_page_unwire(m, 0);
-	}
-	vm_page_unlock_queues();
-	VM_OBJECT_UNLOCK(upobj);
-	up = (vm_offset_t)p->p_uarea;
-	pmap_qremove(up, UAREA_PAGES);
-}
-
-/*
- * Bring the U area for a specified process back in.
- */
-static void
-vm_proc_swapin(struct proc *p)
-{
-	vm_page_t ma[UAREA_PAGES];
-	vm_object_t upobj;
-	vm_offset_t up;
-	vm_page_t m;
-	int rv;
-	int i;
-
-	upobj = p->p_upages_obj;
-	VM_OBJECT_LOCK(upobj);
-	for (i = 0; i < UAREA_PAGES; i++) {
-		m = vm_page_grab(upobj, i, VM_ALLOC_NORMAL | VM_ALLOC_RETRY);
-		if (m->valid != VM_PAGE_BITS_ALL) {
-			rv = vm_pager_get_pages(upobj, &m, 1, 0);
-			if (rv != VM_PAGER_OK)
-				panic("vm_proc_swapin: cannot get upage");
-		}
-		ma[i] = m;
-	}
-	if (upobj->resident_page_count != UAREA_PAGES)
-		panic("vm_proc_swapin: lost pages from upobj");
-	vm_page_lock_queues();
-	TAILQ_FOREACH(m, &upobj->memq, listq) {
-		m->valid = VM_PAGE_BITS_ALL;
-		vm_page_wire(m);
-		vm_page_wakeup(m);
-	}
-	vm_page_unlock_queues();
-	VM_OBJECT_UNLOCK(upobj);
-	up = (vm_offset_t)p->p_uarea;
-	pmap_qenter(up, ma, UAREA_PAGES);
-}
-
-/*
- * Swap in the UAREAs of all processes swapped out to the given device.
- * The pages in the UAREA are marked dirty and their swap metadata is freed.
- */
-void
-vm_proc_swapin_all(struct swdevt *devidx)
-{
-	struct proc *p;
-	vm_object_t object;
-	vm_page_t m;
-
-retry:
-	sx_slock(&allproc_lock);
-	FOREACH_PROC_IN_SYSTEM(p) {
-		PROC_LOCK(p);
-		object = p->p_upages_obj;
-		if (object != NULL) {
-			VM_OBJECT_LOCK(object);
-			if (swap_pager_isswapped(object, devidx)) {
-				VM_OBJECT_UNLOCK(object);
-				sx_sunlock(&allproc_lock);
-				faultin(p);
-				PROC_UNLOCK(p);
-				VM_OBJECT_LOCK(object);
-				vm_page_lock_queues();
-				TAILQ_FOREACH(m, &object->memq, listq)
-					vm_page_dirty(m);
-				vm_page_unlock_queues();
-				swap_pager_freespace(object, 0,
-				    object->un_pager.swp.swp_bcount);
-				VM_OBJECT_UNLOCK(object);
-				goto retry;
-			}
-			VM_OBJECT_UNLOCK(object);
-		}
-		PROC_UNLOCK(p);
-	}
-	sx_sunlock(&allproc_lock);
-}
-#endif
-
 #ifndef KSTACK_MAX_PAGES
 #define KSTACK_MAX_PAGES 32
 #endif
@@ -641,19 +462,6 @@
 	}
 
 	/*
-	 * p_stats currently points at fields in the user struct.
-	 * Copy parts of p_stats; zero the rest of p_stats (statistics).
-	 */
-#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,
 	 * and make the child ready to run.
 	 */
@@ -736,7 +544,6 @@
 		mtx_unlock_spin(&sched_lock);
 		PROC_UNLOCK(p);
 
-		vm_proc_swapin(p);
 		FOREACH_THREAD_IN_PROC(p, td)
 			vm_thread_swapin(td);
 
@@ -1092,7 +899,6 @@
 		TD_SET_SWAPPED(td);
 	mtx_unlock_spin(&sched_lock);
 
-	vm_proc_swapout(p);
 	FOREACH_THREAD_IN_PROC(p, td)
 		vm_thread_swapout(td);
 
Index: vm/vm_pageout.h
===================================================================
RCS file: /v/freebsd/cvs/src/sys/vm/vm_pageout.h,v
retrieving revision 1.39.2.1
retrieving revision 1.39.2.2
diff -u -d -r1.39.2.1 -r1.39.2.2
--- vm/vm_pageout.h	31 Jan 2005 23:27:04 -0000	1.39.2.1
+++ vm/vm_pageout.h	5 Feb 2005 00:59:57 -0000	1.39.2.2
@@ -97,12 +97,6 @@
 extern void vm_wait(void);
 extern void vm_waitpfault(void);
 
-/* XXX This is probably misplaced. */
-#ifndef NO_SWAPPING
-struct swdevt;
-void vm_proc_swapin_all(struct swdevt *);
-#endif	/* !NO_SWAPPING */
-
 #ifdef _KERNEL
 int vm_pageout_flush(vm_page_t *, int, int);
 #endif
Index: kern/sched_4bsd.c
===================================================================
RCS file: /v/freebsd/cvs/src/sys/kern/sched_4bsd.c,v
retrieving revision 1.49.2.12
retrieving revision 1.49.2.15
diff -u -d -r1.49.2.12 -r1.49.2.15
--- kern/sched_4bsd.c	9 Oct 2004 05:25:21 -0000	1.49.2.12
+++ kern/sched_4bsd.c	5 Feb 2005 08:09:02 -0000	1.49.2.15
@@ -79,7 +79,6 @@
 	TAILQ_ENTRY(kse) ke_procq;	/* (j/z) Run queue. */
 	struct thread	*ke_thread;	/* (*) Active associated thread. */
 	fixpt_t		ke_pctcpu;	/* (j) %cpu during p_swtime. */
-	u_char		ke_oncpu;	/* (j) Which cpu we are on. */
 	char		ke_rqindex;	/* (j) Run queue index. */
 	enum {
 		KES_THREAD = 0x0,	/* slaved to thread state */
@@ -281,6 +280,19 @@
 	   "number of followons done to a different ksegrp");
 
 static int sched_kgfollowons = 0;
+static __inline void
+sched_load_add(void)
+{
+	sched_tdcnt++;
+	CTR1(KTR_SCHED, "global load: %d", sched_tdcnt);
+}
+
+static __inline void
+sched_load_rem(void)
+{
+	sched_tdcnt--;
+	CTR1(KTR_SCHED, "global load: %d", sched_tdcnt);
+}
 SYSCTL_INT(_kern_sched, OID_AUTO, kgfollowons, CTLFLAG_RD,
 	   &sched_kgfollowons, 0,
 	   "number of followons done in a ksegrp");
@@ -595,7 +607,7 @@
 	roundrobin(NULL);
 
 	/* Account for thread0. */
-	sched_tdcnt++;
+	sched_load_add();
 }
 
 /* External interfaces start here */
@@ -615,7 +627,6 @@
 	ksegrp0.kg_sched = &kg_sched0;
 	thread0.td_sched = &kse0;
 	kse0.ke_thread = &thread0;
-	kse0.ke_oncpu = NOCPU; /* wrong.. can we use PCPU(cpuid) yet? */
 	kse0.ke_state = KES_THREAD;
 	kg_sched0.skg_concurrency = 1;
 	kg_sched0.skg_avail_opennings = 0; /* we are already running */
@@ -698,8 +709,10 @@
 void
 sched_exit_thread(struct thread *td, struct thread *child)
 {
+	CTR3(KTR_SCHED, "sched_exit_thread: %p(%s) prio %d",
+	    child, child->td_proc->p_comm, child->td_priority);
 	if ((child->td_proc->p_flag & P_NOLOAD) == 0)
-		sched_tdcnt--;
+		sched_load_rem();
 }
 
 void
@@ -751,6 +764,9 @@
 void
 sched_prio(struct thread *td, u_char prio)
 {
+	CTR6(KTR_SCHED, "sched_prio: %p(%s) prio %d newprio %d by %p(%s)",
+	    td, td->td_proc->p_comm, td->td_priority, prio, curthread, 
+	    curthread->td_proc->p_comm);
 
 	mtx_assert(&sched_lock, MA_OWNED);
 	if (TD_ON_RUNQ(td)) {
@@ -784,7 +800,7 @@
 	mtx_assert(&sched_lock, MA_OWNED);
 
 	if ((p->p_flag & P_NOLOAD) == 0)
-		sched_tdcnt--;
+		sched_load_rem();
 	/* 
 	 * We are volunteering to switch out so we get to nominate
 	 * a successor for the rest of our quantum
@@ -856,7 +872,7 @@
 		newtd->td_kse->ke_flags |= KEF_DIDRUN;
         	TD_SET_RUNNING(newtd);
 		if ((newtd->td_proc->p_flag & P_NOLOAD) == 0)
-			sched_tdcnt++;
+			sched_load_add();
 	} else {
 		newtd = choosethread();
 	}
@@ -980,6 +996,9 @@
 
 	ke = td->td_kse;
 	mtx_assert(&sched_lock, MA_OWNED);
+	CTR5(KTR_SCHED, "sched_add: %p(%s) prio %d by %p(%s)",
+	    td, td->td_proc->p_comm, td->td_priority, curthread,
+	    curthread->td_proc->p_comm);
 	KASSERT(ke->ke_state != KES_ONRUNQ,
 	    ("sched_add: kse %p (%s) already in run queue", ke,
 	    ke->ke_proc->p_comm));
@@ -1053,7 +1072,7 @@
 		}
 	}
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
-		sched_tdcnt++;
+		sched_load_add();
 	SLOT_USE(td->td_ksegrp);
 	runq_add(ke->ke_runq, ke, flags);
 	ke->ke_ksegrp->kg_runq_kses++;
@@ -1073,8 +1092,11 @@
 	    ("sched_rem: KSE not on run queue"));
 	mtx_assert(&sched_lock, MA_OWNED);
 
+	CTR5(KTR_SCHED, "sched_rem: %p(%s) prio %d by %p(%s)",
+	    td, td->td_proc->p_comm, td->td_priority, curthread,
+	    curthread->td_proc->p_comm);
 	if ((td->td_proc->p_flag & P_NOLOAD) == 0)
-		sched_tdcnt--;
+		sched_load_rem();
 	SLOT_RELEASE(td->td_ksegrp);
 	runq_remove(ke->ke_runq, ke);
 


More information about the cvs-src mailing list