Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 3 Jun 2018 21:09:15 +0200
From:      Polytropon <freebsd@edvax.de>
To:        Brennan Vincent <brennan@umanwizard.com>
Cc:        John Howie <john@thehowies.com>, freebsd-questions@freebsd.org
Subject:   Re: Is it normal that a user can take down the whole system by using too much memory?
Message-ID:  <20180603210915.7da21bf1.freebsd@edvax.de>
In-Reply-To: <1527981931.2670335.1394316280.09410FC9@webmail.messagingengine.com>
References:  <1527977770.2651378.1394286400.0806CC5C@webmail.messagingengine.com> <01EE7EEA-03AC-4D71-BA08-B0CEA97EE720@thehowies.com> <1527981931.2670335.1394316280.09410FC9@webmail.messagingengine.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 02 Jun 2018 19:25:31 -0400, Brennan Vincent wrote:
> I'm also curious, however, to learn more from an OS design perspective.
> Why isn't it possible for the kernel to realize it should kill `eatmem`
> rather than make the system unusable?
> 
> Is this a hard problem in general, or just a missing feature in FreeBSD
> specifically ?

It's more about what the kernel's basic function is: to control
the interactions of hardware and software. In case of "eatmem"
or any other program that allocates memory, there _might_ be a
totally valid and legitimate (!) reason for a problem program
to do so. If physical RAM has been consumed, swap will be added.
This is still within normal margins of system use. Just consider
today's memory-intensive user applications like web browsers.
At which threshold should the kernel say: "Okay, no more RAM
for you, please go kill yourself, or I will do it in 60 seconds.",
which is (more or less) what you seem to expect?

Resource control mechanisms are present in FreeBSD, but it takes
a system administrator with sufficient knowledge and experience
to decide about the values that will apply - how much RAM can be
consumed, how many child processes can be spawned, how many files
can be held open... and so on. There just is no system default
that can be preconfigured, calculated, assumed, guessed, or
arbitrarily chosen. No "one size fits all" solution is possible.

Just take the following example: A problem program will do some
database lookup, store lots of data in memory, then calculate
something from it, build another set of memory-intensive struc-
tures, and then start heavy disk I/O do write lots of result
files. This might require more RAM than the system has. Let's
say it's 64 GB. The program now needs 80 GB, so swap will be
used. After a period of heavy system activity, memory will be
released again. Load values go back to normal.

For this example, try to imagine at what stage the kernel should
interfere. And _should_ it interfere? From the practical point
of view, everything worked as it was intended and expected.




-- 
Polytropon
Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180603210915.7da21bf1.freebsd>