rusage breakdown and cpu limits.

Jeff Roberson jroberson at chesapeake.net
Tue May 29 21:57:22 UTC 2007


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);

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
>


More information about the freebsd-arch mailing list