Subject: Re: CVS commit: src/sys/kern/kern_ktrace.c
To: None <tech-kern@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 12/14/2003 20:54:22
On Fri, Dec 12, 2003 at 08:53:15PM +0900, YAMAMOTO Takashi wrote:
> hi,
>
> > Module Name: src
> > Committed By: dsl
> > Date: Wed Nov 12 21:07:38 UTC 2003
> >
> > Modified Files:
> > src/sys/compat/svr4: svr4_misc.c
> > src/sys/compat/svr4_32: svr4_32_misc.c
> > src/sys/kern: kern_exec.c kern_exit.c kern_fork.c kern_ktrace.c
> > kern_proc.c kern_sig.c
> > src/sys/sys: param.h proc.h
> >
> > Log Message:
> > - Count number of zombies and stopped children and requeue them at the top
> > of the sibling list so that find_stopped_child can be optimised to avoid
> > traversing the entire sibling list - helps when a process has a lot of
> > children.
> > - Modify locking in pfind() and pgfind() to that the caller can rely on the
> > result being valid, allow caller to request that zombies be findable.
> > - Rename pfind() to p_find() to ensure we break binary compatibility.
> > - Remove svr4_pfind since p_find willnow do the job.
> > - Modify some of the SMP locking of the proc lists - signals are still stuffed.
> >
> > Welcome to 1.6ZF
>
> this change seems to break ktrace.
> now ktrace_common() calls ktrops(), which might sleep,
> with proclist lock held.
The fix below should fix this by deferring the trace of the EMUL line
until the relevant process is active.
There is still a problem if fclose(9) sleeps - but that needs a different fix.
David
Index: sys/ktrace.h
===================================================================
RCS file: /cvsroot/src/sys/sys/ktrace.h,v
retrieving revision 1.35
diff -u -p -r1.35 ktrace.h
--- sys/ktrace.h 2003/11/24 16:51:33 1.35
+++ sys/ktrace.h 2003/12/14 20:45:26
@@ -212,6 +212,7 @@ struct ktr_mool {
#define KTRFAC_ROOT 0x80000000 /* root set this trace */
#define KTRFAC_INHERIT 0x40000000 /* pass trace flags to children */
#define KTRFAC_ACTIVE 0x20000000 /* ktrace logging in progress, ignore */
+#define KTRFAC_TRC_EMUL 0x10000000 /* ktrace KTR_EMUL before next trace */
#ifndef _KERNEL
Index: kern/kern_ktrace.c
===================================================================
RCS file: /cvsroot/src/sys/kern/kern_ktrace.c,v
retrieving revision 1.83
diff -u -p -r1.83 kern_ktrace.c
--- kern/kern_ktrace.c 2003/11/24 16:51:33 1.83
+++ kern/kern_ktrace.c 2003/12/14 20:45:28
@@ -677,7 +677,7 @@ ktrops(curp, p, ops, facs, fp)
* change/attach request.
*/
if (KTRPOINT(p, KTR_EMUL))
- ktremul(p);
+ p->p_traceflag |= KTRFAC_TRC_EMUL;
#ifdef __HAVE_SYSCALL_INTERN
(*p->p_emul->e_syscall_intern)(p);
#endif
@@ -734,6 +734,12 @@ ktrwrite(p, kth)
if (fp == NULL)
return 0;
+ if (p->p_traceflag & KTRFAC_TRC_EMUL) {
+ /* Add emulation trace before first entry for this process */
+ p->p_traceflag &= ~KTRFAC_TRC_EMUL;
+ ktremul(p);
+ }
+
auio.uio_iov = &aiov[0];
auio.uio_offset = 0;
auio.uio_segflg = UIO_SYSSPACE;
--
David Laight: david@l8s.co.uk