From owner-freebsd-current@FreeBSD.ORG Fri Feb 24 22:54:11 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from [127.0.0.1] (localhost [127.0.0.1]) by hub.freebsd.org (Postfix) with ESMTP id 7982F16A420; Fri, 24 Feb 2006 22:54:10 +0000 (GMT) (envelope-from davidxu@freebsd.org) Message-ID: <43FF8E96.5040203@freebsd.org> Date: Sat, 25 Feb 2006 06:54:14 +0800 From: David Xu User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.7.12) Gecko/20060117 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Kazuaki Oda References: <43FE4E26.4060507@freebsd.org> <43FE9BC3.5070909@highway.ne.jp> In-Reply-To: <43FE9BC3.5070909@highway.ne.jp> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-current@freebsd.org Subject: Re: calcru: runtime went backwards X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Feb 2006 22:54:11 -0000 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());