From b19ec1be3c35b0ec231282ab51d0b320e2967052 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 4 Mar 2022 19:21:38 -0800 Subject: [PATCH] %CPU can exceed 100 on GNU/Linux * src/sysdep.c (system_process_attributes) [GNU_LINUX]: CPU usage can exceed 100% on a multicore platform when Emacs is not entirely single-threaded. --- doc/lispref/processes.texi | 5 +++-- src/sysdep.c | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/doc/lispref/processes.texi b/doc/lispref/processes.texi index d338d59a814..ed07c1cbf70 100644 --- a/doc/lispref/processes.texi +++ b/doc/lispref/processes.texi @@ -2382,8 +2382,9 @@ occupied by the process in the machine's physical memory. @item pcpu The percentage of the CPU time used by the process since it started. -The corresponding @var{value} is a floating-point number between 0 and -100. +The corresponding @var{value} is a nonnegative floating-point number. +Although in theory the number can exceed 100 on a multicore platform, +it is usually less than 100 because Emacs is typically single-threaded. @item pmem The percentage of the total physical memory installed on the machine diff --git a/src/sysdep.c b/src/sysdep.c index 28d32c77c63..c9101f94818 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -3487,8 +3487,6 @@ system_process_attributes (Lisp_Object pid) attrs = Fcons (Fcons (Qetime, make_lisp_time (telapsed)), attrs); us_time = time_from_jiffies (u_time + s_time, clocks_per_sec); pcpu = timespectod (us_time) / timespectod (telapsed); - if (pcpu > 1.0) - pcpu = 1.0; attrs = Fcons (Fcons (Qpcpu, make_float (100 * pcpu)), attrs); pmem = 4.0 * 100 * rss / procfs_get_total_memory (); if (pmem > 100) -- 2.39.5