calcru: runtime went backwards
David Xu
davidxu at freebsd.org
Fri Feb 24 14:54:11 PST 2006
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
@@ -439,6 +439,7 @@
void
thread_exit(void)
{
+ struct bintime new_switchtime;
struct thread *td;
struct proc *p;
struct ksegrp *kg;
@@ -566,6 +567,15 @@
*/
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());
More information about the freebsd-current
mailing list