From owner-freebsd-arch@FreeBSD.ORG Tue May 29 23:57:02 2007 Return-Path: X-Original-To: freebsd-arch@freebsd.org Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3909E16A421 for ; Tue, 29 May 2007 23:57:02 +0000 (UTC) (envelope-from julian@elischer.org) Received: from outO.internet-mail-service.net (outO.internet-mail-service.net [216.240.47.238]) by mx1.freebsd.org (Postfix) with ESMTP id 23EA513C44B for ; Tue, 29 May 2007 23:57:02 +0000 (UTC) (envelope-from julian@elischer.org) Received: from mx0.idiom.com (HELO idiom.com) (216.240.32.160) by out.internet-mail-service.net (qpsmtpd/0.32) with ESMTP; Tue, 29 May 2007 16:57:01 -0700 Received: from julian-mac.elischer.org (nat.ironport.com [63.251.108.100]) by idiom.com (Postfix) with ESMTP id 75879125B2B; Tue, 29 May 2007 16:57:01 -0700 (PDT) Message-ID: <465CBDCB.2040202@elischer.org> Date: Tue, 29 May 2007 16:56:59 -0700 From: Julian Elischer User-Agent: Thunderbird 2.0.0.0 (Macintosh/20070326) MIME-Version: 1.0 To: Jeff Roberson References: <20070529105856.L661@10.0.0.1> <200705291456.38515.jhb@freebsd.org> <20070529121653.P661@10.0.0.1> <465C90F5.1000906@elischer.org> <20070530072219.G11288@besplex.bde.org> <20070529145508.U661@10.0.0.1> In-Reply-To: <20070529145508.U661@10.0.0.1> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-arch@freebsd.org Subject: Re: rusage breakdown and cpu limits. X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 May 2007 23:57:02 -0000 Jeff Roberson wrote: > On Wed, 30 May 2007, Bruce Evans wrote: > >> On Tue, 29 May 2007, Julian Elischer wrote: >> >>> Jeff Roberson wrote: >>>> I think I'm going to make the rusage struct per-thread and aggregate >>>> it on demand. There will be a lot of code churn, but it will be >>>> simple. There are a few cases where which will be complicated, and >>>> cpulimit is one of them. >>> >>> So, there should be somewhere to store the aggregated stats from >>> threads that have already exited. >> >> We already have that. It is the per-process rusage. There is already >> delayed accumulation for tick counts (these are currently accumulated in >> the rusage from the thread at context switch time). There is also >> delayed conversion of stats to the form needed by getrusage(). Stats >> are kept in raw form as long as possible (forever if nothing calls >> getrusage() or wait[34]() to look at them) to avoid conversion overhead >> for them on every exit(). So there are many precedents for delayed >> stats handling. > >> From thread_exit(): > /* Add our usage into the usage of all our children. */ > if (p->p_numthreads == 1) > ruadd(p->p_ru, &p->p_rux, &p->p_stats->p_cru, &p->p_crux); This is only called when the last thread is exiting (as part of exit()) .... and we are adding our process's rusage to the storage for have already put their rusage numbers. I assume that wait() will reap it from there later. making it per-thread would effectively remove the conditional and make something similar happen on every thread_exit(). (not necessarily a bad thing). > > Is the comment wrong or the code wrong? This adds our child's rusage to > our own. I assume the comment is actually wrong and that we're adding > our children's resource usage to our own so the pstats structure can be > freed and our parent can aggregate it all together. > > Jeff > > >> >> Bruce >>