From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f51.google.com (mail-wg0-f51.google.com [74.125.82.51]) by kanga.kvack.org (Postfix) with ESMTP id 7EB546B0032 for ; Tue, 27 Jan 2015 06:03:37 -0500 (EST) Received: by mail-wg0-f51.google.com with SMTP id k14so14030257wgh.10 for ; Tue, 27 Jan 2015 03:03:37 -0800 (PST) Received: from mx2.suse.de (cantor2.suse.de. [195.135.220.15]) by mx.google.com with ESMTPS id bt4si25333796wib.2.2015.01.27.03.03.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 03:03:36 -0800 (PST) Message-ID: <54C77086.7090505@suse.cz> Date: Tue, 27 Jan 2015 12:03:34 +0100 From: Vlastimil Babka MIME-Version: 1.0 Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> In-Reply-To: <54C2C89C.8080002@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: John Moser Cc: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" CC linux-mm in case somebody has a good answer but missed this in lkml traffic On 01/23/2015 11:18 PM, John Moser wrote: > Why is there no tunable to OOM at low page cache? > > I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some > other stupid program goes off the deep end and eats up my RAM, I hit > some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every > time the program tries to do something to eat more RAM, it cranks disk > hard; the disk starts thrashing, the mouse pointer stops moving, and > nothing goes on. It's like swapping like crazy, except you're reading > library files instead of paged anonymous RAM. > > If only I could tell the system to OOM kill at 512MB or 1GB or 95% > non-evictable RAM, it would recover on its own. As-is, I need to wait > or trigger the OOM killer by sysrq. > > Am I just the only person in the world who's ever had that problem? Or > is it a matter of questions fast popping up when you try to do this > *and* enable paging to disk? (In my experience, that's a matter of too > much swap space: if you have 16GB RAM and your computer dies at 15.25GB > usage, your swap space should be no larger than 750MB plus inactive > working RAM; obviously, your computer can't handle paging 750MB back and > forth. If you make it 8GB wide and you start swap thrashing at 2GB > usage, you have too much swap available). > > I guess you could try to detect excessive swap and page cache thrashing, > but that's complex; if anyone really wanted to do that, it would be done > by now. A low-barrier OOM is much simpler. > -- > 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/ > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f181.google.com (mail-pd0-f181.google.com [209.85.192.181]) by kanga.kvack.org (Postfix) with ESMTP id D450D6B0032 for ; Wed, 28 Jan 2015 01:26:20 -0500 (EST) Received: by mail-pd0-f181.google.com with SMTP id g10so23675545pdj.12 for ; Tue, 27 Jan 2015 22:26:20 -0800 (PST) Received: from mail-pa0-x234.google.com (mail-pa0-x234.google.com. [2607:f8b0:400e:c03::234]) by mx.google.com with ESMTPS id ql8si4447607pac.165.2015.01.27.22.26.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 27 Jan 2015 22:26:19 -0800 (PST) Received: by mail-pa0-f52.google.com with SMTP id kx10so23481267pab.11 for ; Tue, 27 Jan 2015 22:26:19 -0800 (PST) Date: Wed, 28 Jan 2015 15:26:10 +0900 From: Minchan Kim Subject: Re: OOM at low page cache? Message-ID: <20150128062609.GA4706@blaptop> References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54C77086.7090505@suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Vlastimil Babka Cc: John Moser , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Hello, On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: > CC linux-mm in case somebody has a good answer but missed this in lkml traffic > > On 01/23/2015 11:18 PM, John Moser wrote: > > Why is there no tunable to OOM at low page cache? AFAIR, there were several trial although there wasn't acceptable at that time. One thing I can remember is min_filelist_kbytes. FYI, http://lwn.net/Articles/412313/ > > > > I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some > > other stupid program goes off the deep end and eats up my RAM, I hit > > some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every > > time the program tries to do something to eat more RAM, it cranks disk > > hard; the disk starts thrashing, the mouse pointer stops moving, and > > nothing goes on. It's like swapping like crazy, except you're reading > > library files instead of paged anonymous RAM. > > > > If only I could tell the system to OOM kill at 512MB or 1GB or 95% > > non-evictable RAM, it would recover on its own. As-is, I need to wait > > or trigger the OOM killer by sysrq. > > > > Am I just the only person in the world who's ever had that problem? Or > > is it a matter of questions fast popping up when you try to do this > > *and* enable paging to disk? (In my experience, that's a matter of too > > much swap space: if you have 16GB RAM and your computer dies at 15.25GB > > usage, your swap space should be no larger than 750MB plus inactive > > working RAM; obviously, your computer can't handle paging 750MB back and > > forth. If you make it 8GB wide and you start swap thrashing at 2GB > > usage, you have too much swap available). > > > > I guess you could try to detect excessive swap and page cache thrashing, > > but that's complex; if anyone really wanted to do that, it would be done > > by now. A low-barrier OOM is much simpler. I'm far away from reclaim code for a long time but when I read again, I found something strange. With having swap in get_scan_count, we keep a mount of file LRU + free as above than high wmark to prevent file LRU thrashing but we don't with no swap. Why? Anyway, I believe we should fix it and we now have workingset.c so there might be more ways to be smart than old(although I am concern about that shadow shrinker blows out lots of information to be useful to detect in heavy memory pressure like page thrashing) Below could be band-aid until we find a elegant solution? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by kanga.kvack.org (Postfix) with ESMTP id 8F0A06B0032 for ; Wed, 28 Jan 2015 07:36:25 -0500 (EST) Received: by mail-we0-f179.google.com with SMTP id q59so20526987wes.10 for ; Wed, 28 Jan 2015 04:36:24 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id q7si8437002wjo.59.2015.01.28.04.36.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Jan 2015 04:36:23 -0800 (PST) Message-ID: <54C8D7B0.7030803@redhat.com> Date: Wed, 28 Jan 2015 07:36:00 -0500 From: Rik van Riel MIME-Version: 1.0 Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> In-Reply-To: <20150128062609.GA4706@blaptop> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim , Vlastimil Babka Cc: John Moser , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/28/2015 01:26 AM, Minchan Kim wrote: > Hello, > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: >> CC linux-mm in case somebody has a good answer but missed this in >> lkml traffic >> >> On 01/23/2015 11:18 PM, John Moser wrote: >>> Why is there no tunable to OOM at low page cache? > > AFAIR, there were several trial although there wasn't acceptable at > that time. One thing I can remember is min_filelist_kbytes. FYI, > http://lwn.net/Articles/412313/ The Android low memory killer does exactly what you want, and for very much the same reasons. See drivers/staging/android/lowmemorykiller.c However, in the mainline kernel I think it does make sense to apply something like the patch that Minchan cooked up with, to OOM if freeing all the page cache could not bring us back up to the high watermark, across all the memory zones. - -- All rights reversed -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUyNewAAoJEM553pKExN6DlKQH/3PprrXF7IOyjiXnO+2Qqbau wgWXO7mQWGFi+zNqSUzmWtfTCFVx6BxLi23MCQG1RqKGnQI4DehdOKMDidFwoC8D 2grKe9ELp04mEbyG0aipdxSw6FouIDFhC2FzmU7oQDZX5RKmLuxY7QPU4NTCitcR xHp6jWrvyY2CDiSpA2QSAaAAIG21BtPJvXQg3WvY/LI03N1edqZnExt5Po8CY7oe EeiO7ZtYISl/wRIoribEafZF4rMAfJ5A36kdbulqCqVtgCWEDPV0RCXimc5EtDIt bFDiv924+YMiuEFULJlEqLGqTJOtfJ+NlBIn8nVRk5P1pOGEbO05zE+XV1Vea6k= =8351 -----END PGP SIGNATURE----- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qa0-f48.google.com (mail-qa0-f48.google.com [209.85.216.48]) by kanga.kvack.org (Postfix) with ESMTP id BC20D6B006C for ; Wed, 28 Jan 2015 09:13:47 -0500 (EST) Received: by mail-qa0-f48.google.com with SMTP id v8so16211146qal.7 for ; Wed, 28 Jan 2015 06:13:47 -0800 (PST) Received: from mail-qa0-x234.google.com (mail-qa0-x234.google.com. [2607:f8b0:400d:c00::234]) by mx.google.com with ESMTPS id v7si6056551qas.110.2015.01.28.06.13.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Jan 2015 06:13:47 -0800 (PST) Received: by mail-qa0-f52.google.com with SMTP id x12so16226364qac.11 for ; Wed, 28 Jan 2015 06:13:46 -0800 (PST) Message-ID: <54C8EE99.80107@gmail.com> Date: Wed, 28 Jan 2015 09:13:45 -0500 From: John Moser MIME-Version: 1.0 Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> <54C8D7B0.7030803@redhat.com> In-Reply-To: <54C8D7B0.7030803@redhat.com> Content-Type: multipart/alternative; boundary="------------080800070009030305080906" Sender: owner-linux-mm@kvack.org List-ID: To: Rik van Riel , Minchan Kim , Vlastimil Babka Cc: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter This is a multi-part message in MIME format. --------------080800070009030305080906 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit On 01/28/2015 07:36 AM, Rik van Riel wrote: > On 01/28/2015 01:26 AM, Minchan Kim wrote: > > Hello, > > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: > >> CC linux-mm in case somebody has a good answer but missed this in > >> lkml traffic > >> > >> On 01/23/2015 11:18 PM, John Moser wrote: > >>> Why is there no tunable to OOM at low page cache? > > > AFAIR, there were several trial although there wasn't acceptable at > > that time. One thing I can remember is min_filelist_kbytes. FYI, > > http://lwn.net/Articles/412313/ > > The Android low memory killer does exactly what you want, and > for very much the same reasons. > > See drivers/staging/android/lowmemorykiller.c > Haven't seen that; it's been a long time since I bothered myself with kernel code, so I'm out-of-touch. Wow lots of good responses coming quick. > However, in the mainline kernel I think it does make sense to > apply something like the patch that Minchan cooked up with, to OOM > if freeing all the page cache could not bring us back up to the high > watermark, across all the memory zones. > > --------------080800070009030305080906 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit On 01/28/2015 07:36 AM, Rik van Riel wrote:
On 01/28/2015 01:26 AM, Minchan Kim wrote:
> Hello,

> On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote:
>> CC linux-mm in case somebody has a good answer but missed this in
>> lkml traffic
>>
>> On 01/23/2015 11:18 PM, John Moser wrote:
>>> Why is there no tunable to OOM at low page cache?

> AFAIR, there were several trial although there wasn't acceptable at
> that time. One thing I can remember is min_filelist_kbytes. FYI,
> http://lwn.net/Articles/412313/

The Android low memory killer does exactly what you want, and
for very much the same reasons.

See drivers/staging/android/lowmemorykiller.c


Haven't seen that; it's been a long time since I bothered myself with kernel code, so I'm out-of-touch.

Wow lots of good responses coming quick.
However, in the mainline kernel I think it does make sense to
apply something like the patch that Minchan cooked up with, to OOM
if freeing all the page cache could not bring us back up to the high
watermark, across all the memory zones.

>


--------------080800070009030305080906-- -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yk0-f173.google.com (mail-yk0-f173.google.com [209.85.160.173]) by kanga.kvack.org (Postfix) with ESMTP id 9C1DD6B0038 for ; Wed, 28 Jan 2015 09:15:52 -0500 (EST) Received: by mail-yk0-f173.google.com with SMTP id 142so8985725ykq.4 for ; Wed, 28 Jan 2015 06:15:52 -0800 (PST) Received: from mail-qg0-x22e.google.com (mail-qg0-x22e.google.com. [2607:f8b0:400d:c04::22e]) by mx.google.com with ESMTPS id u4si6097774qac.80.2015.01.28.06.15.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Jan 2015 06:15:52 -0800 (PST) Received: by mail-qg0-f46.google.com with SMTP id i50so16730268qgf.5 for ; Wed, 28 Jan 2015 06:15:51 -0800 (PST) Message-ID: <54C8EF16.5080701@gmail.com> Date: Wed, 28 Jan 2015 09:15:50 -0500 From: John Moser MIME-Version: 1.0 Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> In-Reply-To: <20150128062609.GA4706@blaptop> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim , Vlastimil Babka Cc: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter On 01/28/2015 01:26 AM, Minchan Kim wrote: > Hello, > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: >> CC linux-mm in case somebody has a good answer but missed this in lkml traffic >> >> On 01/23/2015 11:18 PM, John Moser wrote: >>> Why is there no tunable to OOM at low page cache? > AFAIR, there were several trial although there wasn't acceptable > at that time. One thing I can remember is min_filelist_kbytes. > FYI, http://lwn.net/Articles/412313/ > That looks more straight-forward than http://lwn.net/Articles/422291/ > I'm far away from reclaim code for a long time but when I read again, > I found something strange. > > With having swap in get_scan_count, we keep a mount of file LRU + free > as above than high wmark to prevent file LRU thrashing but we don't > with no swap. Why? > That's ... strange. That means having a token 1MB swap file changes the system's practical memory reclaim behavior dramatically? -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qa0-f45.google.com (mail-qa0-f45.google.com [209.85.216.45]) by kanga.kvack.org (Postfix) with ESMTP id 622276B0038 for ; Wed, 28 Jan 2015 09:27:15 -0500 (EST) Received: by mail-qa0-f45.google.com with SMTP id n8so16312212qaq.4 for ; Wed, 28 Jan 2015 06:27:15 -0800 (PST) Received: from mail-qg0-x230.google.com (mail-qg0-x230.google.com. [2607:f8b0:400d:c04::230]) by mx.google.com with ESMTPS id o9si6182607qaa.43.2015.01.28.06.27.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Jan 2015 06:27:14 -0800 (PST) Received: by mail-qg0-f48.google.com with SMTP id z60so16789812qgd.7 for ; Wed, 28 Jan 2015 06:27:14 -0800 (PST) Message-ID: <54C8F1C1.7050908@gmail.com> Date: Wed, 28 Jan 2015 09:27:13 -0500 From: John Moser MIME-Version: 1.0 Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> In-Reply-To: <20150128062609.GA4706@blaptop> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org List-ID: To: Minchan Kim , Vlastimil Babka Cc: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter On 01/28/2015 01:26 AM, Minchan Kim wrote: > > Below could be band-aid until we find a elegant solution? > > I don't know about elegant; but I'd be impressed if anyone figured out how to just go Windows 95 with it and build a Task Master interface. It would be useful to have a kernel interface that allows a service to attach, delegate an interface program, etc., and then pull it up under certain conditions (low memory, heavy scheduling due to lots of fork()ing, etc.) and assign temporary high priority. Basically, nearly-pause the system and allow the user to select and kill/term processes, or bring a process forward (for like 10 seconds, then kick it back again) so the user can save their work and exit gracefully. At hard OOM, you could either OOM or pause everything (you'd need a zero-allocation path to kill things in a user-end OOM handler). Yeah, imaginative fantasies. Totally doable, but probably too complex to bother. There's all kinds of semaphore inversion or some such to worry about; how do you ensure an X11 program is 100% snappy when the system is being thrashed by fork() bombs and memory pressure? Actually, I have no idea what I'm talking about. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by kanga.kvack.org (Postfix) with ESMTP id 2D8B16B006E for ; Wed, 28 Jan 2015 20:24:19 -0500 (EST) Received: by mail-pa0-f53.google.com with SMTP id kx10so32100066pab.12 for ; Wed, 28 Jan 2015 17:24:18 -0800 (PST) Received: from mail-pa0-x22b.google.com (mail-pa0-x22b.google.com. [2607:f8b0:400e:c03::22b]) by mx.google.com with ESMTPS id hc9si7726471pbc.228.2015.01.28.17.24.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Jan 2015 17:24:18 -0800 (PST) Received: by mail-pa0-f43.google.com with SMTP id eu11so32158997pac.2 for ; Wed, 28 Jan 2015 17:24:18 -0800 (PST) Date: Thu, 29 Jan 2015 10:24:07 +0900 From: Minchan Kim Subject: Re: OOM at low page cache? Message-ID: <20150129012356.GA9672@blaptop> References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> <54C8EF16.5080701@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54C8EF16.5080701@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: John Moser Cc: Vlastimil Babka , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Hello, On Wed, Jan 28, 2015 at 09:15:50AM -0500, John Moser wrote: > On 01/28/2015 01:26 AM, Minchan Kim wrote: > > Hello, > > > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: > >> CC linux-mm in case somebody has a good answer but missed this in lkml traffic > >> > >> On 01/23/2015 11:18 PM, John Moser wrote: > >>> Why is there no tunable to OOM at low page cache? > > AFAIR, there were several trial although there wasn't acceptable > > at that time. One thing I can remember is min_filelist_kbytes. > > FYI, http://lwn.net/Articles/412313/ > > > > That looks more straight-forward than http://lwn.net/Articles/422291/ > > > > I'm far away from reclaim code for a long time but when I read again, > > I found something strange. > > > > With having swap in get_scan_count, we keep a mount of file LRU + free > > as above than high wmark to prevent file LRU thrashing but we don't > > with no swap. Why? > > > > That's ... strange. That means having a token 1MB swap file changes the > system's practical memory reclaim behavior dramatically? Basically, yes but 1M is too small. If all of swap consumed, the behavior will be same so I think we need more explicit logic to prevent cache thrashing. Could you test below patch? Thanks. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751777AbbAWWSJ (ORCPT ); Fri, 23 Jan 2015 17:18:09 -0500 Received: from mail-qa0-f53.google.com ([209.85.216.53]:49500 "EHLO mail-qa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750917AbbAWWSG (ORCPT ); Fri, 23 Jan 2015 17:18:06 -0500 Message-ID: <54C2C89C.8080002@gmail.com> Date: Fri, 23 Jan 2015 17:18:04 -0500 From: John Moser User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: linux-kernel@vger.kernel.org Subject: OOM at low page cache? Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Why is there no tunable to OOM at low page cache? I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some other stupid program goes off the deep end and eats up my RAM, I hit some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every time the program tries to do something to eat more RAM, it cranks disk hard; the disk starts thrashing, the mouse pointer stops moving, and nothing goes on. It's like swapping like crazy, except you're reading library files instead of paged anonymous RAM. If only I could tell the system to OOM kill at 512MB or 1GB or 95% non-evictable RAM, it would recover on its own. As-is, I need to wait or trigger the OOM killer by sysrq. Am I just the only person in the world who's ever had that problem? Or is it a matter of questions fast popping up when you try to do this *and* enable paging to disk? (In my experience, that's a matter of too much swap space: if you have 16GB RAM and your computer dies at 15.25GB usage, your swap space should be no larger than 750MB plus inactive working RAM; obviously, your computer can't handle paging 750MB back and forth. If you make it 8GB wide and you start swap thrashing at 2GB usage, you have too much swap available). I guess you could try to detect excessive swap and page cache thrashing, but that's complex; if anyone really wanted to do that, it would be done by now. A low-barrier OOM is much simpler. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758130AbbA0LDj (ORCPT ); Tue, 27 Jan 2015 06:03:39 -0500 Received: from cantor2.suse.de ([195.135.220.15]:45213 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757933AbbA0LDg (ORCPT ); Tue, 27 Jan 2015 06:03:36 -0500 Message-ID: <54C77086.7090505@suse.cz> Date: Tue, 27 Jan 2015 12:03:34 +0100 From: Vlastimil Babka User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: John Moser CC: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> In-Reply-To: <54C2C89C.8080002@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org CC linux-mm in case somebody has a good answer but missed this in lkml traffic On 01/23/2015 11:18 PM, John Moser wrote: > Why is there no tunable to OOM at low page cache? > > I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some > other stupid program goes off the deep end and eats up my RAM, I hit > some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every > time the program tries to do something to eat more RAM, it cranks disk > hard; the disk starts thrashing, the mouse pointer stops moving, and > nothing goes on. It's like swapping like crazy, except you're reading > library files instead of paged anonymous RAM. > > If only I could tell the system to OOM kill at 512MB or 1GB or 95% > non-evictable RAM, it would recover on its own. As-is, I need to wait > or trigger the OOM killer by sysrq. > > Am I just the only person in the world who's ever had that problem? Or > is it a matter of questions fast popping up when you try to do this > *and* enable paging to disk? (In my experience, that's a matter of too > much swap space: if you have 16GB RAM and your computer dies at 15.25GB > usage, your swap space should be no larger than 750MB plus inactive > working RAM; obviously, your computer can't handle paging 750MB back and > forth. If you make it 8GB wide and you start swap thrashing at 2GB > usage, you have too much swap available). > > I guess you could try to detect excessive swap and page cache thrashing, > but that's complex; if anyone really wanted to do that, it would be done > by now. A low-barrier OOM is much simpler. > -- > 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/ > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760893AbbA1G0V (ORCPT ); Wed, 28 Jan 2015 01:26:21 -0500 Received: from mail-pd0-f174.google.com ([209.85.192.174]:36697 "EHLO mail-pd0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751464AbbA1G0U (ORCPT ); Wed, 28 Jan 2015 01:26:20 -0500 Date: Wed, 28 Jan 2015 15:26:10 +0900 From: Minchan Kim To: Vlastimil Babka Cc: John Moser , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Subject: Re: OOM at low page cache? Message-ID: <20150128062609.GA4706@blaptop> References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54C77086.7090505@suse.cz> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: > CC linux-mm in case somebody has a good answer but missed this in lkml traffic > > On 01/23/2015 11:18 PM, John Moser wrote: > > Why is there no tunable to OOM at low page cache? AFAIR, there were several trial although there wasn't acceptable at that time. One thing I can remember is min_filelist_kbytes. FYI, http://lwn.net/Articles/412313/ > > > > I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some > > other stupid program goes off the deep end and eats up my RAM, I hit > > some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every > > time the program tries to do something to eat more RAM, it cranks disk > > hard; the disk starts thrashing, the mouse pointer stops moving, and > > nothing goes on. It's like swapping like crazy, except you're reading > > library files instead of paged anonymous RAM. > > > > If only I could tell the system to OOM kill at 512MB or 1GB or 95% > > non-evictable RAM, it would recover on its own. As-is, I need to wait > > or trigger the OOM killer by sysrq. > > > > Am I just the only person in the world who's ever had that problem? Or > > is it a matter of questions fast popping up when you try to do this > > *and* enable paging to disk? (In my experience, that's a matter of too > > much swap space: if you have 16GB RAM and your computer dies at 15.25GB > > usage, your swap space should be no larger than 750MB plus inactive > > working RAM; obviously, your computer can't handle paging 750MB back and > > forth. If you make it 8GB wide and you start swap thrashing at 2GB > > usage, you have too much swap available). > > > > I guess you could try to detect excessive swap and page cache thrashing, > > but that's complex; if anyone really wanted to do that, it would be done > > by now. A low-barrier OOM is much simpler. I'm far away from reclaim code for a long time but when I read again, I found something strange. With having swap in get_scan_count, we keep a mount of file LRU + free as above than high wmark to prevent file LRU thrashing but we don't with no swap. Why? Anyway, I believe we should fix it and we now have workingset.c so there might be more ways to be smart than old(although I am concern about that shadow shrinker blows out lots of information to be useful to detect in heavy memory pressure like page thrashing) Below could be band-aid until we find a elegant solution? >>From c51787f7d75340b54bab2b5e3c587f4a483da51a Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Wed, 28 Jan 2015 14:01:57 +0900 Subject: [PATCH] mm: prevent page thrashing No-Signed-off-by: Minchan Kim --- mm/vmscan.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/mm/vmscan.c b/mm/vmscan.c index 671e47edb584..b258df552e3a 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -2143,6 +2143,25 @@ out: denominator); break; case SCAN_FILE: + if (file && global_reclaim(sc)) { + unsigned long zonefile; + unsigned long zonefree; + + zonefree = zone_page_state(zone, + NR_FREE_PAGES); + zonefile = zone_page_state(zone, + NR_ACTIVE_FILE) + + zone_page_state(zone, + NR_INACTIVE_FILE); + + /* OOM is better than code thrashing */ + if (zonefile + zonefree <= + high_wmark_pages(zone)) { + size = 0; + scan = 0; + } + break; + } case SCAN_ANON: /* Scan one type exclusively */ if ((scan_balance == SCAN_FILE) != file) { -- 1.9.1 -- Kind regards, Minchan Kim From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932082AbbA1U7H (ORCPT ); Wed, 28 Jan 2015 15:59:07 -0500 Received: from mx1.redhat.com ([209.132.183.28]:53892 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756038AbbA1U7F (ORCPT ); Wed, 28 Jan 2015 15:59:05 -0500 Message-ID: <54C8D7B0.7030803@redhat.com> Date: Wed, 28 Jan 2015 07:36:00 -0500 From: Rik van Riel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Minchan Kim , Vlastimil Babka CC: John Moser , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> In-Reply-To: <20150128062609.GA4706@blaptop> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 01/28/2015 01:26 AM, Minchan Kim wrote: > Hello, > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: >> CC linux-mm in case somebody has a good answer but missed this in >> lkml traffic >> >> On 01/23/2015 11:18 PM, John Moser wrote: >>> Why is there no tunable to OOM at low page cache? > > AFAIR, there were several trial although there wasn't acceptable at > that time. One thing I can remember is min_filelist_kbytes. FYI, > http://lwn.net/Articles/412313/ The Android low memory killer does exactly what you want, and for very much the same reasons. See drivers/staging/android/lowmemorykiller.c However, in the mainline kernel I think it does make sense to apply something like the patch that Minchan cooked up with, to OOM if freeing all the page cache could not bring us back up to the high watermark, across all the memory zones. - -- All rights reversed -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUyNewAAoJEM553pKExN6DlKQH/3PprrXF7IOyjiXnO+2Qqbau wgWXO7mQWGFi+zNqSUzmWtfTCFVx6BxLi23MCQG1RqKGnQI4DehdOKMDidFwoC8D 2grKe9ELp04mEbyG0aipdxSw6FouIDFhC2FzmU7oQDZX5RKmLuxY7QPU4NTCitcR xHp6jWrvyY2CDiSpA2QSAaAAIG21BtPJvXQg3WvY/LI03N1edqZnExt5Po8CY7oe EeiO7ZtYISl/wRIoribEafZF4rMAfJ5A36kdbulqCqVtgCWEDPV0RCXimc5EtDIt bFDiv924+YMiuEFULJlEqLGqTJOtfJ+NlBIn8nVRk5P1pOGEbO05zE+XV1Vea6k= =8351 -----END PGP SIGNATURE----- From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756889AbbA2BmH (ORCPT ); Wed, 28 Jan 2015 20:42:07 -0500 Received: from mail-qg0-f51.google.com ([209.85.192.51]:41609 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751753AbbA2BmD (ORCPT ); Wed, 28 Jan 2015 20:42:03 -0500 Message-ID: <54C8EF16.5080701@gmail.com> Date: Wed, 28 Jan 2015 09:15:50 -0500 From: John Moser User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Minchan Kim , Vlastimil Babka CC: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> In-Reply-To: <20150128062609.GA4706@blaptop> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/28/2015 01:26 AM, Minchan Kim wrote: > Hello, > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: >> CC linux-mm in case somebody has a good answer but missed this in lkml traffic >> >> On 01/23/2015 11:18 PM, John Moser wrote: >>> Why is there no tunable to OOM at low page cache? > AFAIR, there were several trial although there wasn't acceptable > at that time. One thing I can remember is min_filelist_kbytes. > FYI, http://lwn.net/Articles/412313/ > That looks more straight-forward than http://lwn.net/Articles/422291/ > I'm far away from reclaim code for a long time but when I read again, > I found something strange. > > With having swap in get_scan_count, we keep a mount of file LRU + free > as above than high wmark to prevent file LRU thrashing but we don't > with no swap. Why? > That's ... strange. That means having a token 1MB swap file changes the system's practical memory reclaim behavior dramatically? From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760821AbbA2CDh (ORCPT ); Wed, 28 Jan 2015 21:03:37 -0500 Received: from mail-qg0-f51.google.com ([209.85.192.51]:60055 "EHLO mail-qg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752177AbbA2CDe (ORCPT ); Wed, 28 Jan 2015 21:03:34 -0500 Message-ID: <54C8F1C1.7050908@gmail.com> Date: Wed, 28 Jan 2015 09:27:13 -0500 From: John Moser User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Minchan Kim , Vlastimil Babka CC: linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Subject: Re: OOM at low page cache? References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> In-Reply-To: <20150128062609.GA4706@blaptop> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/28/2015 01:26 AM, Minchan Kim wrote: > > Below could be band-aid until we find a elegant solution? > > I don't know about elegant; but I'd be impressed if anyone figured out how to just go Windows 95 with it and build a Task Master interface. It would be useful to have a kernel interface that allows a service to attach, delegate an interface program, etc., and then pull it up under certain conditions (low memory, heavy scheduling due to lots of fork()ing, etc.) and assign temporary high priority. Basically, nearly-pause the system and allow the user to select and kill/term processes, or bring a process forward (for like 10 seconds, then kick it back again) so the user can save their work and exit gracefully. At hard OOM, you could either OOM or pause everything (you'd need a zero-allocation path to kill things in a user-end OOM handler). Yeah, imaginative fantasies. Totally doable, but probably too complex to bother. There's all kinds of semaphore inversion or some such to worry about; how do you ensure an X11 program is 100% snappy when the system is being thrashed by fork() bombs and memory pressure? Actually, I have no idea what I'm talking about. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754664AbbA2BYV (ORCPT ); Wed, 28 Jan 2015 20:24:21 -0500 Received: from mail-pa0-f50.google.com ([209.85.220.50]:36305 "EHLO mail-pa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751528AbbA2BYS (ORCPT ); Wed, 28 Jan 2015 20:24:18 -0500 Date: Thu, 29 Jan 2015 10:24:07 +0900 From: Minchan Kim To: John Moser Cc: Vlastimil Babka , linux-kernel@vger.kernel.org, "linux-mm@kvack.org" , Rik van Riel , Johannes Weiner , KOSAKI Motohiro , Kamezawa Hiroyuki , Christoph Lameter Subject: Re: OOM at low page cache? Message-ID: <20150129012356.GA9672@blaptop> References: <54C2C89C.8080002@gmail.com> <54C77086.7090505@suse.cz> <20150128062609.GA4706@blaptop> <54C8EF16.5080701@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <54C8EF16.5080701@gmail.com> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Jan 28, 2015 at 09:15:50AM -0500, John Moser wrote: > On 01/28/2015 01:26 AM, Minchan Kim wrote: > > Hello, > > > > On Tue, Jan 27, 2015 at 12:03:34PM +0100, Vlastimil Babka wrote: > >> CC linux-mm in case somebody has a good answer but missed this in lkml traffic > >> > >> On 01/23/2015 11:18 PM, John Moser wrote: > >>> Why is there no tunable to OOM at low page cache? > > AFAIR, there were several trial although there wasn't acceptable > > at that time. One thing I can remember is min_filelist_kbytes. > > FYI, http://lwn.net/Articles/412313/ > > > > That looks more straight-forward than http://lwn.net/Articles/422291/ > > > > I'm far away from reclaim code for a long time but when I read again, > > I found something strange. > > > > With having swap in get_scan_count, we keep a mount of file LRU + free > > as above than high wmark to prevent file LRU thrashing but we don't > > with no swap. Why? > > > > That's ... strange. That means having a token 1MB swap file changes the > system's practical memory reclaim behavior dramatically? Basically, yes but 1M is too small. If all of swap consumed, the behavior will be same so I think we need more explicit logic to prevent cache thrashing. Could you test below patch? Thanks. >>From d7659ff20f065b89633037652042968ba9c9f5c2 Mon Sep 17 00:00:00 2001 From: Minchan Kim Date: Wed, 28 Jan 2015 14:01:57 +0900 Subject: [PATCH] mm: prevent page thrashing for non-swap Josh reported "I have no swap configured. I have 16GB RAM. If Chrome or Gimp or some other stupid program goes off the deep end and eats up my RAM, I hit some 15.5GB or 15.75GB usage and stay there for about 40 minutes. Every time the program tries to do something to eat more RAM, it cranks disk hard; the disk starts thrashing, the mouse pointer stops moving, and nothing goes on. It's like swapping like crazy, except you're reading library files instead of paged anonymous RAM." With swap enable, get_scan_count has a logic to prevent cache thrasing but it doesn't with no swap case. This patch adds the check for non-swap case so that we shouldn't drop all of page cache in non-swap case, either to prevent cache thrashing. Reported-by: John Moser Signed-off-by: Minchan Kim --- mm/vmscan.c | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 671e47edb584..2a2236fceaee 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -1957,6 +1957,22 @@ enum scan_balance { SCAN_FILE, }; +bool enough_file_pages(struct zone *zone) +{ + bool ret = true; + unsigned long zonefile; + unsigned long zonefree; + + zonefree = zone_page_state(zone, NR_FREE_PAGES); + zonefile = zone_page_state(zone, NR_ACTIVE_FILE) + + zone_page_state(zone, NR_INACTIVE_FILE); + + if (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) + ret = false; + + return ret; +} + /* * Determine how aggressively the anon and file LRU lists should be * scanned. The relative value of each set of LRU lists is determined @@ -2039,18 +2055,9 @@ static void get_scan_count(struct lruvec *lruvec, int swappiness, * thrashing file LRU becomes infinitely more attractive than * anon pages. Try to detect this based on file LRU size. */ - if (global_reclaim(sc)) { - unsigned long zonefile; - unsigned long zonefree; - - zonefree = zone_page_state(zone, NR_FREE_PAGES); - zonefile = zone_page_state(zone, NR_ACTIVE_FILE) + - zone_page_state(zone, NR_INACTIVE_FILE); - - if (unlikely(zonefile + zonefree <= high_wmark_pages(zone))) { - scan_balance = SCAN_ANON; - goto out; - } + if (global_reclaim(sc) && !enough_file_pages(zone)) { + scan_balance = SCAN_ANON; + goto out; } /* @@ -2143,6 +2150,17 @@ out: denominator); break; case SCAN_FILE: + /* + * If there isn't enough page cache to prevent + * cache thrashing, OOM is better than long time + * unresponsible system. + */ + if (global_reclaim(sc) && file && + !enough_file_pages(zone)) { + size = 0; + scan = 0; + break; + } case SCAN_ANON: /* Scan one type exclusively */ if ((scan_balance == SCAN_FILE) != file) { -- 1.9.1 -- Kind regards, Minchan Kim