From: Austin S Hemmelgarn <ahferroin7@gmail.com>
To: Parav Pandit <pandit.parav@gmail.com>
Cc: Aleksa Sarai <cyphar@cyphar.com>, Max Kellermann <mk@cm4all.com>,
Tejun Heo <tj@kernel.org>,
cgroups@vger.kernel.org, lizefan@huawei.com,
Johannes Weiner <hannes@cmpxchg.org>,
max@duempel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup_pids: add fork limit
Date: Tue, 10 Nov 2015 14:54:43 -0500 [thread overview]
Message-ID: <56424B83.2080504@gmail.com> (raw)
In-Reply-To: <CAG53R5XfNjuBcwNZW4pB_bhq2+vLoo1UKQ7Rqhx=TdLMa5abuw@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 3703 bytes --]
On 2015-11-10 11:19, Parav Pandit wrote:
> On Tue, Nov 10, 2015 at 9:28 PM, Austin S Hemmelgarn
> <ahferroin7@gmail.com> wrote:
>> On 2015-11-10 10:25, Aleksa Sarai wrote:
>>>
>>> Processes don't "use up resources" after they've died and been freed
>>> (which is dealt with inside PIDs). Yes, lots of small processes that
>>> die quickly could (in principle) make hard work for the scheduler, but
>>> I don't see how "time spent scheduling in general" is a resource...
>>> Fork bombs aren't bad because they cause a lot of fork()s, they're bad
>>> because the *create a bunch of processes that use up memory*, which
>>> happens because they call fork() a bunch of times and **don't
>>> exit()**.
>>
>> While I'm indifferent about the patch, I would like to point out that
>> fork-bombs are also bad because they eat _a lot_ of processor time, and I've
>> seen ones designed to bring a system to it's knees just by saturating the
>> processor with calls to fork() (which is as slow as or slower than stat() on
>> many commodity systems, setting up the various structures for a new process
>> is an expensive operation) and clogging up the scheduler.
>
> Isn't cpu cgroup helpful there to limit it?
Possibly, I don't know the specifics of how it handles stuff executing
in a context technically outside of a process on behalf of that process.
I'm almost 100% certain that there is no sane way it can account and
limit time spent in the scheduler because a process is spawning lots of
children.
> Are you saying time spent by scheduler is more that actually affects
> the scheduling of processes of other threads?
In some cases yes, although this is very dependent on the system itself
(for example, if you have a really low /proc/sys/pids_max, it will never
be an issue, but that will also make it easier for a fork-bomb to make
your system unusable). The scheduler on Linux is comparatively fast for
how feature rich it is, but it still slows down as you have more and
more processes to schedule. If you have a lot of RAM proportionate to
your processing power (as in, multiple GB on a processor running at only
a few MHz, and yes such systems do exist), then the scheduling overhead
is much more significant than the memory overhead. Even without such a
situation, it's fully possible to weigh down the system with overhead
from the kernel. As an example, a on a Raspberry Pi (single core 700MHz
ARM11stj-z CPU, 512MB of RAM), you can spawn a few hundred processes
each just sitting on an interval timer set so that every time the
scheduler runs, at least 10% of them are runnable (and I've seen
fork-bombs that do this), and you will render the system unusable not
because of memory consumption, but the scheduling and timer overhead.
> If so, could you share little more insight on how that time measure
> outside of the cpu's cgroup cycles? Just so that its helpful to wider
> audience.
Well, there are a number of things that I can think of that the kernel
does on behalf of processes that can consume processor time that isn't
trivial to account:
* Updating timers on behalf of userspace processes (itimers or similar).
* Sending certain kernel generated signals to processes (that is,
stuff generated by the kernel like SIGFPE, SIGSEGV, and so forth).
* Queuing events from dnotify/inotify/fanotify.
* TLB misses, page faults, and swapping.
* Setting up new processes prior to them actually running.
* Scheduling.
All of these are things that fork-bombs can and (other than TLB misses)
do exploit to bring a system down, and the cpu cgroup is by no means a
magic bullet to handle this.
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 3019 bytes --]
next prev parent reply other threads:[~2015-11-10 19:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-10 14:06 [PATCH] cgroup_pids: add fork limit Max Kellermann
[not found] ` <144716440621.20175.1000688899886388119.stgit-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2015-11-10 15:12 ` Tejun Heo
2015-11-10 15:12 ` Tejun Heo
2015-11-10 15:37 ` Max Kellermann
[not found] ` <20151110153746.GA20758-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2015-11-10 15:44 ` Tejun Heo
2015-11-10 15:44 ` Tejun Heo
2015-11-10 17:06 ` Max Kellermann
2015-11-10 17:06 ` Max Kellermann
2015-11-10 17:29 ` Tejun Heo
[not found] ` <20151110172915.GA13740-qYNAdHglDFBN0TnZuCh8vA@public.gmane.org>
2015-11-10 17:52 ` Max Kellermann
2015-11-10 17:52 ` Max Kellermann
2015-11-10 15:25 ` Aleksa Sarai
2015-11-10 15:25 ` Aleksa Sarai
2015-11-10 15:58 ` Austin S Hemmelgarn
2015-11-10 16:19 ` Parav Pandit
2015-11-10 19:54 ` Austin S Hemmelgarn [this message]
[not found] ` <56424B83.2080504-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-11-15 13:36 ` Aleksa Sarai
2015-11-15 13:36 ` Aleksa Sarai
[not found] ` <CAOviyag=rHcDZj3MBR3dMbkdaOY=h1FB-78QLM3CZQe2WrrgCQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-16 17:02 ` Austin S Hemmelgarn
2015-11-16 17:02 ` Austin S Hemmelgarn
2015-11-10 16:01 ` Max Kellermann
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56424B83.2080504@gmail.com \
--to=ahferroin7@gmail.com \
--cc=cgroups@vger.kernel.org \
--cc=cyphar@cyphar.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lizefan@huawei.com \
--cc=max@duempel.org \
--cc=mk@cm4all.com \
--cc=pandit.parav@gmail.com \
--cc=tj@kernel.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.