Commit 89de8cb6 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] Fix PF_MEMDIE

Patch from Hugh Dickins and Robert Love.

Fixes up the PF_MEMDIE handling so that it actually works.

(PF_MEMDIE allows an oom-killed task to use the emergency memory
reserves so that it can actually get out of the page allocator and
die)
parent 51fef6b3
......@@ -443,7 +443,6 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
unsigned long min;
struct zone **zones, *classzone;
struct page *page;
int cflags;
int i;
int cold;
......@@ -514,10 +513,9 @@ __alloc_pages(unsigned int gfp_mask, unsigned int order,
goto nopage;
inc_page_state(allocstall);
cflags = current->flags;
current->flags |= PF_MEMALLOC;
try_to_free_pages(classzone, gfp_mask, order);
current->flags = cflags;
current->flags &= ~PF_MEMALLOC;
/* go through the zonelist yet one more time */
min = 1UL << order;
......
......@@ -120,6 +120,7 @@ int add_to_swap(struct page * page)
{
swp_entry_t entry;
int pf_flags;
int err;
if (!PageLocked(page))
BUG();
......@@ -149,9 +150,15 @@ int add_to_swap(struct page * page)
/*
* Add it to the swap cache and mark it dirty
*/
switch (add_to_page_cache(page, &swapper_space, entry.val)) {
err = add_to_page_cache(page, &swapper_space, entry.val);
if (!(pf_flags & PF_NOWARN))
current->flags &= ~PF_NOWARN;
if (pf_flags & PF_MEMALLOC)
current->flags |= PF_MEMALLOC;
switch (err) {
case 0: /* Success */
current->flags = pf_flags;
SetPageUptodate(page);
ClearPageDirty(page);
set_page_dirty(page);
......@@ -159,13 +166,11 @@ int add_to_swap(struct page * page)
return 1;
case -EEXIST:
/* Raced with "speculative" read_swap_cache_async */
current->flags = pf_flags;
INC_CACHE_INFO(exist_race);
swap_free(entry);
continue;
default:
/* -ENOMEM radix-tree allocation failure */
current->flags = pf_flags;
swap_free(entry);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment