All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Kellermann <mk@cm4all.com>
To: Tejun Heo <tj@kernel.org>
Cc: cgroups@vger.kernel.org, cyphar@cyphar.com, lizefan@huawei.com,
	hannes@cmpxchg.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cgroup_pids: add fork limit
Date: Tue, 10 Nov 2015 16:37:46 +0100	[thread overview]
Message-ID: <20151110153746.GA20758@rabbit.intern.cm-ag> (raw)
In-Reply-To: <20151110151223.GA17938@mtj.duckdns.org>

On 2015/11/10 16:12, Tejun Heo <tj@kernel.org> wrote:
> On Tue, Nov 10, 2015 at 03:06:46PM +0100, Max Kellermann wrote:
> > This patch introduces a new setting called "fork_remaining".  When
> > positive, each successful fork decrements the value, and once it
> > reaches zero, no further forking is allowed, no matter how many of
> > those processes are still alive.  The special value "unlimited"
> > disables the fork limit.
> > 
> > The goal of this limit is to have another safeguard against fork
> > bombs.  It gives processes a chance to set up their child processes /
> > threads, but will be stopped once they attempt to waste resources by
> > continuously exiting and cloning new processes.  This can be useful
> > for short-lived processes such as CGI programs.
> 
> But what's the resource here?

CPU consumption and memory bandwidth.  A fork/clone is an operation
that puts considerable load on a machine, most of which happens in
kernel space (copying page tables etc.).

> All first-order resources which can be consumed by forking
> repeatedly already have proper controllers.

They do?

I can limit CPU time with RLIMIT_CPU, but that's per-process and thus
completely useless.  There's no cgroup controller with such a feature.
There's "cpu" which changes priority, "cpuset" selects CPUs, "cpuacct"
only does accounting and "freezer" (somewhat related).  But nothing
that limits CPU usage according to configured rules.

I can limit absolute memory usage with memcg, which is a good thing,
but is orthogonal to this feature.  Note that there are already
various RLIMITs about memory usage, and despite that, memcg was
merged due to RLIMIT shortcomings.

"pids" was merged even though there already was RLIMIT_NPROC.  Again,
RLIMITs have their shortcomings.

But which controllers can I use to achieve the same effect as my fork
limit feature?  Did I miss one?

> What's the point of adding an extra second-order controller?

I explained that, and you just cited my explanation.

> Where do we go from there?  Limit on the number of syscalls?

No idea.  Are these questions really relevant for my patch?

Max

  reply	other threads:[~2015-11-10 15:37 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 [this message]
     [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
     [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=20151110153746.GA20758@rabbit.intern.cm-ag \
    --to=mk@cm4all.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=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.