emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master 5c532fe303: Recommend that the user turn off memory overcommi


From: Phil Sainty
Subject: Re: master 5c532fe303: Recommend that the user turn off memory overcommit
Date: Sat, 09 Apr 2022 20:42:51 +1200
User-agent: Orcon Webmail

I keep seeing the choice of process to kill being described as
"random", but it is not random.

The kernel may or may not choose the best process to kill, but
it does choose it for a reason, and I would suggest that the
described criteria is fairly unlikely to describe an Emacs
process (although it's obviously still possible).

The selection process is described in the article that I linked
to previously in a related thread:

https://www.kernel.org/doc/gorman/html/understand/understand016.html

13.3 Selecting a Process

The function select_bad_process() is responsible for choosing a
process to kill. It decides by stepping through each running task
and calculating how suitable it is for killing with the function
badness(). The badness is calculated as follows, note that the
square roots are integer approximations calculated with
int_sqrt();

badness_for_task = total_vm_for_task /
  (sqrt(cpu_time_in_seconds) * sqrt(sqrt(cpu_time_in_minutes)))

This has been chosen to select a process that is using a large
amount of memory but is not that long lived. Processes which have
been running a long time are unlikely to be the cause of memory
shortage so this calculation is likely to select a process that
uses a lot of memory but has not been running long. If the
process is a root process or has CAP_SYS_ADMIN capabilities, the
points are divided by four as it is assumed that root privilege
processes are well behaved. Similarly, if it has CAP_SYS_RAWIO
capabilities (access to raw devices) privileges, the points are
further divided by 4 as it is undesirable to kill a process that
has direct access to hardware.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]