%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.
This commit is contained in:
Paul Eggert 2022-03-04 19:21:38 -08:00
parent af742bb3bb
commit b19ec1be3c
2 changed files with 3 additions and 4 deletions

View file

@ -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

View file

@ -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)