From owner-freebsd-questions@freebsd.org Fri Jun 8 14:18:33 2018 Return-Path: Delivered-To: freebsd-questions@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 30D27101BB97 for ; Fri, 8 Jun 2018 14:18:33 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from bs1.fjl.org.uk (bs1.fjl.org.uk [84.45.41.196]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "bs1.fjl.org.uk", Issuer "bs1.fjl.org.uk" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id B193783AF9 for ; Fri, 8 Jun 2018 14:18:32 +0000 (UTC) (envelope-from frank2@fjl.co.uk) Received: from roundcube.fjl.org.uk (localhost [127.0.0.1]) by bs1.fjl.org.uk (8.14.4/8.14.4) with ESMTP id w58EIT25095775 for ; Fri, 8 Jun 2018 15:18:29 +0100 (BST) (envelope-from frank2@fjl.co.uk) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 08 Jun 2018 15:18:29 +0100 From: Frank Leonhardt To: freebsd-questions@freebsd.org Subject: Re: Is it normal that a user can take down the whole system by using too much =?UTF-8?Q?memory=3F?= Organization: FJL Microsystems In-Reply-To: <20180604104334.cfa2f9b307e52afff34c39ec@sohara.org> References: <1527977770.2651378.1394286400.0806CC5C@webmail.messagingengine.com> <01EE7EEA-03AC-4D71-BA08-B0CEA97EE720@thehowies.com> <1527981931.2670335.1394316280.09410FC9@webmail.messagingengine.com> <20180604104334.cfa2f9b307e52afff34c39ec@sohara.org> Message-ID: <3637bd5588f69098fd342cf29c8a81b4@roundcube.fjl.org.uk> X-Sender: frank2@fjl.co.uk User-Agent: Roundcube Webmail/0.9.2 X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Jun 2018 14:18:33 -0000 On 2018-06-04 10:43, Steve O'Hara-Smith wrote: > On Sat, 02 Jun 2018 19:25:31 -0400 > Brennan Vincent wrote: > >> Thanks John for the response -- this should help me solve my practical >> needs. >> >> I'm also curious, however, to learn more from an OS design >> perspective. > > Best way to do that is look at the code. > >> Why isn't it possible for the kernel to realize it should kill >> `eatmem` >> rather than make the system unusable? > > The code in vm_pageout.c that handles out of swap conditions tries > to kill the biggest process - by that it means the one estimated to > release > the most memory. To that end it skips processes in various states - > killed, > protected, system, non-running and then picks the biggest of the > remaining > processes to kill. > > One thing that may cause the random chaos you see is that killing a > process takes time, especially if that process has swapped out pages, > if > something else calls for memory it has finished dying then the next > biggest > process will get killed even though the process responsible has already > been killed (after all it might be locked up and failing to die). You might want to look at this: http://blog.frankleonhardt.com/2011/large-swap-files-on-freebsd-die-with-mystery-killed-howto-add-lots-of-swap-space/ Regards, Frank.