From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with ESMTP id A4F60900114 for ; Sat, 21 May 2011 09:35:10 -0400 (EDT) Received: by pzk4 with SMTP id 4so2677910pzk.14 for ; Sat, 21 May 2011 06:35:07 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: <4DD5DC06.6010204@jp.fujitsu.com> <20110520140856.fdf4d1c8.kamezawa.hiroyu@jp.fujitsu.com> <20110520101120.GC11729@random.random> <20110520153346.GA1843@barrios-desktop> <20110520161934.GA2386@barrios-desktop> From: Andrew Lutomirski Date: Sat, 21 May 2011 09:34:47 -0400 Message-ID: Subject: Re: Kernel falls apart under light memory pressure (i.e. linking vmlinux) Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: KOSAKI Motohiro Cc: Minchan Kim , Andrea Arcangeli , KAMEZAWA Hiroyuki , fengguang.wu@intel.com, andi@firstfloor.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, mgorman@suse.de, hannes@cmpxchg.org, riel@redhat.com On Sat, May 21, 2011 at 8:04 AM, KOSAKI Motohiro wrote: >> diff --git a/mm/vmscan.c b/mm/vmscan.c >> index 3f44b81..d1dabc9 100644 >> @@ -1426,8 +1437,13 @@ shrink_inactive_list(unsigned long nr_to_scan, >> struct zone *zone, >> >> =A0 =A0 =A0 =A0/* Check if we should syncronously wait for writeback */ >> =A0 =A0 =A0 =A0if (should_reclaim_stall(nr_taken, nr_reclaimed, priority= , sc)) { >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 unsigned long nr_active, old_nr_scanned; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0set_reclaim_mode(priority, sc, true); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 nr_active =3D clear_active_flags(&page_lis= t, NULL); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 count_vm_events(PGDEACTIVATE, nr_active); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 old_nr_scanned =3D sc->nr_scanned; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0nr_reclaimed +=3D shrink_page_list(&page_= list, zone, sc); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 sc->nr_scanned =3D old_nr_scanned; >> =A0 =A0 =A0 =A0} >> >> =A0 =A0 =A0 =A0local_irq_disable(); >> >> I just tested 2.6.38.6 with the attached patch. =A0It survived dirty_ram >> and test_mempressure without any problems other than slowness, but >> when I hit ctrl-c to stop test_mempressure, I got the attached oom. > > Minchan, > > I'm confused now. > If pages got SetPageActive(), should_reclaim_stall() should never return = true. > Can you please explain which bad scenario was happen? > > -------------------------------------------------------------------------= ---------------------------- > static void reset_reclaim_mode(struct scan_control *sc) > { > =A0 =A0 =A0 =A0sc->reclaim_mode =3D RECLAIM_MODE_SINGLE | RECLAIM_MODE_AS= YNC; > } > > shrink_page_list() > { > =A0(snip) > =A0activate_locked: > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0SetPageActive(page); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0pgactivate++; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0unlock_page(page); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0reset_reclaim_mode(sc); =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0/// here > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0list_add(&page->lru, &ret_pages); > =A0 =A0 =A0 =A0} > -------------------------------------------------------------------------= ---------------------------- > > > -------------------------------------------------------------------------= ---------------------------- > bool should_reclaim_stall() > { > =A0(snip) > > =A0 =A0 =A0 =A0/* Only stall on lumpy reclaim */ > =A0 =A0 =A0 =A0if (sc->reclaim_mode & RECLAIM_MODE_SINGLE) =A0 /// and he= re > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0return false; > -------------------------------------------------------------------------= ---------------------------- > I did some tracing and the oops happens from the second call to shrink_page_list after should_reclaim_stall returns true and it hits the same pages in the same order that the earlier call just finished calling SetPageActive on. I have *not* confirmed that the two calls happened from the same call to shrink_inactive_list, but something's certainly wrong in there. This is very easy to reproduce on my laptop. --Andy -- 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/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org