Out-of-swap killer and SIGTERM signal

From: ralph41096 <ralph41096_at_protonmail.com>
Date: Mon, 10 Jan 2022 12:55:56 UTC
Hello,

Do you think it would be a good idea to introduce the following soft
mode for the Out-of-swap killer?

Old behaviour:
  1) If there is no free swap space left, send SIGKILL signals to the
     condemned processes. (This is the hard mode.)

New behaviour:
  1) If there is less than 2 GiB of free swap space, send SIGTERM
     signals to the condemned processes, then wait for a 5 seconds
     grace period, then send SIGKILL signals to the condemned processes
     who are still running.
  2) Repeat step 1) until the amount of free swap space becomes greater
     than 2 GiB. (This is the soft mode.)
  3) If the soft mode does not release swap space fast enough, and the
     amount of free swap space becomes zero, enter hard mode and
     immediately send SIGKILL signals to the condemned processes.

These two system-wide parameters (2 GiB of free swap space, 5 seconds
grace period) could be defined in a configuration file, to allow the
administrator to change them.

The intent is to allow condemned processes to write some data on
persistent storage and exit gracefully, when the shortage of swap space
does not happen too quickly.

Ambert