From owner-freebsd-bugs@freebsd.org Tue Aug 4 08:31:19 2020 Return-Path: Delivered-To: freebsd-bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7B1A23B5391 for ; Tue, 4 Aug 2020 08:31:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4BLSdg2dbpz43xL for ; Tue, 4 Aug 2020 08:31:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.nyi.freebsd.org (Postfix) id 5A7273B5390; Tue, 4 Aug 2020 08:31:19 +0000 (UTC) Delivered-To: bugs@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 5A3AE3B5239 for ; Tue, 4 Aug 2020 08:31:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4BLSdg0QSfz44CN for ; Tue, 4 Aug 2020 08:31:19 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id E611A22560 for ; Tue, 4 Aug 2020 08:31:18 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 0748VIId090781 for ; Tue, 4 Aug 2020 08:31:18 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 0748VIxZ090780 for bugs@FreeBSD.org; Tue, 4 Aug 2020 08:31:18 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 248463] linprocfs: /proc/meminfo values do not add up Date: Tue, 04 Aug 2020 08:31:18 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: danfe@FreeBSD.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Aug 2020 08:31:19 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D248463 Bug ID: 248463 Summary: linprocfs: /proc/meminfo values do not add up Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: danfe@FreeBSD.org While porting some software which originates from GNU/Linux and collects me= mory usage information from /proc/meminfo, I've noticed one common pattern of failure when the same code runs on FreeBSD: the amount of estimated "free" memory is larger than total memory. (Obligatory disclaimer: It's been known for years that reasoning about free/used memory is to a certain extent short of black magic, and it's prob= ably better to avoid broad generalisations like "used" and "free" at all, but pe= ople still do this in otherwise nice and useful software, so we'd better make su= re it runs properly on FreeBSD.) Back to the popular calculation formula: the amount of memory actually in u= se is often assessed, in the /proc/meminfo field terms, as "MemTotal - (MemFre= e + Buffers + Cached)". Now, the problem is that on FreeBSD, apparently, "MemF= ree + Cached" is always larger than MemTotal (Buffers are always zero, because "bufspace is internal to vfs_bio.c and we don't feel like unstaticizing it = just for linprocfs's sake" per the comment in the linprocfs.c). Reading the code in /sys/compat/linprocfs/linprocfs.c around line 163 (sear= ch for "cheat") shows that while trying to avoid misleading Linux binaries into thinking there is very little memory left by reporting that all memory that isn't wired down is free, we instead mislead them in a different way by screwing their calculations as the amount of used memory becomes negative. SVN-blaming shows that this "cheating" logic had been added more than 20 ye= ars ago. Perhaps it's time to revisit it? --=20 You are receiving this mail because: You are the assignee for the bug.=