From owner-svn-src-all@freebsd.org Sat Mar 3 19:15:32 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66955F33621; Sat, 3 Mar 2018 19:15:32 +0000 (UTC) (envelope-from alc@rice.edu) Received: from mx0b-0010f301.pphosted.com (mx0b-0010f301.pphosted.com [148.163.153.244]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.pphosted.com", Issuer "thawte SHA256 SSL CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C953771579; Sat, 3 Mar 2018 19:15:31 +0000 (UTC) (envelope-from alc@rice.edu) Received: from pps.filterd (m0102860.ppops.net [127.0.0.1]) by mx0b-0010f301.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w23J6B95023498; Sat, 3 Mar 2018 13:06:40 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rice.edu; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=ricemail; bh=CeU5WV0Yi/FTWrvgqpwNR72U6e9R5Ds7NvBZgccOmLs=; b=GpsZ4GT36KgVlltcZSSLs6v7G0f1a21C1t4TJ/+t9e+t9+jdp4Zk/0Sjx43yurQWG6P2 3meDoT2okc4Mw8tiWo3vyOHHu+iF6D9Pt59p3rBy4SSiK+/tdjuYq9WiEiOB+FsI69SV IQwD0f7BM2o64f68e0f/Kk8GX9U9gAj+WGpi8Z9z3IKemmFcFFASguSGhzfC6LCjjku6 IQ5HM9gOLWBhxCC1FbwtjYEvoEMRes8hnZmcp1Rd6qP1TsdPPTO7ZKqI5bd3z280NglC HJgRqQsZ7oDZFlmr7tIx4yhaJtbclmDEtlpV7r7dDukjkomANqMh8R6RfABlcTK+dt6s dQ== Received: from mh2.mail.rice.edu (mh2.mail.rice.edu [128.42.201.21]) by mx0b-0010f301.pphosted.com with ESMTP id 2gfsy3rapq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 03 Mar 2018 13:06:40 -0600 Received-X: from mh2.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh2.mail.rice.edu (Postfix) with ESMTP id A75D1500281; Sat, 3 Mar 2018 13:06:39 -0600 (CST) Received-X: from mh2.mail.rice.edu (localhost.localdomain [127.0.0.1]) by mh2.mail.rice.edu (Postfix) with ESMTP id A5DF550023A; Sat, 3 Mar 2018 13:06:39 -0600 (CST) X-Virus-Scanned: by amavis-2.7.0 at mh2.mail.rice.edu, auth channel Received-X: from mh2.mail.rice.edu ([127.0.0.1]) by mh2.mail.rice.edu (mh2.mail.rice.edu [127.0.0.1]) (amavis, port 10026) with ESMTP id cjkZKRXwP4wv; Sat, 3 Mar 2018 13:06:39 -0600 (CST) Received: from 108-254-203-201.lightspeed.hstntx.sbcglobal.net (162-234-74-167.lightspeed.hstntx.sbcglobal.net [162.234.74.167]) (using TLSv1.2 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: alc) by mh2.mail.rice.edu (Postfix) with ESMTPSA id 483D1500248; Sat, 3 Mar 2018 13:06:39 -0600 (CST) Subject: Re: svn commit: r309017 - in head/sys: cddl/compat/opensolaris/sys compat/linprocfs fs/tmpfs sys vm To: Alexey Dokuchaev , Alan Cox Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org References: <201611221813.uAMIDkHQ071392@repo.freebsd.org> <20180303084817.GA66382@FreeBSD.org> From: Alan Cox Message-ID: <40f92b0f-9abf-efdc-f1f8-b222fb036c69@rice.edu> Date: Sat, 3 Mar 2018 13:06:38 -0600 User-Agent: Mozilla/5.0 (X11; FreeBSD i386; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <20180303084817.GA66382@FreeBSD.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2018-03-03_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=10 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=788 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1803030242 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Mar 2018 19:15:32 -0000 On 03/03/2018 02:48, Alexey Dokuchaev wrote: > On Tue, Nov 22, 2016 at 06:13:46PM +0000, Alan Cox wrote: >> New Revision: 309017 >> URL: https://svnweb.freebsd.org/changeset/base/309017 >> >> Log: >> Remove PG_CACHED-related fields from struct vmmeter, because they are no >> longer used. More precisely, they are always zero because the code that >> decremented and incremented them no longer exists. >> >> Bump __FreeBSD_version to mark this change. >> >> Reviewed by: kib, markj >> Sponsored by: Dell EMC Isilon >> Differential Revision: https://reviews.freebsd.org/D8583 >> >> Modified: head/sys/cddl/compat/opensolaris/sys/kmem.h >> ... >> -#define freemem (vm_cnt.v_free_count + vm_cnt.v_cache_count) >> +#define freemem vm_cnt.v_free_count > This looks correct now. > >> Modified: head/sys/compat/linprocfs/linprocfs.c >> ... >> @@ -176,7 +176,7 @@ linprocfs_domeminfo(PFS_FILL_ARGS) >> * like unstaticizing it just for linprocfs's sake. >> */ >> buffers = 0; >> - cached = vm_cnt.v_cache_count * PAGE_SIZE; >> + cached = vm_cnt.v_inactive_count * PAGE_SIZE; > Some applications that make calculations based on the readings from the > /usr/compat/linux/proc/meminfo are broken after this change, e.g. those > that do things like: > > return (totalMem - (freeMem + buffers + cache)) / totalMem; > > because now free memory includes cached one, and above formula gives > bogus negative result. > > In `sys/compat/linprocfs/linprocfs.c', memfree is calculated as follows: > > memtotal = physmem * PAGE_SIZE; > /* > * The correct thing here would be: > * > memfree = vm_cnt.v_free_count * PAGE_SIZE; > memused = memtotal - memfree; > * > * but it might mislead linux binaries into thinking there > * is very little memory left, so we cheat and tell them that > * all memory that isn't wired down is free. > */ > memused = vm_cnt.v_wire_count * PAGE_SIZE; > memfree = memtotal - memused; > > So, when vm.stats.vm.v_cache_count was yielding some (typically small) > result, using the aforementioned trick made sense (because even when > vm_cnt.v_free_count added to vm.stats.vm.v_cache_count it would still > be rather small). This logic no longer applies after this change. > > On my 12-CURRENT i386 system, /usr/compat/linux/proc/meminfo reports: > > % cat /usr/compat/linux/proc/meminfo | head -4 > MemTotal: 3132504 kB > MemFree: 2925936 kB <<< that's a lot > Buffers: 0 kB > Cached: 2212196 kB <<< that's also a lot > > On an older 4.11-STABLE box (also i386), it reports: > > MemTotal: 521828 kB > MemFree: 383976 kB > MemShared: 7480 kB > Buffers: 0 kB > Cached: 22732 kB (can be added to MemFree and still < MemTotal) > > So either the "cheat" have to go away and vm_cnt.v_free_count used as it > should, or cached memory should not be read from vm_cnt.v_inactive_count > but estimated somehow else. Which approach would be more correct? The former.