From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Tue, 18 Sep 2007 13:47:21 -0700 (PDT) From: David Rientjes Subject: [patch 6/4] oom: pass null to kfree if zonelist is not cleared In-Reply-To: Message-ID: References: <871b7a4fd566de081120.1187786931@v2.random> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org Return-Path: To: Andrew Morton Cc: Andrea Arcangeli , Christoph Lameter , linux-mm@kvack.org List-ID: On Tue, 18 Sep 2007, Christoph Lameter wrote: > > I thought about doing that as well as statically allocating > > > > #define MAX_OOM_THREADS 4 > > static struct zonelist *zonelists[MAX_OOM_THREADS]; > > > > and using semaphores. But in my testing of this patchset and experience > > in working with the watermarks used in __alloc_pages(), we should never > > actually encounter a condition where we can't find > > sizeof(struct oom_zonelist) of memory. That's on the order of how many > > invocations of the OOM killer you have, but I don't actually think you'll > > have many that have a completely exclusive set of zones in the zonelist. > > Watermarks usually do the trick (and is the only reason TIF_MEMDIE works, > > by the way). > > You are playing with fire here. The slab queues *may* have enough memory > to satisfy that requests but if not then we may recursively call into the > page allocator to get a page/pages. Sounds dangerous to me. > Wrong. Notice what the newly-named try_set_zone_oom() function returns if the kzalloc() fails; this was a specific design decision. It returns 1, so the conditional in __alloc_pages() fails and the OOM killer progresses as normal. Thanks for reminding me about that, though, because the following will be needed if that indeed happens. oom: pass null to kfree if zonelist is not cleared If a zonelist pointer cannot be found in the linked list, kfree() must be called with NULL instead. Cc: Andrea Arcangeli Cc: Christoph Lameter Signed-off-by: David Rientjes --- mm/oom_kill.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -438,7 +438,7 @@ out: */ void clear_zonelist_oom(const struct zonelist *zonelist) { - struct oom_zonelist *oom_zl; + struct oom_zonelist *oom_zl = NULL; mutex_lock(&oom_zonelist_mutex); list_for_each_entry(oom_zl, &zonelists, list) -- 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