Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754835AbbB0SuP (ORCPT ); Fri, 27 Feb 2015 13:50:15 -0500 Received: from mail-ie0-f175.google.com ([209.85.223.175]:38827 "EHLO mail-ie0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752839AbbB0SuM (ORCPT ); Fri, 27 Feb 2015 13:50:12 -0500 Message-ID: <54F0BC51.4050506@gmail.com> Date: Fri, 27 Feb 2015 13:49:53 -0500 From: Austin S Hemmelgarn User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Tejun Heo CC: Aleksa Sarai , lizefan@huawei.com, mingo@redhat.com, peterz@infradead.org, richard@nod.at, fweisbec@gmail.com, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org Subject: Re: [PATCH RFC 0/2] add nproc cgroup subsystem References: <1424660891-12719-1-git-send-email-cyphar@cyphar.com> <20150227114940.GB3964@htj.duckdns.org> <54F09E62.8000007@gmail.com> <20150227170640.GK3964@htj.duckdns.org> In-Reply-To: <20150227170640.GK3964@htj.duckdns.org> x-hashcash: 1:21:150227:tj@kernel.org::968d07ece34e9365a549abff47d99ad1:28d7d620dea3c766 x-hashcash: 1:21:150227:cyphar@cyphar.com::27cd44b62bbefb5782921b926634a44e:5a5c4bc1f35e806 x-hashcash: 1:21:150227:lizefan@huawei.com::9011ca6f9c355b2d13179d0c03ccc211:df3a6104e94009d3 x-hashcash: 1:21:150227:mingo@redhat.com::56b76489fa67e2d787a0bc3e981bf42a:83355d01408e541f x-hashcash: 1:21:150227:peterz@infradead.org::37e59662c9cee432719948d4d71ec099:36148e679be3b89 x-hashcash: 1:21:150227:richard@nod.at::dba56e4dc4142cbefe61c1b2a6a0b069:6e90d44a47040a9d x-hashcash: 1:21:150227:fweisbec@gmail.com::3081dcd554ba5174b5b70f8498583384:d50e193cf76212f5 x-hashcash: 1:21:150227:linux-kernel@vger.kernel.org::99243ac962d821b0ca4bfcd0129024f8:34f682938341f620 x-hashcash: 1:21:150227:cgroups@vger.kernel.org::ea566a95557b1b7adf400e7daff9763a:677a91e34b8ba42a x-stampprotocols: hashcash:1:17;mbound:0:10:3000:5000 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3357 Lines: 61 On 2015-02-27 12:06, Tejun Heo wrote: > Hello, > > On Fri, Feb 27, 2015 at 11:42:10AM -0500, Austin S Hemmelgarn wrote: >> Kernel memory consumption isn't the only valid reason to want to limit the >> number of processes in a cgroup. Limiting the number of processes is very >> useful to ensure that a program is working correctly (for example, the NTP >> daemon should (usually) have an _exact_ number of children if it is >> functioning correctly, and rpcbind shouldn't (AFAIK) ever have _any_ >> children), to prevent PID number exhaustion, to head off DoS attacks against >> forking network servers before they get to the point of causing kmem >> exhaustion, and to limit the number of processes in a cgroup that uses lots >> of kernel memory very infrequently. > > All the use cases you're listing are extremely niche and can be > trivially achieved without introducing another cgroup controller. Not > only that, they're actually pretty silly. Let's say NTP daemon is > misbehaving (or its code changed w/o you knowing or there are corner > cases which trigger extremely infrequently). What do you exactly > achieve by rejecting its fork call? It's just adding another > variation to the misbehavior. It was misbehaving before and would now > be continuing to misbehave after a failed fork. > I wouldn't think that preventing PID exhaustion would be all that much of a niche case, it's fully possible for it to happen without using excessive amounts of kernel memory (think about BIG server systems with terabytes of memory running (arguably poorly written) forking servers that handle tens of thousands of client requests per second, each lasting multiple tens of seconds), and not necessarily as trivial as you might think to handle sanely (especially if you want callbacks when the limits get hit). As far as being trivial to achieve, I'm assuming you are referring to rlimit and PAM's limits module, both of which have their own issues. Using pam_limits.so to limit processes isn't trivial because it requires calling through PAM to begin with, which almost no software that isn't login related does, and rlimits are tricky to set up properly with the granularity that having a cgroup would provide. > In general, I'm pretty strongly against adding controllers for things > which aren't fundamental resources in the system. What's next? Open > files? Pipe buffer? Number of flocks? Number of session leaders or > program groups? > PID's are a fundamental resource, you run out and it's an only marginally better situation than OOM, namely, if you don't already have a shell open which has kill builtin (because you can't fork), or have some other reliable way to terminate processes without forking, you are stuck either waiting for the problem to resolve itself, or have to reset the system. > If you want to prevent a certain class of jobs from exhausting a given > resource, protecting that resource is the obvious thing to do. > Which is why I'm advocating something that provides a more robust method of preventing the system from exhausting PID numbers. > Thanks. > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/