2007/8/14, Simon 'corecode' Schubert <[EMAIL PROTECTED]>: > Nicolas Thery wrote: > > Changed sysctl(KERN_PROC, ...) behaviour for kernel threads not associated > > with lwps. kinfo_lwp.kl_tid is set to -1 in this case instead of thread > > structure address. This is consistent with kinfo_proc.kp_pid, avoid > > garbage values in ps -axH output and should not break anything as kl_tid > > is not used anywhere in the source tree. > > > Index: dfly/src/sys/kern/kern_kinfo.c > > =================================================================== > > --- dfly.orig/src/sys/kern/kern_kinfo.c 2007-08-14 21:35:18.000000000 > > +0200 > > +++ dfly/src/sys/kern/kern_kinfo.c 2007-08-14 21:36:39.000000000 +0200 > > @@ -218,7 +218,7 @@ > > kp->kp_stat = SACTIVE; > > > > kp->kp_lwp.kl_pid = -1; > > - kp->kp_lwp.kl_tid = (uintptr_t)td; > > + kp->kp_lwp.kl_tid = -1; > > kp->kp_lwp.kl_tdflags = td->td_flags; > > #ifdef SMP > > kp->kp_lwp.kl_mpcount = td->td_mpcount; > > I don't think this is good. td is the "thread id", and nothing else. Now > you've removed the only possible identifier for a kernel thread. > > This needs to be reverted, and ps extended to use %#x or so
I understand your point but the existing code already has a similar problem: when the kernel thread is associated with a lwp, fill_kinfo_lwp() sets kl_tid to lwp_tid which is an integer allocated in lwp_fork() , not the associated struct thread address. It seems that "TID" refers sometimes to a LWP ID and sometimes to a kernel thread ID. Cheers, Nicolas
