public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Arcangeli <andrea@suse.de>
To: Andrew Morton <akpm@zip.com.au>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: Re: the oom killer
Date: Fri, 5 Apr 2002 16:43:48 +0200	[thread overview]
Message-ID: <20020405164348.K32431@dualathlon.random> (raw)
In-Reply-To: <3CAD6BE2.40ADC2B4@zip.com.au>

On Fri, Apr 05, 2002 at 01:18:26AM -0800, Andrew Morton wrote:
> 
> Andrea,
> 
> Marcelo would prefer that the VM retain the oom killer.  The thinking
> is that if try_to_free_pages fails, then we're better off making a
> deliberate selection of the process to kill rather than the random(ish)
> selection which we make by failing the allocation.
> 
> One example is at
> 
> http://marc.theaimsgroup.com/?l=linux-kernel&m=101405688319160&w=2
> 
> That failure was with vm-24, which I think had the less aggressive

vm-24 had a problem yes, that is fixed in the latest releases.

> i/dcache shrink code.  We do need to robustly handle the no-swap-left
> situation.
> 
> So I have resurrected the oom killer.  The patch is below.
> 
> During testing of this, a problem cropped up.  The machine has 64 megs
> of memory, no swap.  The workload consisted of running `make -j0
> bzImage' in parallel with `usemem 40'.  usemem will malloc a 40
> megabyte chunk, memset it and exit.
> 
> The kernel livelocked.  What appeared to be happening was that ZONE_DMA
> was short on free pages, but ZONE_NORMAL was not.  So this check:
> 
> 	if (!check_classzone_need_balance(classzone))
>         	break;
> 
> in try_to_free_pages() was seeing that ZONE_NORMAL had some headroom
> and was causing a return to __alloc_pages().
> 
> __alloc_pages has this logic:
> 
> 	min = 1UL << order;
> 	for (;;) {
> 		zone_t *z = *(zone++);
> 		if (!z)
> 			break;
> 
> 		min += z->pages_min;
> 		if (z->free_pages > min) {
> 			page = rmqueue(z, order);
> 			if (page)
> 				return page;
> 		}
> 	}
> 
> 
> On the first pass through this loop, `min' gets the value
> zone_dma.pages_min + 1.  On the second pass through the loop it gets
> the value zone_dma.pages_min + 1 + zone_normal.pages_min.  And this is
> greater than zone_normal.free_pages! So alloc_pages() gets stuck in an
> infinite loop.

This is a bug I fixed in the -rest patch, that's also broken on numa.
The deadlock cannot happen if you apply all my patches.

As for your patch it reintroduces a deadlock by looping in GFP relying
on the oom killer (that will also go and kill the
bigger task most of the time), the oom killer can select a task in D
state, or it can a sigterm, and secondly you broke google DB (the right
fix for that min thing are the point-of-view watermarks in the -rest
patch in my collection). the worst thing is that with the oom killer
we've to keep looping, so if the task is for whatever reason hung in R
state in kernel the machine will deadlock, while current way it will
make progress either in the do_exit, or in the -ENOMEM fail path (modulo
getblk that's not too bad anyways). the current memory balancing is now
been good enough to kill in function of probability, so I didn't feel
the need of risking (at the very least theorical) deadlocks there, this
is why I left it disabled.

Andrea

  reply	other threads:[~2002-04-05 14:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-05  9:18 the oom killer Andrew Morton
2002-04-05 14:43 ` Andrea Arcangeli [this message]
2002-04-05 21:45   ` Marcelo Tosatti
2002-04-11 13:13     ` Andrea Arcangeli
2002-04-11 19:41       ` Andrew Morton
2002-04-11 21:15         ` Christoph Hellwig

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=20020405164348.K32431@dualathlon.random \
    --to=andrea@suse.de \
    --cc=akpm@zip.com.au \
    --cc=linux-kernel@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox