All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Brian K. White" <brian-goxB3+SAe6wAvxtiuMwx3w@public.gmane.org>
To: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Cc: cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH] new cgroup controller "fork"
Date: Fri, 04 Nov 2011 12:43:38 -0400	[thread overview]
Message-ID: <4EB4163A.3060305@aljex.com> (raw)
In-Reply-To: <4EB3E47E.2080003-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>

On 11/4/2011 9:11 AM, Glauber Costa wrote:
> On 11/04/2011 01:03 AM, Li Zefan wrote:
>> 于 2011年11月04日 05:54, Glauber Costa 写道:
>>> On 11/03/2011 06:13 PM, Brian K. White wrote:
>>>> On 11/3/2011 3:25 PM, Glauber Costa wrote:
>>>>> On 11/03/2011 05:20 PM, Max Kellermann wrote:
>>>>>> On 2011/11/03 20:03, Alan Cox<alan@lxorguk.ukuu.org.uk> wrote:
>>>>>>> Sure - I'm just not seeing that a whole separate cgroup for it is
>>>>>>> appropriate or a good plan. Anyone doing real resource management
>>>>>>> needs
>>>>>>> the rest of the stuff anyway.
>>>>>>
>>>>>> Right. When I saw Frederic's controller today, my first thought was
>>>>>> that one could move the fork limit code over into that controller. If
>>>>>> we reach a consensus that this would be a good idea, and would have
>>>>>> chances to get merged, I could probably take some time to refactor my
>>>>>> code.
>>>>>>
>>>>>> Max
>>>>> I'd advise you to take a step back and think if this is really needed.
>>>>> As Alan pointed out, the really expensive resource here is already
>>>>> being
>>>>> constrained by Frederic's controller.
>>>>
>>>> I think this really is a different knob that is nice to have as long as
>>>> it doesn't cost much. It's a way to set a max lifespan in a way that
>>>> isn't really addressed by the other controls. (I could absolutely be
>>>> missing something.)
>>>>
>>>> I think Max explained the issue clearly enough.
>>>
>>> He did, indeed.
>>>
>>>> It doesn't matter that the fork itself is supposedly so cheap.
>>>>
>>>> It's still nice to have a way to say, you may not
>>>> fork/die/fork/die/fork
>>>> in a race.
>>>>
>>>> What's so unimaginable about having a process that you know needs a lot
>>>> of cpu and ram or other resources to do it's job, and you expressly
>>>> want
>>>> to allow it to take as much of those resources as it can, but you know
>>>> it has no need to fork, so if it forks, _that_ is the only
>>>> indication of
>>>> a problem, so you may only want to block it based on that.
>>>>
>>>> Sure many other processes would legitimately fork/die/fork/die a lot
>>>> while never exceeding a few total concurrent tasks, and for them you
>>>> would not want to set any such fork limit. So what?
>>>>
>>> As I said previously, he knows his use cases better than anyone else.
>>> If a use case can be found in which the summation of cpu+task
>>> controllers is not enough, and if this is implemented as an option to
>>> the task controller, and does not make it:
>>> 1) confusing,
>>> 2) more expensive,
>>>
>>> then I don't see why not we shouldn't take it.
>>
>> Quoted from Lennart's reply in another mail thread:
>>
>> "Given that shutting down some services might involve forking off a few
>> things (think: a shell script handling shutdown which forks off a couple
>> of shell utilities) we'd want something that is between "from now on no
>> forking at all" and "unlimited forking". This could be done in many
>> different ways: we'd be happy if we could do time-based rate limiting,
>> but we'd also be fine with defining a certain budget of additional forks
>> a cgroup can do (i.e. "from now on you can do 50 more forks, then you'll
>> get EPERM)."
>>
>> (http://lkml.org/lkml/2011/10/19/468)
>>
>> The last sentence suggests he might like this fork controller.
>
> Well, If I understand Frederic's work well enough, this can be achieved
> by setting the task limit to 0 in his controller. No?

Not that I can see. Not without changes.


> Because being lower than your limit won't kick tasks out, the practical
> effect is that no forks will be allowed in the group with this setting.

Setting task limit to 0 (more properly named "new/additional task limit" 
if it works the way you say) will do only one part of the fork limiter. 
The part that prevents new tasks from spawning. But that is only 
supposed to happen after a counter has reached a target value, and no 
such counter currently exists. The task counter does not count forks. It 
could, but it currently doesn't.

Tasks only account for a subset of forks.

> So for time-based rate limiting, it is trivial to just set it to 0 after
> x seconds.

What? no no no, maybe there are uses for that too but probably even less 
common than the proposed fork counter/decrimenter. Most of unix 
explicitly avoids ever promising to perform tasks within any arbitrary 
time widows. The system is mostly asynchronous by design, and operations 
block, buffer, spool, wait, and eventually resume and succeed, by 
design, instead of failing after arbitrary time limits.
It's not that a forks-per-time-unit would never be useful, but I think 
less often, less generically. It would be a nice option for those 
unknown, unknowable, situations where someone might know that they do 
want that.

> For other uses, we can watch the task counter increase until a certain
> value, and then set the limit to 0.

What? again:

time  action  forks  tasks
0000  init    0      1
0001  fork    1      2
0002  die     1      1
0003  fork    2      2
0004  die     2      1
0005  fork    3      2
0006  die     3      1
0007  fork    4      2
0008  die     4      1
0009  fork    5      2
0010  die     5      1
0011  fork    6      2
0012  die     6      1

Tasks never exceeds 2
Forks may climb to infinite.

You can't say that cpu or ram or any other resource can solve the same 
problem because the ultimate purpose of cpu and ram and the other 
resources is to be used, to do jobs, not preserve idle cpu time. You may 
expressly want the task to consume all available cpu, ram, disk i/o, net 
i/o, etc, it depends on the job.

Likewise the time on the wall means nothing either, or at least, you 
can't say that it's useful generically. Maybe in some odd cases someone 
may know that for their job, anything over X seconds is wrong, but I 
can't say that about almost anything, since unix is an asynchronous 
system that specifically explicitly avoids making any promises about 
timing in most operations. Almost any operation may take almost any 
amount of time depending on countless other transient factors, and most 
things block, buffer, spool, wait, and eventually resume and succeed 
instead of failing after arbitrary time limits.

The task counter only covers some cases.

As for rate limiting, that's a nice additional feature and there are a 
few ways to handle that. One crude way might be a cron job that 
periodically resets a long-running tasks remaining-forks-limit. That 
would allow say X forks per minute, and allow normal ops to work, while 
blocking a runaway. But most long-running tasks on my box have no such 
intrinsic sane-max-forks, or max-forks-per-time-unit limit on my boxes. 
When all my users try to log in at once after a network blip and the box 
gets 300 new ssh connections at once from about 10 different ip's so 
it's a lot per ip even, (buildings full of end users behind one ip) I 
specifically need to accept and handle that surge to the limit of the 
hardware's ability to do it, even though normally the rate of new ssh 
connections is a tiny fraction of that. Same goes for practically every 
service.

But I think Max was more talking about discreet jobs than long-running 
tasks, where the entire start-work-exit life cycle of the job is well 
known, so you could set the known fork limit for it and under normal 
circumstances it can do it's entire normal job within that limit, and 
has no excuse for exceeding that limit, and so it's a good safety to set 
and enforce that limit, and in doing so you can prevent things you might 
not be able to prevent any other way, at least not reliably and/or 
without doing more harm than good by breaking things you don't want to 
break.

If someone gets a cgi process to start dictionary attacking the local 
box or some other box, it will fork-login-attempt-fail repeatedly and 
use up the fork budget immediately. But it wouldn't necessarily have 
touched any reasonable typical task limit or cpu or ram or network or 
disk i/o.

I think cgi is just an example and by no means a special case. It sounds 
like generically useful control to me like any of the other controls. 
Maybe only needed in relatively few situations, but not predictable or 
limited to any particular situations. Like cgroups itself or any other 
controls, it might be used anywhere for anything, and many important 
uses may only occur to people after the facility exists and is 
considered for a while, and then may even be seen as indispensable.

Am I missing something? How does the task counter provide this kind of 
boxing-in without actually counting forks along the way, distinctly from 
tasks?

-- 
bkw
_______________________________________________
Containers mailing list
Containers@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/containers

  parent reply	other threads:[~2011-11-04 16:43 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-03 16:22 [PATCH] new cgroup controller "fork" Max Kellermann
2011-11-03 16:22 ` Max Kellermann
     [not found] ` <20111103162238.27609.11515.stgit-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2011-11-03 16:43   ` Frederic Weisbecker
2011-11-03 16:43     ` Frederic Weisbecker
     [not found]     ` <20111103164302.GE8198-oHC15RC7JGTpAmv0O++HtFaTQe2KTcn/@public.gmane.org>
2011-11-03 17:16       ` Max Kellermann
2011-11-03 17:16         ` Max Kellermann
     [not found]         ` <20111103171645.GA27887-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2011-11-03 17:26           ` Glauber Costa
2011-11-03 17:26             ` Glauber Costa
     [not found]             ` <4EB2CEB2.7050800-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-03 17:48               ` Max Kellermann
2011-11-03 17:48                 ` Max Kellermann
     [not found]                 ` <20111103174809.GA28108-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2011-11-03 17:50                   ` Glauber Costa
2011-11-03 17:50                     ` Glauber Costa
     [not found]                     ` <4EB2D451.4010607-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-03 18:30                       ` Max Kellermann
2011-11-03 18:30                         ` Max Kellermann
     [not found]                         ` <20111103183018.GA28318-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2011-11-03 18:34                           ` Glauber Costa
2011-11-03 18:34                             ` Glauber Costa
2011-11-03 16:43   ` Glauber Costa
2011-11-03 16:43     ` Glauber Costa
     [not found]     ` <4EB2C4A5.6000406-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-03 16:59       ` Max Kellermann
2011-11-03 16:59         ` Max Kellermann
2011-11-03 17:05         ` Frederic Weisbecker
2011-11-03 17:05           ` Frederic Weisbecker
2011-11-03 18:21         ` Alan Cox
2011-11-03 18:21           ` Alan Cox
     [not found]           ` <20111103182101.5037c1e5-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2011-11-03 18:51             ` Max Kellermann
2011-11-03 18:51               ` Max Kellermann
2011-11-03 18:56               ` Glauber Costa
2011-11-03 18:56                 ` Glauber Costa
     [not found]                 ` <4EB2E3E6.6070401-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-03 20:08                   ` Matt Helsley
2011-11-03 20:08                     ` Matt Helsley
2011-11-03 19:03               ` Alan Cox
2011-11-03 19:03                 ` Alan Cox
     [not found]                 ` <20111103190330.02590426-qBU/x9rampVanCEyBjwyrvXRex20P6io@public.gmane.org>
2011-11-03 19:20                   ` Max Kellermann
2011-11-03 19:20                     ` Max Kellermann
2011-11-03 19:25                     ` Glauber Costa
2011-11-03 19:25                       ` Glauber Costa
     [not found]                       ` <4EB2EA93.2050206-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-03 20:13                         ` Brian K. White
2011-11-03 20:13                           ` Brian K. White
     [not found]                           ` <4EB2F5CF.5010604-goxB3+SAe6wAvxtiuMwx3w@public.gmane.org>
2011-11-03 21:54                             ` Glauber Costa
2011-11-03 21:54                               ` Glauber Costa
     [not found]                               ` <4EB30DAF.4090704-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-04  3:03                                 ` Li Zefan
2011-11-04  3:03                                   ` Li Zefan
2011-11-04 13:11                                   ` Glauber Costa
     [not found]                                     ` <4EB3E47E.2080003-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
2011-11-04 13:38                                       ` Max Kellermann
2011-11-04 16:43                                       ` Brian K. White [this message]
2011-11-04 13:38                                     ` Max Kellermann
2011-11-04 13:59                                   ` Lennart Poettering
     [not found]                                   ` <4EB3560D.7000002-BthXqXjhjHXQFUHtdCDX3A@public.gmane.org>
2011-11-04  4:37                                     ` KAMEZAWA Hiroyuki
2011-11-04  4:37                                       ` KAMEZAWA Hiroyuki
2011-11-04 13:11                                     ` Glauber Costa
2011-11-04 13:59                                     ` Lennart Poettering
2011-11-03 17:31   ` richard -rw- weinberger
2011-11-03 17:31     ` richard -rw- weinberger
  -- strict thread matches above, loose matches on Subject: below --
2011-02-17 13:31 Max Kellermann
2011-02-17 13:31 ` Max Kellermann
2011-02-17 13:50 ` KAMEZAWA Hiroyuki
     [not found]   ` <20110217225010.7f79b412.kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A@public.gmane.org>
2011-02-17 14:09     ` Max Kellermann
2011-02-17 14:09   ` Max Kellermann
     [not found] ` <20110217133152.4043.94951.stgit-Rjmu19FXx3rR8JxBgnUBv+rzNCUFrscg@public.gmane.org>
2011-02-17 13:50   ` KAMEZAWA Hiroyuki
2011-02-18  0:59   ` Paul Menage
2011-02-18  0:59 ` Paul Menage
2011-02-18  9:26   ` Max Kellermann
     [not found]   ` <AANLkTi=X7rHEy9yOngogs_OQ69FJeZeQRSwvFdgnbWxo-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-02-18  9:26     ` 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=4EB4163A.3060305@aljex.com \
    --to=brian-goxb3+sae6wavxtiumwx3w@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.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.