Re: calcru: runtime went backwards

From: David Xu <davidxu_at_freebsd.org>
Date: Sat, 25 Feb 2006 06:54:14 +0800
Kazuaki Oda wrote:

>
> I've been getting calcru messages on 6-STABLE when stress-testing an 
> application linked with libpthread.  As far as my experience goes, 
> these messages are only for ones linked with libpthread.  If the same 
> application is linked with libthr, these messages go away.
>
> As I post about the same issue on -CURRENT a few days ago, I guess 
> these messages are caused by the programs which access process states. 
> ps(1), top(1) etc.  Because if I run the following command on the test 
> target machine, I can easily get them.
> % sh -c "while true; do ps ax >/dev/null; done"
>
> I hope this issue will be fixed before 6.1-RELEASE.
>
>
> ----
> Kazuaki Oda
>
>
Can you try following patch on a 6-STABLE machine?

Index: kern_thread.c
===================================================================
RCS file: /home/ncvs/src/sys/kern/kern_thread.c,v
retrieving revision 1.216.2.1
diff -u -r1.216.2.1 kern_thread.c
--- kern_thread.c    4 Oct 2005 22:53:56 -0000    1.216.2.1
+++ kern_thread.c    24 Feb 2006 22:51:08 -0000
_at__at_ -439,6 +439,7 _at__at_
 void
 thread_exit(void)
 {
+    struct bintime new_switchtime;
     struct thread *td;
     struct proc *p;
     struct ksegrp    *kg;
_at__at_ -566,6 +567,15 _at__at_
          */
         PROC_UNLOCK(p);
     }
+
+    /* Do the same timestamp bookkeeping that mi_switch() would do. */
+    binuptime(&new_switchtime);
+    bintime_add(&p->p_rux.rux_runtime, &new_switchtime);
+    bintime_sub(&p->p_rux.rux_runtime, PCPU_PTR(switchtime));
+    PCPU_SET(switchtime, new_switchtime);
+    PCPU_SET(switchticks, ticks);
+    cnt.v_swtch++;
+
     td->td_state = TDS_INACTIVE;
     CTR1(KTR_PROC, "thread_exit: cpu_throw() thread %p", td);
     cpu_throw(td, choosethread());
Received on Fri Feb 24 2006 - 21:54:11 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:52 UTC