From owner-freebsd-current@FreeBSD.ORG Fri Feb 24 19:34:47 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id AEB431065670 for ; Fri, 24 Feb 2012 19:34:47 +0000 (UTC) (envelope-from matthewstory@gmail.com) Received: from mail-qy0-f182.google.com (mail-qy0-f182.google.com [209.85.216.182]) by mx1.freebsd.org (Postfix) with ESMTP id 548238FC0C for ; Fri, 24 Feb 2012 19:34:47 +0000 (UTC) Received: by qcsg15 with SMTP id g15so729697qcs.13 for ; Fri, 24 Feb 2012 11:34:46 -0800 (PST) Received-SPF: pass (google.com: domain of matthewstory@gmail.com designates 10.229.135.193 as permitted sender) client-ip=10.229.135.193; Authentication-Results: mr.google.com; spf=pass (google.com: domain of matthewstory@gmail.com designates 10.229.135.193 as permitted sender) smtp.mail=matthewstory@gmail.com; dkim=pass header.i=matthewstory@gmail.com Received: from mr.google.com ([10.229.135.193]) by 10.229.135.193 with SMTP id o1mr2823394qct.74.1330112086730 (num_hops = 1); Fri, 24 Feb 2012 11:34:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=lskJYPEFwJHO9zbMWlLP+NXf5FNPl6igIw5ZJXHx8OQ=; b=k44KPExIrF1VYb4rdJ+oOGYKxPpz8xc/BXeWtI5KyLU7T5G3EwyDkxUNb2MbcndAz2 KPs6DB2ByGx+ViRQmFNjnD/QSvZPZDsgL/3gKs426hxOxpu3cPU9VgXpDw30rsdYWSIC BNhwkNzEXC540MpE08RPl8cSQc2Yva6dKdQkw= MIME-Version: 1.0 Received: by 10.229.135.193 with SMTP id o1mr2288247qct.74.1330110623438; Fri, 24 Feb 2012 11:10:23 -0800 (PST) Received: by 10.229.95.74 with HTTP; Fri, 24 Feb 2012 11:10:23 -0800 (PST) Date: Fri, 24 Feb 2012 14:10:23 -0500 Message-ID: From: Matthew Story To: freebsd-current@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: calculating resident size (in K) 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 2012 19:34:47 -0000 I'm working on kern/163033, and so far have written a sysctl for controlling logging of additional process information on SIGKILL (or SIGEXIT if logsigexit=1) from the kernel level, this logs proc size in K, number of threads, process state and CPU utilization of the process, in addition to the currently available information. For resident memory, things are a touch trickier, I looked at top for inspiration (possibly not the best place for inspiration ...), and from a kinfo_proc I can calculate via rssize (sum of threads pages utilization, and then use pagesize from there). It's also possible, albeit with some code repetition, to handle this from a proc (not kinfo_proc). But there are a few questions, the first of which is that the kern_proc.c code that populates a kinfo_proc struct's rssize value, has a nice XXX next to it ... kp->ki_rssize = vmspace_resident_count(vm); /*XXX*/ FOREACH_THREAD_IN_PROC(p, td0) { if (!TD_IS_SWAPPED(td0)) kp->ki_rssize += td0->td_kstack_pages; } ... so I'm wondering if there are plans on changing the way this is calculated, and what assumptions are safe in so far as calculating resident memory (if things are likely to change). The second question is that were resident memory logging enabled by this sysctl (not sure that populating a kinfo_proc and calculating res memory is necessarily an intelligent idea prior to a SIGKILL ... and the other diagnostics give you enough information to debug intelligently, but for the sake of argument ...), there would be at least 2 implementations which calculate resident memory in K from pages (this one and top, there are doubtlessly others). Would it be useful to provide a function at the sys level to return the calculated resident size in K from a kinfo_proc (or just a regular old proc)? -- regards, matt