From owner-freebsd-questions@FreeBSD.ORG Wed Jan 19 01:21:05 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4C122106564A for ; Wed, 19 Jan 2011 01:21:05 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from asmtpout027.mac.com (asmtpout027.mac.com [17.148.16.102]) by mx1.freebsd.org (Postfix) with ESMTP id 341948FC20 for ; Wed, 19 Jan 2011 01:21:04 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from cswiger1.apple.com ([17.209.4.71]) by asmtp027.mac.com (Oracle Communications Messaging Exchange Server 7u4-18.01 64bit (built Jul 15 2010)) with ESMTPSA id <0LF800GGEX2SH150@asmtp027.mac.com> for freebsd-questions@freebsd.org; Tue, 18 Jan 2011 17:20:53 -0800 (PST) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.2.15,1.0.148,0.0.0000 definitions=2011-01-19_01:2011-01-19, 2011-01-19, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1010190000 definitions=main-1101180209 From: Chuck Swiger In-reply-to: <35110.88084.qm@web110316.mail.gq1.yahoo.com> Date: Tue, 18 Jan 2011 17:20:51 -0800 Message-id: <76A5ACE2-12EB-4D5D-ABD8-E99B2DEEB5C8@mac.com> References: <35110.88084.qm@web110316.mail.gq1.yahoo.com> To: Mark Terribile X-Mailer: Apple Mail (2.1082) Cc: freebsd-questions@freebsd.org Subject: Re: rusage and pthreads X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jan 2011 01:21:05 -0000 On Jan 18, 2011, at 5:01 PM, Mark Terribile wrote: > and continues further down > > ru = &td->td_ru; > ru->ru_ixrss += pgtok(vm->vm_tsize); > ru->ru_idrss += pgtok(vm->vm_dsize); > ru->ru_isrss += pgtok(vm->vm_ssize); > > This looks to me like it's accumulating the data in per-thread counters. What's more, it's consistent with what I'm seeing on the user side. Note that this is 7.2; if 8.x behaves differently I'd like to know. I wonder if all of the threads in a process might be pointing to the same struct rusage? Nope, checking kern/kern_resource.c kern_getrusage(), there is a per-proc struct rusage_ext which gets the sum of the per-thread td->td_ru counters via rufetch() / ruxagg()...so you're right that the counters are now per-thread. > Which would mean that a process that is occupying memory but doesn't happen to be running on that clock tick doesn't have its memory counted toward the total ... right? That's right. Regards, -- -Chuck