DragonFly BSD
DragonFly commits List (threaded) for 2005-10
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: cvs commit: src/sys/kern kern_exec.c sysv_ipc.c src/sys/sys proc.h


From: "Simon 'corecode' Schubert" <corecode@xxxxxxxxxxxx>
Date: Sun, 09 Oct 2005 16:38:36 +0200

Matthew Dillon wrote:
:Uhm, so each thread will carry the same information but proc won't?
:
:Alright, I can back it out, it just seemed a bit weird not to have the :command in struct proc.
:
:And worrying about these 17 bytes seemed not reasonable either.
All processes have threads (all LWP's have thread's too), but not all
threads have processes.


    The LWP separation implies that the command should be in the process
    structure so all the LWP's can share it, but that would still leaves us
    with a duplicate comm[] array in the thread structure which otherwise
    must be there for pure kernel threads and I really dislike that because
    it adds confusion.

*_comm[] is not the 'official' command name anyway. It's just the
short form used by ps, accounting, and so forth. Lets keep it in the thread structure.

See this patch: I think it adds too much churd. Mind you, we can't access p_comm anymore, we always have to find "some" lwp in proc to get the comm, and this seems backwards. I can commit this to remove p_comm, but I am still feeling that we shouldn't do this.


cheers
  simon

--
Serve - BSD     +++  RENT this banner advert  +++    ASCII Ribbon   /"\
Work - Mac      +++  space for low $$$ NOW!1  +++      Campaign     \ /
Party Enjoy Relax   |   http://dragonflybsd.org      Against  HTML   \
Dude 2c 2 the max   !   http://golden-apple.biz       Mail + News   / \
Index: ddb/db_ps.c
===================================================================
RCS file: /home/dcvs/src/sys/ddb/db_ps.c,v
retrieving revision 1.13
diff -u -r1.13 db_ps.c
--- ddb/db_ps.c	25 Apr 2005 22:26:22 -0000	1.13
+++ ddb/db_ps.c	9 Oct 2005 11:50:38 -0000
@@ -87,7 +87,7 @@
 		} else {
 			db_printf("                 ");
 		}
-		db_printf(" %s\n", p->p_comm ? p->p_comm : "");
+		db_printf(" %s\n", p->p_thread->td_comm);
 		db_dump_td_tokens(p->p_thread);
 
 		p = p->p_list.le_next;
@@ -161,7 +161,7 @@
 #endif
 			td->td_sp,
 			td->td_wmesg ? td->td_wmesg : "-",
-			td->td_proc ? td->td_proc->p_comm : td->td_comm);
+			td->td_comm);
 		    if (td->td_preempted)
 			db_printf("  PREEMPTING THREAD %p\n", td->td_preempted);
 		    db_dump_td_tokens(td);
@@ -189,7 +189,7 @@
 #endif
 		    td->td_sp,
 		    td->td_wmesg ? td->td_wmesg : "-",
-		    td->td_proc ? td->td_proc->p_comm : td->td_comm);
+		    td->td_comm);
 		db_dump_td_tokens(td);
 	    }
 	}
Index: dev/raid/vinum/vinumioctl.c
===================================================================
RCS file: /home/dcvs/src/sys/dev/raid/vinum/vinumioctl.c,v
retrieving revision 1.5
diff -u -r1.5 vinumioctl.c
--- dev/raid/vinum/vinumioctl.c	15 Nov 2003 21:05:42 -0000	1.5
+++ dev/raid/vinum/vinumioctl.c	9 Oct 2005 11:06:06 -0000
@@ -314,7 +314,7 @@
 	log(LOG_WARNING,
 	    "vinumioctl: invalid ioctl from process %d (%s): %lx\n",
 	    curproc->p_pid,
-	    curproc->p_comm,
+	    curthread->td_comm,
 	    cmd);
 	return EINVAL;
 
Index: emulation/linux/i386/linprocfs/linprocfs_misc.c
===================================================================
RCS file: /home/dcvs/src/sys/emulation/linux/i386/linprocfs/linprocfs_misc.c,v
retrieving revision 1.11
diff -u -r1.11 linprocfs_misc.c
--- emulation/linux/i386/linprocfs/linprocfs_misc.c	27 Apr 2005 14:31:19 -0000	1.11
+++ emulation/linux/i386/linprocfs/linprocfs_misc.c	9 Oct 2005 11:09:39 -0000
@@ -338,11 +338,14 @@
 	struct uio *uio;
 {
 	char *ps, psbuf[1024];
+	struct lwp *lp;
+
+	lp = LIST_FIRST(&p->p_lwps);	/* XXX */
 
 	ps = psbuf;
 	ps += sprintf(ps, "%d", p->p_pid);
 #define PS_ADD(name, fmt, arg) ps += sprintf(ps, " " fmt, arg)
-	PS_ADD("comm",		"(%s)",	p->p_comm);
+	PS_ADD("comm",		"(%s)",	lp->lwp_thread->td_comm);
 	PS_ADD("statr",		"%c",	'0'); /* XXX */
 	PS_ADD("ppid",		"%d",	p->p_pptr ? p->p_pptr->p_pid : 0);
 	PS_ADD("pgrp",		"%d",	p->p_pgid);
@@ -406,8 +409,11 @@
 {
 	char *ps, psbuf[1024];
 	char *state;
+	struct lwp *lp;
 	int i;
 
+	lp = LIST_FIRST(&p->p_lwps);	/* XXX */
+
 	ps = psbuf;
 
 	if (p->p_stat > sizeof state_str / sizeof *state_str)
@@ -416,7 +422,7 @@
 		state = state_str[(int)p->p_stat];
 
 #define PS_ADD ps += sprintf
-	PS_ADD(ps, "Name:\t%s\n",	  p->p_comm); /* XXX escape */
+	PS_ADD(ps, "Name:\t%s\n",	  lp->lwp_thread->td_comm); /* XXX escape */
 	PS_ADD(ps, "State:\t%s\n",	  state);
 
 	/*
Index: emulation/posix4/p1003_1b.c
===================================================================
RCS file: /home/dcvs/src/sys/emulation/posix4/p1003_1b.c,v
retrieving revision 1.7
diff -u -r1.7 p1003_1b.c
--- emulation/posix4/p1003_1b.c	27 Nov 2003 19:11:17 -0000	1.7
+++ emulation/posix4/p1003_1b.c	9 Oct 2005 11:10:14 -0000
@@ -121,7 +121,7 @@
 {
 	struct proc *p = curproc;
 	log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
-			p->p_comm, p->p_pid, s);
+			curthread->td_comm, p->p_pid, s);
 
 	/* a " return nosys(p, uap); " here causes a core dump.
 	 */
Index: i386/i386/trap.c
===================================================================
RCS file: /home/dcvs/src/sys/i386/i386/trap.c,v
retrieving revision 1.61
diff -u -r1.61 trap.c
--- i386/i386/trap.c	8 Oct 2005 12:24:26 -0000	1.61
+++ i386/i386/trap.c	9 Oct 2005 11:10:48 -0000
@@ -403,7 +403,7 @@
 		if (ISPL(frame.tf_cs)==SEL_UPL || (frame.tf_eflags & PSL_VM)) {
 			printf(
 			    "pid %ld (%s): trap %d with interrupts disabled\n",
-			    (long)curproc->p_pid, curproc->p_comm, type);
+			    (long)curproc->p_pid, curthread->td_comm, type);
 		} else if (type != T_BPTFLT && type != T_TRCTRAP) {
 			/*
 			 * XXX not quite right, since this may be for a
@@ -1100,8 +1100,7 @@
 	printf("current process		= ");
 	if (curproc) {
 		printf("%lu (%s)\n",
-		    (u_long)curproc->p_pid, curproc->p_comm ?
-		    curproc->p_comm : "");
+		    (u_long)curproc->p_pid, curthread->td_comm);
 	} else {
 		printf("Idle\n");
 	}
Index: i386/i386/vm_machdep.c
===================================================================
RCS file: /home/dcvs/src/sys/i386/i386/vm_machdep.c,v
retrieving revision 1.36
diff -u -r1.36 vm_machdep.c
--- i386/i386/vm_machdep.c	16 Jun 2005 21:12:44 -0000	1.36
+++ i386/i386/vm_machdep.c	9 Oct 2005 10:59:01 -0000
@@ -223,12 +223,18 @@
 	void (*func) (void *);
 	void *arg;
 {
+	struct lwp *lp;
+
+	KKASSERT(p->p_nthreads == 1);
+
+	lp = LIST_FIRST(&p->p_lwps);
+
 	/*
 	 * Note that the trap frame follows the args, so the function
 	 * is really called like this:  func(arg, frame);
 	 */
-	p->p_thread->td_pcb->pcb_esi = (int) func;	/* function */
-	p->p_thread->td_pcb->pcb_ebx = (int) arg;	/* first arg */
+	lp->lwp_thread->td_pcb->pcb_esi = (int) func;	/* function */
+	lp->lwp_thread->td_pcb->pcb_ebx = (int) arg;	/* first arg */
 }
 
 void
Index: i386/isa/npx.c
===================================================================
RCS file: /home/dcvs/src/sys/i386/isa/npx.c,v
retrieving revision 1.24
diff -u -r1.24 npx.c
--- i386/isa/npx.c	16 Jun 2005 21:12:47 -0000	1.24
+++ i386/isa/npx.c	9 Oct 2005 11:11:11 -0000
@@ -566,7 +566,7 @@
 		if (masked_exceptions & 0x0d)
 			log(LOG_ERR,
 	"pid %d (%s) exited with masked floating point exceptions 0x%02x\n",
-			    p->p_pid, p->p_comm, masked_exceptions);
+			    p->p_pid, curthread->td_comm, masked_exceptions);
 	}
 #endif
 }
Index: kern/imgact_elf.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/imgact_elf.c,v
retrieving revision 1.32
diff -u -r1.32 imgact_elf.c
--- kern/imgact_elf.c	2 Sep 2005 07:16:58 -0000	1.32
+++ kern/imgact_elf.c	9 Oct 2005 11:16:49 -0000
@@ -1211,7 +1211,9 @@
 	prstatus_t *status;
 	prfpregset_t *fpregset;
 	prpsinfo_t *psinfo;
+	struct lwp *lp = &p->p_lwp;	/* XXX lwp */
 	int nbytes;
+
 	tempdata = malloc(sizeof(*tempdata), M_TEMP, M_ZERO | M_WAITOK);
 	status = &tempdata->status;
 	fpregset = &tempdata->fpregset;
@@ -1231,10 +1233,11 @@
 
 	psinfo->pr_version = PRPSINFO_VERSION;
 	psinfo->pr_psinfosz = sizeof(prpsinfo_t);
-	strncpy(psinfo->pr_fname, p->p_comm, sizeof(psinfo->pr_fname) - 1);
+	strncpy(psinfo->pr_fname, lp->lwp_thread->td_comm,
+		sizeof(psinfo->pr_fname) - 1);
 
 	/* XXX - We don't fill in the command line arguments properly yet. */
-	strncpy(psinfo->pr_psargs, p->p_comm, PRARGSZ);
+	strncpy(psinfo->pr_psargs, lp->lwp_thread->td_comm, PRARGSZ);
 
 	/* Fill in the header. */
 	error = elf_puthdr(p, target, status, fpregset, psinfo, numsegs);
Index: kern/init_main.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/init_main.c,v
retrieving revision 1.46
diff -u -r1.46 init_main.c
--- kern/init_main.c	8 Oct 2005 19:46:50 -0000	1.46
+++ kern/init_main.c	9 Oct 2005 11:53:06 -0000
@@ -318,7 +318,8 @@
 	p->p_peers = 0;
 	p->p_leader = p;
 
-	bcopy("swapper", p->p_comm, sizeof ("swapper"));
+	bcopy("swapper", LIST_FIRST(&p->p_lwps)->lwp_thread->td_comm,
+	      sizeof ("swapper"));
 
 	/* Create credentials. */
 	p->p_ucred = crget();
Index: kern/kern_acct.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_acct.c,v
retrieving revision 1.19
diff -u -r1.19 kern_acct.c
--- kern/kern_acct.c	8 Oct 2005 19:46:50 -0000	1.19
+++ kern/kern_acct.c	9 Oct 2005 11:18:20 -0000
@@ -209,7 +209,7 @@
 	 */
 
 	/* (1) The name of the command that ran */
-	bcopy(p->p_comm, acct.ac_comm, sizeof acct.ac_comm);
+	bcopy(td->td_comm, acct.ac_comm, sizeof acct.ac_comm);
 
 	/* (2) The amount of user and system time that was used */
 	calcru(p, &ut, &st, NULL);
Index: kern/kern_checkpoint.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_checkpoint.c,v
retrieving revision 1.5
diff -u -r1.5 kern_checkpoint.c
--- kern/kern_checkpoint.c	9 Aug 2005 02:49:49 -0000	1.5
+++ kern/kern_checkpoint.c	9 Oct 2005 11:25:49 -0000
@@ -287,6 +287,7 @@
 elf_loadnotes(struct proc *p, prpsinfo_t *psinfo, prstatus_t *status, 
 	   prfpregset_t *fpregset) 
 {
+	struct lwp *lp = &p->p_lwp;
 	int error;
 
 	/* validate status and psinfo */
@@ -304,7 +305,8 @@
 	if ((error = set_regs(p, &status->pr_reg)) != 0)
 		goto done;
 	error = set_fpregs(p, fpregset);
-	strlcpy(p->p_comm, psinfo->pr_fname, sizeof(p->p_comm));
+	strlcpy(lp->lwp_thread->td_comm, psinfo->pr_fname,
+		sizeof(lp->lwp_thread->td_comm));
 	/* XXX psinfo->pr_psargs not yet implemented */
  done:	
 	TRACE_EXIT;
@@ -731,6 +733,7 @@
 int
 checkpoint_signal_handler(struct proc *p) 
 {
+	struct lwp *lp = &p->p_lwp;
 	char *buf;
 	struct file *fp;
 	struct nlookupdata nd;
@@ -747,14 +750,15 @@
 		return (EPERM);
 	}
 
-	buf = ckpt_expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
+	buf = ckpt_expand_name(lp->lwp_thread->td_comm, p->p_ucred->cr_uid,
+			       p->p_pid);
 	if (buf == NULL) {
 		chptinuse--;
 		return (ENOMEM);
 	}
 
 	log(LOG_INFO, "pid %d (%s), uid %d: checkpointing to %s\n",
-		p->p_pid, p->p_comm, 
+		p->p_pid, lp->lwp_thread->td_comm, 
 		(p->p_ucred ? p->p_ucred->cr_uid : -1),
 		buf);
 
Index: kern/kern_exec.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_exec.c,v
retrieving revision 1.34
diff -u -r1.34 kern_exec.c
--- kern/kern_exec.c	8 Oct 2005 14:31:26 -0000	1.34
+++ kern/kern_exec.c	9 Oct 2005 11:26:39 -0000
@@ -336,9 +336,8 @@
 
 	/* name this process - nameiexec(p, ndp) */
 	len = min(nd->nl_ncp->nc_nlen, MAXCOMLEN);
-	bcopy(nd->nl_ncp->nc_name, p->p_comm, len);
-	p->p_comm[len] = 0;
-	bcopy(p->p_comm, p->p_lwp.lwp_thread->td_comm, MAXCOMLEN+1);
+	bcopy(nd->nl_ncp->nc_name, td->td_comm, len);
+	td->td_comm[len] = 0;
 
 	/*
 	 * mark as execed, wakeup the process that vforked (if any) and tell
Index: kern/kern_fork.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_fork.c,v
retrieving revision 1.40
diff -u -r1.40 kern_fork.c
--- kern/kern_fork.c	8 Oct 2005 19:46:50 -0000	1.40
+++ kern/kern_fork.c	9 Oct 2005 13:54:18 -0000
@@ -297,6 +297,7 @@
 	LIST_INSERT_HEAD(&newproc->p_lwps, &newproc->p_lwp, lwp_list);
 	newproc->p_lwp.lwp_proc = newproc;
 	newproc->p_lwp.lwp_tid = 0;
+	newproc->p_nthreads = 1;
 
 	/*
 	 * Find an unused process ID.  We remember a range of unused IDs
@@ -638,6 +639,12 @@
 void
 start_forked_proc(struct proc *p1, struct proc *p2)
 {
+	struct lwp *lp2;
+
+	KKASSERT(p2 != NULL && p2->p_nthreads == 1);
+
+	lp2 = LIST_FIRST(&p2->p_lwps);
+
 	/*
 	 * Move from SIDL to RUN queue, and activate the process's thread.
 	 * Activation of the thread effectively makes the process "a"
Index: kern/kern_ktrace.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_ktrace.c,v
retrieving revision 1.19
diff -u -r1.19 kern_ktrace.c
--- kern/kern_ktrace.c	28 Jul 2005 18:10:23 -0000	1.19
+++ kern/kern_ktrace.c	9 Oct 2005 11:27:04 -0000
@@ -73,7 +73,7 @@
 	kth->ktr_type = type;
 	microtime(&kth->ktr_time);
 	kth->ktr_pid = p->p_pid;
-	bcopy(p->p_comm, kth->ktr_comm, MAXCOMLEN + 1);
+	bcopy(curthread->td_comm, kth->ktr_comm, MAXCOMLEN + 1);
 	return (kth);
 }
 
Index: kern/kern_lockf.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_lockf.c,v
retrieving revision 1.24
diff -u -r1.24 kern_lockf.c
--- kern/kern_lockf.c	14 Apr 2005 08:14:31 -0000	1.24
+++ kern/kern_lockf.c	9 Oct 2005 11:29:07 -0000
@@ -799,12 +799,13 @@
 static void
 _lf_printf(const char *ctl, ...)
 {
-	struct proc *p;
+	struct lwp *lp;
 	__va_list va;
 
 	if (lf_print_ranges) {
-	    if ((p = curproc) != NULL)
-		printf("pid %d (%s): ", p->p_pid, p->p_comm);
+	    if ((lp = curthread->td_lwp) != NULL)
+		printf("pid %d tid %d (%s): ", lp->lwp_proc->p_pid,
+		       lp->lwp_tid, lp->lwp_thrad->td_comm);
 	}
 	__va_start(va, ctl);
 	vprintf(ctl, va);
Index: kern/kern_shutdown.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_shutdown.c,v
retrieving revision 1.22
diff -u -r1.22 kern_shutdown.c
--- kern/kern_shutdown.c	19 Jul 2005 19:53:53 -0000	1.22
+++ kern/kern_shutdown.c	9 Oct 2005 11:29:37 -0000
@@ -708,7 +708,7 @@
 	td = (struct thread *)arg;
 	if ((p = td->td_proc) != NULL) {
 	    printf("Waiting (max %d seconds) for system process `%s' to stop...",
-		kproc_shutdown_wait, p->p_comm);
+		kproc_shutdown_wait, td->td_comm);
 	} else {
 	    printf("Waiting (max %d seconds) for system thread %s to stop...",
 		kproc_shutdown_wait, td->td_comm);
Index: kern/kern_sig.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/kern_sig.c,v
retrieving revision 1.37
diff -u -r1.37 kern_sig.c
--- kern/kern_sig.c	6 Jun 2005 15:02:28 -0000	1.37
+++ kern/kern_sig.c	9 Oct 2005 11:33:43 -0000
@@ -1459,7 +1459,10 @@
 void
 killproc(struct proc *p, char *why)
 {
-	log(LOG_ERR, "pid %d (%s), uid %d, was killed: %s\n", p->p_pid, p->p_comm,
+	struct lwp *lp = LIST_FIRST(&p->p_lwps);	/* XXX */
+
+	log(LOG_ERR, "pid %d (%s), uid %d, was killed: %s\n", p->p_pid,
+		lp->lwp_thread->td_comm,
 		p->p_ucred ? p->p_ucred->cr_uid : -1, why);
 	psignal(p, SIGKILL);
 }
@@ -1475,6 +1478,8 @@
 void
 sigexit(struct proc *p, int sig)
 {
+	struct lwp *lp = &p->p_lwp;	/* XXX lwp */
+
 	p->p_acflag |= AXSIG;
 	if (sigprop(sig) & SA_CORE) {
 		p->p_sig = sig;
@@ -1489,7 +1494,7 @@
 		if (kern_logsigexit)
 			log(LOG_INFO,
 			    "pid %d (%s), uid %d: exited on signal %d%s\n",
-			    p->p_pid, p->p_comm,
+			    p->p_pid, lp->lwp_thread->td_comm,
 			    p->p_ucred ? p->p_ucred->cr_uid : -1,
 			    sig &~ WCOREFLAG,
 			    sig & WCOREFLAG ? " (core dumped)" : "");
@@ -1591,6 +1596,7 @@
 static int
 coredump(struct proc *p)
 {
+	struct lwp *lp = &p->p_lwp;
 	struct vnode *vp;
 	struct ucred *cred = p->p_ucred;
 	struct thread *td = p->p_thread;
@@ -1618,7 +1624,7 @@
 	if (limit == 0)
 		return EFBIG;
 
-	name = expand_name(p->p_comm, p->p_ucred->cr_uid, p->p_pid);
+	name = expand_name(lp->lwp_thread->td_comm, p->p_ucred->cr_uid, p->p_pid);
 	if (name == NULL)
 		return (EINVAL);
 	error = nlookup_init(&nd, name, UIO_SYSSPACE, NLC_LOCKVP);
Index: kern/sysv_ipc.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/sysv_ipc.c,v
retrieving revision 1.8
diff -u -r1.8 sysv_ipc.c
--- kern/sysv_ipc.c	8 Oct 2005 14:31:26 -0000	1.8
+++ kern/sysv_ipc.c	9 Oct 2005 11:34:59 -0000
@@ -86,10 +86,12 @@
 sysv_nosys(char *s)
 {
 	struct thread *td = curthread;
+	struct lwp *lp = td->td_lwp;
 	struct proc *p = td->td_proc;
 
-	log(LOG_ERR, "cmd %s pid %d tried to use non-present %s\n",
-			(p ? p->p_comm : td->td_comm),
+	log(LOG_ERR, "cmd %s pid %d tid %d tried to use non-present %s\n",
+			td->td_comm,
+			(lp ? lp->lwp_tid : -1),
 			(p ? p->p_pid : -1), s);
 }
 
Index: kern/tty.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/tty.c,v
retrieving revision 1.18
diff -u -r1.18 tty.c
--- kern/tty.c	27 Jun 2005 18:37:57 -0000	1.18
+++ kern/tty.c	9 Oct 2005 11:38:06 -0000
@@ -2379,6 +2379,7 @@
 		 */
 		char buf[64];
 		const char *str;
+		struct lwp *lp;
 		int isinmem;
 		long vmsz;
 		int pctcpu;
@@ -2404,7 +2405,7 @@
 			str = "iowait";
 
 		snprintf(buf, sizeof(buf), "cmd: %s %d [%s]",
-			(pick->p_thread ? pick->p_comm : "?"),
+			(pick->p_thread ? pick->p_thread->td_comm : "?"),
 			pick->p_pid, str);
 
 		/*
Index: kern/vfs_aio.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/vfs_aio.c,v
retrieving revision 1.18
diff -u -r1.18 vfs_aio.c
--- kern/vfs_aio.c	3 Aug 2005 16:36:33 -0000	1.18
+++ kern/vfs_aio.c	9 Oct 2005 11:39:04 -0000
@@ -618,13 +618,15 @@
 	struct aioproclist *aiop;
 	struct kaioinfo *ki;
 	struct proc *curcp, *mycp, *userp;
+	struct thread *mytd;
 	struct vmspace *myvm, *tmpvm;
 	struct ucred *cr;
 
 	/*
 	 * Local copies of curproc (cp) and vmspace (myvm)
 	 */
-	mycp = curproc;
+	mytd = curthread;
+	mycp = mytd->td_proc;
 	myvm = mycp->p_vmspace;
 
 	if (mycp->p_textvp) {
@@ -652,7 +654,7 @@
 	crit_exit();
 
 	/* Make up a name for the daemon. */
-	strcpy(mycp->p_comm, "aiod");
+	strcpy(mytd->td_comm, "aiod");
 
 	/*
 	 * Get rid of our current filedescriptors.  AIOD's don't need any
Index: kern/vfs_journal.c
===================================================================
RCS file: /home/dcvs/src/sys/kern/vfs_journal.c,v
retrieving revision 1.23
diff -u -r1.23 vfs_journal.c
--- kern/vfs_journal.c	17 Sep 2005 07:43:00 -0000	1.23
+++ kern/vfs_journal.c	9 Oct 2005 11:39:41 -0000
@@ -1806,7 +1806,7 @@
     jrecord_leaf(jrec, JLEAF_GID, &cred->cr_gid, sizeof(cred->cr_gid));
     if (td && (p = td->td_proc) != NULL) {
 	jrecord_leaf(jrec, JLEAF_PID, &p->p_pid, sizeof(p->p_pid));
-	jrecord_leaf(jrec, JLEAF_COMM, p->p_comm, sizeof(p->p_comm));
+	jrecord_leaf(jrec, JLEAF_COMM, td->td_comm, sizeof(td->td_comm));
     }
     jrecord_pop(jrec, save);
 }
Index: netproto/smb/smb_subr.c
===================================================================
RCS file: /home/dcvs/src/sys/netproto/smb/smb_subr.c,v
retrieving revision 1.14
diff -u -r1.14 smb_subr.c
--- netproto/smb/smb_subr.c	2 Mar 2005 19:14:51 -0000	1.14
+++ netproto/smb/smb_subr.c	9 Oct 2005 10:51:43 -0000
@@ -372,6 +372,7 @@
 	int error;
 	__va_list ap;
 	struct proc *p2;
+	struct lwp *lp2;
 
 	if (!proc0.p_stats || proc0.p_thread->td_start.tv_sec == 0) {
 		panic("kthread_create called too soon");
@@ -381,6 +382,8 @@
 	if (error)
 		return error;
 
+	lp2 = LIST_FIRST(&p2->p_lwps);
+
 	/* save a global descriptor, if desired */
 	if (newpp != NULL)
 		*newpp = p2;
@@ -391,7 +394,8 @@
 
 	/* set up arg0 for 'ps', et al */
 	__va_start(ap, fmt);
-	vsnprintf(p2->p_comm, sizeof(p2->p_comm), fmt, ap);
+	vsnprintf(lp2->lwp_thread->td_comm,
+		  sizeof(lp2->lwp_thread->td_comm), fmt, ap);
 	__va_end(ap);
 
 	/* call the processes' main()... */
Index: sys/proc.h
===================================================================
RCS file: /home/dcvs/src/sys/sys/proc.h,v
retrieving revision 1.66
diff -u -r1.66 proc.h
--- sys/proc.h	8 Oct 2005 19:46:51 -0000	1.66
+++ sys/proc.h	9 Oct 2005 11:03:35 -0000
@@ -258,15 +258,14 @@
 #define	p_endzero	p_startcopy
 
 /* The following fields are all copied upon creation in fork. */
-#define	p_startcopy	p_comm
+#define	p_startcopy	p_lock
 
 #define p_sigmask p_lwp.lwp_sigmask
 #define p_sigstk p_lwp.lwp_sigstk
 
-	char		p_comm[MAXCOMLEN+1]; /* typ 16+1 bytes */
 	char		p_lock;		/* Process lock (prevent swap) count. */
 	char		p_nice;		/* Process "nice" value. */
-	char		p_pad3;
+	char		p_pad3[2];
 
 	struct pgrp	*p_pgrp;	/* Pointer to process group. */
 
Index: vfs/procfs/procfs_status.c
===================================================================
RCS file: /home/dcvs/src/sys/vfs/procfs/procfs_status.c,v
retrieving revision 1.10
diff -u -r1.10 procfs_status.c
--- vfs/procfs/procfs_status.c	8 Oct 2005 19:46:51 -0000	1.10
+++ vfs/procfs/procfs_status.c	9 Oct 2005 12:03:04 -0000
@@ -64,6 +64,7 @@
 	struct session *sess;
 	struct tty *tp;
 	struct ucred *cr;
+	struct lwp *lp;
 	char *ps;
 	char *sep;
 	int pid, ppid, pgid, sid;
@@ -80,6 +81,7 @@
 	pgid = p->p_pgrp->pg_id;
 	sess = p->p_pgrp->pg_session;
 	sid = sess->s_leader ? sess->s_leader->p_pid : 0;
+	lp = LIST_FIRST(&p->p_lwps);	/* XXX */
 
 /* comm pid ppid pgid sid maj,min ctty,sldr start ut st wmsg 
                                 euid ruid rgid,egid,groups[1 .. NGROUPS]
@@ -88,7 +90,7 @@
 			("Too short buffer for new MAXCOMLEN"));
 
 	ps = psbuf;
-	bcopy(p->p_comm, ps, MAXCOMLEN);
+	bcopy(lp->lwp_thread->td_comm, ps, MAXCOMLEN);
 	ps[MAXCOMLEN] = '\0';
 	ps += strlen(ps);
 	DOCHECK();
@@ -183,6 +185,7 @@
 procfs_docmdline(struct proc *curp, struct proc *p, struct pfsnode *pfs,
 		 struct uio *uio)
 {
+	struct lwp *lp;
 	char *ps;
 	int xlen;
 	int error;
@@ -195,7 +198,9 @@
 
 	if (uio->uio_rw != UIO_READ)
 		return (EOPNOTSUPP);
-	
+
+	lp = LIST_FIRST(&p->p_lwps);	/* XXX */
+
 	/*
 	 * If we are using the ps/cmdline caching, use that.  Otherwise
 	 * revert back to the old way which only implements full cmdline
@@ -214,7 +219,7 @@
 		buflen = p->p_args->ar_length;
 		buf = 0;
 	} else if (p != curp) {
-		bp = p->p_comm;
+		bp = lp->lwp_thread->td_comm;
 		buflen = MAXCOMLEN;
 		buf = 0;
 	} else {
Index: vfs/ufs/ffs_alloc.c
===================================================================
RCS file: /home/dcvs/src/sys/vfs/ufs/ffs_alloc.c,v
retrieving revision 1.14
diff -u -r1.14 ffs_alloc.c
--- vfs/ufs/ffs_alloc.c	14 Aug 2005 18:53:42 -0000	1.14
+++ vfs/ufs/ffs_alloc.c	9 Oct 2005 11:44:33 -0000
@@ -1812,10 +1812,11 @@
 	struct proc *p;
 
 	if ((p = td->td_proc) != NULL) {
-	    log(LOG_ERR, "pid %d (%s), uid %d on %s: %s\n", p ? p->p_pid : -1,
-		    p ? p->p_comm : "-", uid, fs->fs_fsmnt, cp);
+	    log(LOG_ERR, "pid %d tid %d (%s), uid %d on %s: %s\n",
+		    p->p_pid, td->td_lwp->lwp_tid,
+		    td->td_comm, uid, fs->fs_fsmnt, cp);
 	} else {
-	    log(LOG_ERR, "system thread %p, uid %d on %s: %s\n",
-		    td, uid, fs->fs_fsmnt, cp);
+	    log(LOG_ERR, "system thread %p (%s), uid %d on %s: %s\n",
+		    td, td->td_comm, uid, fs->fs_fsmnt, cp);
 	}
 }
Index: vm/vm_fault.c
===================================================================
RCS file: /home/dcvs/src/sys/vm/vm_fault.c,v
retrieving revision 1.18
diff -u -r1.18 vm_fault.c
--- vm/vm_fault.c	12 Oct 2004 19:29:34 -0000	1.18
+++ vm/vm_fault.c	9 Oct 2005 12:11:33 -0000
@@ -544,8 +544,9 @@
 			 */
 
 			if (rv == VM_PAGER_ERROR)
-				printf("vm_fault: pager read error, pid %d (%s)\n",
-				    curproc->p_pid, curproc->p_comm);
+				printf("vm_fault: pager read error, pid %d tid %d (%s)\n",
+				    curproc->p_pid, curthread->td_lwp->lwp_tid,
+				    curthread->td_comm);
 			/*
 			 * Data outside the range of the pager or an I/O error
 			 */
Index: vm/vm_glue.c
===================================================================
RCS file: /home/dcvs/src/sys/vm/vm_glue.c,v
retrieving revision 1.34
diff -u -r1.34 vm_glue.c
--- vm/vm_glue.c	8 Oct 2005 19:46:51 -0000	1.34
+++ vm/vm_glue.c	9 Oct 2005 11:48:06 -0000
@@ -236,7 +236,7 @@
 	td2 = lwkt_alloc_thread(NULL, LWKT_THREAD_STACK, -1);
 	pmap_init_proc(p2, td2);
 	lwkt_setpri(td2, TDPRI_KERN_USER);
-	lwkt_set_comm(td2, "%s", p1->p_comm);
+	lwkt_set_comm(td2, "%s", LIST_FIRST(&p1->p_lwps)->lwp_thread->td_comm);
 
 	up = p2->p_addr;
 


[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]