From: Dave Peterson <dsp@llnl.gov>
To: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org, pj@sgi.com,
ak@suse.de, linux-mm@kvack.org, garlick@llnl.gov,
mgrondona@llnl.gov
Subject: Re: [PATCH (try #3)] mm: avoid unnecessary OOM kills
Date: Wed, 24 May 2006 08:05:39 -0700 [thread overview]
Message-ID: <7.0.0.16.2.20060524073251.0237c250@llnl.gov> (raw)
In-Reply-To: <44739E2D.60406@yahoo.com.au>
At 04:43 PM 5/23/2006, Nick Piggin wrote:
>>That would be another way to do things. It's a tradeoff between either
>> option A: Each task that enters the OOM code path must loop over all
>> tasks to determine whether an OOM kill is in progress.
>> or...
>> option B: We must declare an oom_kill_in_progress variable and add
>> the following snippet of code to mmput():
>> put_swap_token(mm);
>>+ if (unlikely(test_bit(MM_FLAG_OOM_NOTIFY, &mm->flags)))
>>+ oom_kill_finish(); /* terminate pending OOM kill */
>> mmdrop(mm);
>>I think either option is reasonable (although I have a slight preference
>>for B since it eliminates substantial looping through the tasklist).
>
>Don't you have to loop through the tasklist anyway? To find a task
>to kill?
>
>Either way, at the point of OOM, usually they should have gone through
>the LRU lists several times, so a little bit more CPU time shouldn't
>hurt.
ok, I'll change the patch to use option A.
>>>Is all this really required? Shouldn't you just have in place the
>>>mechanism to prevent concurrent OOM killings in the OOM code, and
>>>so the page allocator doesn't have to bother with it at all (ie.
>>>it can just call into the OOM killer, which may or may not actually
>>>kill anything).
>>
>>I agree it's desirable to keep the OOM killing logic as encapsulated
>>as possible. However unless you are holding the oom kill semaphore
>>when you make your final attempt to allocate memory it's a bit racy.
>>Holding the OOM kill semaphore guarantees that our final allocation
>>failure before invoking the OOM killer occurred _after_ any previous
>>OOM kill victim freed its memory. Thus we know we are not shooting
>>another process prematurely (i.e. before the memory-freeing effects
>>of our previous OOM kill have been felt).
>
>But there is so much fudge in it that I don't think it matters:
>pages could be freed from other sources, some reclaim might happen,
>the point at which OOM is declared is pretty arbitrary anyway, etc.
There's definitely some fudge in it. However the main scenario I'm
concerned with is where one big process is hogging most of the memory
(as opposed to a case where the collective memory-hogging effect of
lots of little processes triggers the OOM killer). In the first case
we want to shoot the one big process and leave the little processes
undisturbed.
If the final allocation failure before invoking the OOM killer
occurs when we don't yet hold the OOM kill semaphore then I'd
be concerned about processes queueing up on the OOM kill semaphore
after they fail their memory allocations. If only one of these
ends up getting awakened _after_ the death of the big memory hog,
then that process will enter the OOM killer and shoot a little
process unnecessarily.
Alternately (perhaps less likely), if your kernel is preemptible,
after the memory hog has been shot but not yet expired a process
may get preempted between its final allocation failure and its
choosing an OOM kill victim (with the memory hog expiring before
the preempted process gets rescheduled). Then the preempted
process shoots a little process when rescheduled.
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2006-05-24 15:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-05-23 0:32 Dave Peterson
2006-05-23 5:39 ` Nick Piggin
2006-05-23 18:04 ` Dave Peterson
2006-05-23 23:43 ` Nick Piggin
2006-05-24 15:05 ` Dave Peterson [this message]
2006-05-29 6:12 ` Nick Piggin
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=7.0.0.16.2.20060524073251.0237c250@llnl.gov \
--to=dsp@llnl.gov \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=garlick@llnl.gov \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgrondona@llnl.gov \
--cc=nickpiggin@yahoo.com.au \
--cc=pj@sgi.com \
/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