From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758278AbXIEXC4 (ORCPT ); Wed, 5 Sep 2007 19:02:56 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S932422AbXIEXBk (ORCPT ); Wed, 5 Sep 2007 19:01:40 -0400 Received: from mx1.redhat.com ([66.187.233.31]:39395 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932562AbXIEXBh (ORCPT ); Wed, 5 Sep 2007 19:01:37 -0400 Message-ID: <46DF3545.4050604@redhat.com> Date: Wed, 05 Sep 2007 19:01:25 -0400 From: Rik van Riel Organization: Red Hat, Inc User-Agent: Thunderbird 1.5.0.7 (X11/20061008) MIME-Version: 1.0 To: Linux kernel Mailing List CC: linux-mm@kvack.org, akpm@linux-foundation.org, safari-kernel@safari.iki.fi Subject: [PATCH] prevent kswapd from freeing excessive amounts of lowmem Content-Type: multipart/mixed; boundary="------------000104020104000509090502" Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org This is a multi-part message in MIME format. --------------000104020104000509090502 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit The current VM can get itself into trouble fairly easily on systems with a small ZONE_HIGHMEM, which is common on i686 computers with 1GB of memory. On one side, page_alloc() will allocate down to zone->pages_low, while on the other side, kswapd() and balance_pgdat() will try to free memory from every zone, until every zone has more free pages than zone->pages_high. Highmem can be filled up to zone->pages_low with page tables, ramfs, vmalloc allocations and other unswappable things quite easily and without many bad side effects, since we still have a huge ZONE_NORMAL to do future allocations from. However, as long as the number of free pages in the highmem zone is below zone->pages_high, kswapd will continue swapping things out from ZONE_NORMAL, too! Sami Farin managed to get his system into a stage where kswapd had freed about 700MB of low memory and was still "going strong". The attached patch will make kswapd stop paging out data from zones when there is more than enough memory free. We do go above zone->pages_high in order to keep pressure between zones equal in normal circumstances, but the patch should prevent the kind of excesses that made Sami's computer totally unusable. Please merge this into -mm. Signed-off-by: Rik van Riel --------------000104020104000509090502 Content-Type: text/x-patch; name="linux-2.6-excessive-pageout.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="linux-2.6-excessive-pageout.patch" --- linux-2.6.22.noarch/mm/vmscan.c.excessive 2007-09-05 12:19:49.000000000 -0400 +++ linux-2.6.22.noarch/mm/vmscan.c 2007-09-05 12:21:40.000000000 -0400 @@ -1371,7 +1371,13 @@ loop_again: temp_priority[i] = priority; sc.nr_scanned = 0; note_zone_scanning_priority(zone, priority); - nr_reclaimed += shrink_zone(priority, zone, &sc); + /* + * We put equal pressure on every zone, unless one + * zone has way too many pages free already. + */ + if (!zone_watermark_ok(zone, order, 8*zone->pages_high, + end_zone, 0)) + nr_reclaimed += shrink_zone(priority, zone, &sc); reclaim_state->reclaimed_slab = 0; nr_slab = shrink_slab(sc.nr_scanned, GFP_KERNEL, lru_pages); --------------000104020104000509090502--