From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#72278: 29.4; Proced reports incorrect results with 16KB page size Date: Thu, 25 Jul 2024 02:55:32 -0700 Message-ID: References: <87v80un1rz.fsf@zohomail.eu> <86zfq65acb.fsf@gnu.org> <88d8077a-b01b-4428-8388-6944581bdfe7@cs.ucla.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26147"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Rahguzar , 72278@debbugs.gnu.org To: Paul Eggert , Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jul 25 11:57:17 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sWvDp-0006e0-Fo for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 25 Jul 2024 11:57:17 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sWvDX-0005ko-PG; Thu, 25 Jul 2024 05:56:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sWvDU-0005V0-Iu for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 05:56:56 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sWvDT-0002B6-Pz for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 05:56:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sWvDZ-0006PA-N8 for bug-gnu-emacs@gnu.org; Thu, 25 Jul 2024 05:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 25 Jul 2024 09:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 72278 X-GNU-PR-Package: emacs Original-Received: via spool by 72278-submit@debbugs.gnu.org id=B72278.172190141024596 (code B ref 72278); Thu, 25 Jul 2024 09:57:01 +0000 Original-Received: (at 72278) by debbugs.gnu.org; 25 Jul 2024 09:56:50 +0000 Original-Received: from localhost ([127.0.0.1]:35564 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWvDO-0006Oe-1O for submit@debbugs.gnu.org; Thu, 25 Jul 2024 05:56:50 -0400 Original-Received: from mail-ed1-f42.google.com ([209.85.208.42]:57851) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sWvDL-0006ON-7y for 72278@debbugs.gnu.org; Thu, 25 Jul 2024 05:56:48 -0400 Original-Received: by mail-ed1-f42.google.com with SMTP id 4fb4d7f45d1cf-5a156556fb4so959690a12.3 for <72278@debbugs.gnu.org>; Thu, 25 Jul 2024 02:56:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721901334; x=1722506134; darn=debbugs.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:from:to:cc:subject:date :message-id:reply-to; bh=uKVcavsFsP/Xnc/Obmg/ANxGq4gvv0TdF9GPw78vtFQ=; b=H/1N0wZrpUIHHV6NVjGQ5GyomABXvz+uIuUIf9psjaIwGSM8kgmEdHbm2EPFL2UiV0 UmQ7JUquHFkAp/o5cHkktaEq0pMUAOQ5tWrmSiUORmFuLoCMhzm3qNuUukAuN3GhV4K7 MFym0wnloqAyjuE2m0+tPES9jXGum+wosQ33r32960aVmqAi787NCIwM/viGoKPtZtiD 0kjgUPbsTyjJR1thuq2X7ZsnmNHTjuNMZyUbsutgeYQbJNIK4jTLOJzg/UELcw46nytJ tkojgtcviIZLbmw1eQISLLPP4T+F2vxlPflpfjRODDFb7saii/8JWK2nXIi0/neQFU3d U/cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721901334; x=1722506134; h=content-transfer-encoding:cc:to:subject:message-id:date :mime-version:references:in-reply-to:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=uKVcavsFsP/Xnc/Obmg/ANxGq4gvv0TdF9GPw78vtFQ=; b=ZI35ICzRklBA08QQ5J9yUWKezyZL63rFvc44eh62rERx0MwCWPQYZBFXuVxaVonWSP AcFNoEL5yzWqcUF3YLbtW3R0MIuwOCZ0ALvVI+fS7gRD62rdO5KPbFgBz2tAADUump4r dGPGIBjvg+QstOrORT9PyIQdZcg3quuUwOWZkPicwwStZW5TOeF+u3OU9hL8anqVa8Yd /I0DbH+jJURE5j7ec2wsdB7dSdWXoZd+uBCCqdtTkmMLfykjxzFUR4pF1718BxHbj4ix 5o8M/kAzKMkaltqCEMFcFFOQQU4NWeYKhUNiV3Yf6C2Q0yNPqOZypHS/UteA1Zj35lQi SbWA== X-Forwarded-Encrypted: i=1; AJvYcCXKPID05mRwpDlybRIGa7qq22zbQJlUbFBKYj/0re7jYqTi15PtFWzLtB+kDngjsHQnle8YTvZNtiy+/z4g7KmqRFp/e5w= X-Gm-Message-State: AOJu0Yybde4dM/Pi9E7fFgcAuOFRGWxDFOaDwUxo3sWkQoREttw367ig gRa1ymEN+gvVONSmzoTAFxEJjqh7hz4dm2DkZQFBrSJ4l6jlyx9NtsXYAP/m2VmEDLdm4kBslbM y6Gax++AHdxjNDpdrUKZP7ksLnSc= X-Google-Smtp-Source: AGHT+IGJm/UFXTDr6T8B6LW5JPfdXU47b3BZ5uS7IIMgpTLpDynD39b7IhESjfBNRn4CxMezLd0E83hIE8sNylSL9HA= X-Received: by 2002:a50:f609:0:b0:58b:12bd:69c8 with SMTP id 4fb4d7f45d1cf-5ac641292b1mr937625a12.36.1721901334114; Thu, 25 Jul 2024 02:55:34 -0700 (PDT) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Thu, 25 Jul 2024 02:55:32 -0700 In-Reply-To: <88d8077a-b01b-4428-8388-6944581bdfe7@cs.ucla.edu> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:289296 Archived-At: Paul Eggert writes: > From 42cdfe7f60ef7ae3bccb5b1e43349c3a6b54ac4a Mon Sep 17 00:00:00 2001 > From: Paul Eggert > Date: Wed, 24 Jul 2024 23:32:24 -0700 > Subject: [PATCH] Fix process-attributes rss and pmem on GNU/Linux > MIME-Version: 1.0 > Content-Type: text/plain; charset=3DUTF-8 > Content-Transfer-Encoding: 8bit > > Problem reported by Rahguzar . > * src/sysdep.c (system_process_attributes): > [GNU_LINUX || CYGWIN || __ANDROID__]: When computing rss and pmem, > don=E2=80=99t assume pagesize is 4096; it could be greater. > --- > src/sysdep.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/src/sysdep.c b/src/sysdep.c > index d916a695155..3955d796ca5 100644 > --- a/src/sysdep.c > +++ b/src/sysdep.c > @@ -3548,6 +3548,7 @@ procfs_ttyname (int rdev) > } > # endif /* GNU_LINUX || __ANDROID__ */ > > +/* Total usable RAM in KiB. */ > static uintmax_t > procfs_get_total_memory (void) > { > @@ -3737,8 +3738,13 @@ system_process_attributes (Lisp_Object pid) > attrs =3D Fcons (Fcons (Qnice, make_fixnum (niceness)), attrs); > attrs =3D Fcons (Fcons (Qthcount, INT_TO_INTEGER (thcount)), attrs); > attrs =3D Fcons (Fcons (Qvsize, INT_TO_INTEGER (vsize / 1024)), attrs= ); > - attrs =3D Fcons (Fcons (Qrss, INT_TO_INTEGER (4 * rss)), attrs); > - pmem =3D 4.0 * 100 * rss / procfs_get_total_memory (); > + > + /* RSS in KiB. */ > + uintmax_t rssk =3D rss; > + rssk *=3D getpagesize () >> 10; > + > + attrs =3D Fcons (Fcons (Qrss, INT_TO_INTEGER (rssk)), attrs); > + pmem =3D 100.0 * rssk / procfs_get_total_memory (); Thanks, that looks like an improvement. On Linux, page sizes can vary per process ("multiple page size support"). Should we bother with that? I also note that the man page for getpagesize says this: This call first appeared in 4.2BSD. SVr4, 4.4BSD, SUSv2. In SUSv2 the getpagesize() call was labeled LEGACY, and it was removed in POSIX.1-2001. > if (pmem > 100) > pmem =3D 100; > attrs =3D Fcons (Fcons (Qpmem, make_float (pmem)), attrs); > -- > 2.43.0