unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: rms@gnu.org
Cc: luangruo@yahoo.com, Stefan Monnier <monnier@iro.umontreal.ca>,
	emacs-devel@gnu.org
Subject: Re: master 5c532fe303: Recommend that the user turn off memory overcommit
Date: Sat, 09 Apr 2022 20:42:51 +1200	[thread overview]
Message-ID: <a5b2a8ef9ed04e765c459584dda53d81@webmail.orcon.net.nz> (raw)
In-Reply-To: <E1nd2Xp-0004yr-FK@fencepost.gnu.org>

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.





  parent reply	other threads:[~2022-04-09  8:42 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <164941780605.21656.13343783431945268284@vcs2.savannah.gnu.org>
     [not found] ` <20220408113647.815ACC051D6@vcs2.savannah.gnu.org>
2022-04-08 12:58   ` master 5c532fe303: Recommend that the user turn off memory overcommit Stefan Monnier
2022-04-08 13:23     ` Óscar Fuentes
2022-04-08 13:31       ` Po Lu
2022-04-08 13:42         ` Brian Cully
2022-04-08 13:57           ` Po Lu
2022-04-08 15:03             ` Stefan Monnier
2022-04-08 19:59           ` Eli Zaretskii
2022-04-08 13:46         ` Óscar Fuentes
2022-04-09  0:23           ` Po Lu
2022-04-09  1:28             ` Óscar Fuentes
2022-04-08 19:17     ` Eli Zaretskii
2022-04-09  4:17     ` Richard Stallman
2022-04-09  5:51       ` Tim Cross
2022-04-09  8:42       ` Phil Sainty [this message]
2022-04-09  9:08         ` Po Lu
2022-04-09 10:08           ` Phil Sainty
2022-04-09 10:27           ` Achim Gratz
2022-04-09  9:56         ` Eli Zaretskii
2022-04-09 10:28           ` Phil Sainty
2022-04-09 10:41             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a5b2a8ef9ed04e765c459584dda53d81@webmail.orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=emacs-devel@gnu.org \
    --cc=luangruo@yahoo.com \
    --cc=monnier@iro.umontreal.ca \
    --cc=rms@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).