From tim@robbins.dropbear.id.au Tue Mar 11 01:53:31 2003 Return-Path: Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A625437B401 for ; Tue, 11 Mar 2003 01:53:31 -0800 (PST) Received: from smtp01.syd.iprimus.net.au (smtp01.syd.iprimus.net.au [210.50.30.70]) by mx1.FreeBSD.org (Postfix) with ESMTP id B043D43FAF for ; Tue, 11 Mar 2003 01:53:30 -0800 (PST) (envelope-from tim@robbins.dropbear.id.au) Received: from dilbert.robbins.dropbear.id.au ([210.50.221.204]) by smtp01.syd.iprimus.net.au with Microsoft SMTPSVC(5.0.2195.5600); Tue, 11 Mar 2003 20:53:24 +1100 Received: from dilbert.robbins.dropbear.id.au (lroksc0xguohgkjb@localhost [127.0.0.1]) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6) with ESMTP id h2B9qxJK083268 for ; Tue, 11 Mar 2003 20:52:59 +1100 (EST) (envelope-from tim@dilbert.robbins.dropbear.id.au) Received: (from tim@localhost) by dilbert.robbins.dropbear.id.au (8.12.6/8.12.6/Submit) id h2B9qwNF083267; Tue, 11 Mar 2003 20:52:58 +1100 (EST) (envelope-from tim) Message-Id: <200303110952.h2B9qwNF083267@dilbert.robbins.dropbear.id.au> Date: Tue, 11 Mar 2003 20:52:58 +1100 (EST) From: Tim Robbins Reply-To: Tim Robbins To: FreeBSD-gnats-submit@freebsd.org Cc: Subject: Resident set size calculation broken in 5.x X-Send-Pr-Version: 3.113 X-GNATS-Notify: >Number: 49102 >Category: kern >Synopsis: Resident set size calculation broken in 5.x >Confidential: no >Severity: serious >Priority: medium >Responsible: julian >State: closed >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Mar 11 02:00:27 PST 2003 >Closed-Date: Mon Aug 23 10:56:26 GMT 2004 >Last-Modified: Mon Aug 23 10:56:26 GMT 2004 >Originator: Tim Robbins >Release: FreeBSD 5.0-RELEASE i386 >Organization: The FreeBSD Project >Environment: System: FreeBSD 5.0-RELEASE i386 >Description: Resident set size calculation is broken in 5.0 because the kernel stack is counted towards the RSS even when a process has been swapped out. In fill_kinfo_proc(): kp->ki_rssize = vmspace_resident_count(vm); /*XXX*/ if (p->p_sflag & PS_INMEM) kp->ki_rssize += UAREA_PAGES; FOREACH_THREAD_IN_PROC(p, td) /* XXXKSE: thread swapout check */ kp->ki_rssize += KSTACK_PAGES; Note the way KSTACK_PAGES is added on to the RSS even when threads are are swapped out and the XXXKSE comment. >How-To-Repeat: Run some processes. Allocate enough memory so that some processes get swapped out. Observe the RSS with 'top' and notice that it is not 0 for swapped-out processes. >Fix: Not supplied. >Release-Note: >Audit-Trail: Responsible-Changed-From-To: freebsd-bugs->julian Responsible-Changed-By: tjr Responsible-Changed-When: Tue Mar 11 02:05:00 PST 2003 Responsible-Changed-Why: Over to Julian. http://www.freebsd.org/cgi/query-pr.cgi?pr=49102 From: "Tim Robbins" To: Cc: Subject: kern/49102: Resident set size calculation broken in 5.x Date: Tue, 11 Mar 2003 20:52:58 +1100 (EST) >Number: 49102 >Category: kern >Synopsis: Resident set size calculation broken in 5.x >Confidential: no >Severity: serious >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Mar 11 02:00:27 PST 2003 >Closed-Date: >Last-Modified: >Originator: Tim Robbins >Release: FreeBSD 5.0-RELEASE i386 >Organization: The FreeBSD Project >Environment: System: FreeBSD 5.0-RELEASE i386 >Description: Resident set size calculation is broken in 5.0 because the kernel stack is counted towards the RSS even when a process has been swapped out. In fill_kinfo_proc(): =09kp->ki_rssize =3D vmspace_resident_count(vm); /*XXX*/ =09if (p->p_sflag & PS_INMEM) =09=09kp->ki_rssize +=3D UAREA_PAGES; =09FOREACH_THREAD_IN_PROC(p, td) /* XXXKSE: thread swapout check */ =09=09kp->ki_rssize +=3D KSTACK_PAGES; Note the way KSTACK_PAGES is added on to the RSS even when threads are are swapped out and the XXXKSE comment. >How-To-Repeat: Run some processes. Allocate enough memory so that some processes get swapped out. Observe the RSS with 'top' and notice that it is not 0 for swapped-out processes. >Fix: Not supplied. >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message From: Bruce Evans To: Tim Robbins Cc: FreeBSD-gnats-submit@FreeBSD.ORG Subject: Re: kern/49102: Resident set size calculation broken in 5.x Date: Tue, 11 Mar 2003 23:22:36 +1100 (EST) > >Description: > > Resident set size calculation is broken in 5.0 because the kernel stack > is counted towards the RSS even when a process has been swapped out. > > In fill_kinfo_proc(): > kp->ki_rssize = vmspace_resident_count(vm); /*XXX*/ > if (p->p_sflag & PS_INMEM) > kp->ki_rssize += UAREA_PAGES; > FOREACH_THREAD_IN_PROC(p, td) /* XXXKSE: thread swapout check */ > kp->ki_rssize += KSTACK_PAGES; > > Note the way KSTACK_PAGES is added on to the RSS even when threads are > are swapped out and the XXXKSE comment. When fixing this, don't forget to fix ttyinfo(). ttyinfo() now gives perfect results for swapped out processes only, since it never counts either user pages or stack pages. Here is a part of patch to make it mostly bug for bug compatible with fill_kinfo_proc() (the full patch is too confusing to show here since it changes most of the variable names ane indentaion): %%% + /* + * XXXKSE the rss calculation is bug-for-bug compatible with + * the one in fill_kinfo_proc(), except we only check + * TD_AWAITING_INTR() here and only check p_vmspace there. + */ ... - vmspace_resident_count(pick->p_vmspace)); ... + rss = pgtok(vmspace_resident_count(pick->p_vmspace)); + if (pick->p_sflag & PS_INMEM) + rss += UAREA_PAGES; + FOREACH_THREAD_IN_PROC(pick, td1) + rss += KSTACK_PAGES; %%% Printing of %cpu in ttyinfo() is also broken. See RELENG_4 for a fix. RELENG_4 just uses vmspace_resident_count() in both fill_kinfo_proc() and ttyinfo(). I'm not sure if vmspace_resident_count() counted "user" pages. If it did, then there may be some subtle paging bugs from not counting the user and stack pages in vm_pageout.c. Bruce State-Changed-From-To: open->closed State-Changed-By: tjr State-Changed-When: Mon Aug 23 10:56:11 GMT 2004 State-Changed-Why: Fixed a long time ago. http://www.freebsd.org/cgi/query-pr.cgi?pr=49102 >Unformatted: