From: Andrew Lutomirski <luto@mit.edu>
To: Andrea Arcangeli <aarcange@redhat.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Minchan Kim <minchan.kim@gmail.com>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
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
Subject: Re: Kernel falls apart under light memory pressure (i.e. linking vmlinux)
Date: Fri, 20 May 2011 10:11:47 -0400 [thread overview]
Message-ID: <BANLkTikAFMvpgHR2dopd+Nvjfyw_XT5=LA@mail.gmail.com> (raw)
In-Reply-To: <20110520101120.GC11729@random.random>
[-- Attachment #1: Type: text/plain, Size: 4915 bytes --]
On Fri, May 20, 2011 at 6:11 AM, Andrea Arcangeli <aarcange@redhat.com> wrote:
> I figure it's not easily reproducible but you can easily rule out THP
> issues by reproducing at least once after booting with
> transparent_hugepage=never or by building the kernel with
> CONFIG_TRANSPARENT_HUGEPAGE=n.
Reproduced with CONFIG_TRANSPARENT_HUGEPAGE=n with and without
compaction and migration.
I applied the attached patch (which includes Minchan's !pgdat_balanced
and need_resched changes). I see:
[ 121.468339] firefox shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea00019217a8) w/ prev = 100000000002000D
[ 121.469236] firefox shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea00016596b8) w/ prev = 100000000002000D
[ 121.470207] firefox: shrink_page_list (nr_scanned=94
nr_reclaimed=19 nr_to_reclaim=32 gfp_mask=201DA) found inactive page
ffffea00019217a8 with flags=100000000002004D
[ 121.472451] firefox: shrink_page_list (nr_scanned=94
nr_reclaimed=19 nr_to_reclaim=32 gfp_mask=201DA) found inactive page
ffffea00016596b8 with flags=100000000002004D
[ 121.482782] dd shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea00013a8938) w/ prev = 100000000002000D
[ 121.489820] dd shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea00017a4e88) w/ prev = 1000000000000801
[ 121.490626] dd shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000005edb0) w/ prev = 1000000000000801
[ 121.491499] dd: shrink_page_list (nr_scanned=62 nr_reclaimed=0
nr_to_reclaim=32 gfp_mask=200D2) found inactive page ffffea00017a4e88
with flags=1000000000000841
[ 121.494337] dd: shrink_page_list (nr_scanned=62 nr_reclaimed=0
nr_to_reclaim=32 gfp_mask=200D2) found inactive page ffffea000005edb0
with flags=1000000000000841
[ 121.499219] dd shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000129c788) w/ prev = 1000000000080009
[ 121.500363] dd shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000129c830) w/ prev = 1000000000080009
[ 121.502270] kswapd0 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0001146470) w/ prev = 100000000008001D
[ 121.661545] kworker/1:1 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0000058168) w/ prev = 1000000000000801
[ 121.662791] kworker/1:1 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000166f288) w/ prev = 1000000000000801
[ 121.665727] kworker/1:1 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0001681c40) w/ prev = 1000000000000801
[ 121.666857] kworker/1:1 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0001693130) w/ prev = 1000000000000801
[ 121.667988] kworker/1:1 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0000c790d8) w/ prev = 1000000000000801
[ 121.669105] kworker/1:1 shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000113fe48) w/ prev = 1000000000000801
[ 121.670238] kworker/1:1: shrink_page_list (nr_scanned=102
nr_reclaimed=20 nr_to_reclaim=32 gfp_mask=11212) found inactive page
ffffea0000058168 with flags=1000000000000841
[ 121.674061] kworker/1:1: shrink_page_list (nr_scanned=102
nr_reclaimed=20 nr_to_reclaim=32 gfp_mask=11212) found inactive page
ffffea000166f288 with flags=1000000000000841
[ 121.678054] kworker/1:1: shrink_page_list (nr_scanned=102
nr_reclaimed=20 nr_to_reclaim=32 gfp_mask=11212) found inactive page
ffffea0001681c40 with flags=1000000000000841
[ 121.682069] kworker/1:1: shrink_page_list (nr_scanned=102
nr_reclaimed=20 nr_to_reclaim=32 gfp_mask=11212) found inactive page
ffffea0001693130 with flags=1000000000000841
[ 121.686074] kworker/1:1: shrink_page_list (nr_scanned=102
nr_reclaimed=20 nr_to_reclaim=32 gfp_mask=11212) found inactive page
ffffea0000c790d8 with flags=1000000000000841
[ 121.690045] kworker/1:1: shrink_page_list (nr_scanned=102
nr_reclaimed=20 nr_to_reclaim=32 gfp_mask=11212) found inactive page
ffffea000113fe48 with flags=1000000000000841
[ 121.866205] test_mempressur shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000165d5b8) w/ prev = 100000000002000D
[ 121.868204] test_mempressur shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0001661288) w/ prev = 100000000002000D
[ 121.870203] test_mempressur shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0001661250) w/ prev = 100000000002000D
[ 121.872195] test_mempressur shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea000100cee8) w/ prev = 100000000002000D
[ 121.873486] test_mempressur shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0000eafab8) w/ prev = 100000000002000D
[ 121.874718] test_mempressur shrink_page_list+0x4f3/0x5ca:
SetPageActive(ffffea0000eafaf0) w/ prev = 100000000002000D
This is interesting: it looks like shrink_page_list is making its way
through the list more than once. It could be reentering itself
somehow or it could have something screwed up with the linked list.
I'll keep slowly debugging, but maybe this is enough for someone
familiar with this code to beat me to it.
Minchan, I think this means that your fixes are just hiding and not
fixing the underlying problem.
[-- Attachment #2: vm_tests.patch --]
[-- Type: application/octet-stream, Size: 3074 bytes --]
diff --git a/mm/swap.c b/mm/swap.c
index c02f936..74118d2 100644
--- a/mm/swap.c
+++ b/mm/swap.c
@@ -40,6 +40,25 @@ int page_cluster;
static DEFINE_PER_CPU(struct pagevec[NR_LRU_LISTS], lru_add_pvecs);
static DEFINE_PER_CPU(struct pagevec, lru_rotate_pvecs);
+static noinline void SetPageActiveCheck(struct page *page)
+{
+ unsigned long x;
+ while(true) {
+ unsigned long flags = page->flags;
+ x = cmpxchg(&(page)->flags, flags,
+ flags | (1 << PG_active));
+ if (x == flags) break;
+ }
+ if (~x & (1 << PG_lru)) {
+ char name[sizeof(current->comm)];
+ printk(KERN_ERR "%s %pS: SetPageActive(%p) w/ prev = %lX\n",
+ get_task_comm(name, current),
+ __builtin_return_address(0), page, x);
+ }
+}
+
+#define SetPageActive SetPageActiveCheck
+
/*
* This path almost never happens for VM activity - pages are normally
* freed via pagevecs. But it gets used by networking.
diff --git a/mm/vmscan.c b/mm/vmscan.c
index 3f44b81..dc417ab 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -53,6 +53,25 @@
#define CREATE_TRACE_POINTS
#include <trace/events/vmscan.h>
+static noinline void SetPageActiveCheck(struct page *page)
+{
+ unsigned long x;
+ while(true) {
+ unsigned long flags = page->flags;
+ x = cmpxchg(&(page)->flags, flags,
+ flags | (1 << PG_active));
+ if (x == flags) break;
+ }
+ if (~x & (1 << PG_lru)) {
+ char name[sizeof(current->comm)];
+ printk(KERN_ERR "%s %pS: SetPageActive(%p) w/ prev = %lX\n",
+ get_task_comm(name, current),
+ __builtin_return_address(0), page, x);
+ }
+}
+
+#define SetPageActive SetPageActiveCheck
+
/*
* reclaim_mode determines how the inactive list is shrunk
* RECLAIM_MODE_SINGLE: Reclaim only order-0 pages
@@ -729,7 +748,17 @@ static unsigned long shrink_page_list(struct list_head *page_list,
if (!trylock_page(page))
goto keep;
- VM_BUG_ON(PageActive(page));
+ if (PageActive(page)) {
+ char name[sizeof(current->comm)];
+ printk(KERN_ERR "%s: shrink_page_list (nr_scanned=%lu nr_reclaimed=%lu nr_to_reclaim=%lu gfp_mask=%X) found inactive page %p with flags=%lX\n",
+ get_task_comm(name, current),
+ sc->nr_scanned, sc->nr_reclaimed,
+ sc->nr_to_reclaim, sc->gfp_mask, page,
+ page->flags);
+ //VM_BUG_ON(PageActive(page));
+ msleep(1);
+ continue;
+ }
VM_BUG_ON(page_zone(page) != zone);
sc->nr_scanned++;
@@ -2247,6 +2276,10 @@ static bool sleeping_prematurely(pg_data_t *pgdat, int order, long remaining,
unsigned long balanced = 0;
bool all_zones_ok = true;
+ /* If kswapd has been running too long, just sleep */
+ if (need_resched())
+ return false;
+
/* If a direct reclaimer woke kswapd within HZ/10, it's premature */
if (remaining)
return true;
@@ -2282,7 +2315,7 @@ static bool sleeping_prematurely(pg_data_t *pgdat, int order, long remaining,
* must be balanced
*/
if (order)
- return pgdat_balanced(pgdat, balanced, classzone_idx);
+ return !pgdat_balanced(pgdat, balanced, classzone_idx);
else
return !all_zones_ok;
}
next prev parent reply other threads:[~2011-05-20 14:12 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BANLkTi=XqROAp2MOgwQXEQjdkLMenh_OTQ@mail.gmail.com>
[not found] ` <m2fwokj0oz.fsf@firstfloor.org>
[not found] ` <BANLkTikhj1C7+HXP_4T-VnJzPefU2d7b3A@mail.gmail.com>
[not found] ` <20110512054631.GI6008@one.firstfloor.org>
[not found] ` <BANLkTi=fk3DUT9cYd2gAzC98c69F6HXX7g@mail.gmail.com>
2011-05-14 15:46 ` Kernel falls apart under light memory pressure (i.e. linking vmlinux) Andrew Lutomirski
2011-05-14 16:53 ` Andi Kleen
[not found] ` <BANLkTik6SS9NH7XVSRBoCR16_5veY0MKBw@mail.gmail.com>
2011-05-14 17:43 ` Andi Kleen
2011-05-15 1:37 ` Minchan Kim
2011-05-15 15:27 ` Wu Fengguang
2011-05-15 15:59 ` Andrew Lutomirski
2011-05-15 22:58 ` Minchan Kim
2011-05-16 8:51 ` Mel Gorman
2011-05-15 16:12 ` Andrew Lutomirski
2011-05-17 6:00 ` Wu Fengguang
2011-05-17 6:35 ` Minchan Kim
2011-05-17 19:22 ` Andrew Lutomirski
2011-05-18 5:17 ` Minchan Kim
2011-05-19 2:15 ` Andrew Lutomirski
2011-05-19 2:30 ` KAMEZAWA Hiroyuki
2011-05-19 2:41 ` Andrew Lutomirski
2011-05-19 2:54 ` Minchan Kim
2011-05-19 14:16 ` Andrew Lutomirski
2011-05-20 0:17 ` Minchan Kim
2011-05-20 2:58 ` Andrew Lutomirski
2011-05-20 3:12 ` KOSAKI Motohiro
2011-05-20 3:38 ` Andrew Lutomirski
2011-05-20 4:20 ` Minchan Kim
2011-05-20 5:08 ` KAMEZAWA Hiroyuki
2011-05-20 5:36 ` Minchan Kim
2011-05-20 7:43 ` KAMEZAWA Hiroyuki
2011-05-20 10:11 ` Andrea Arcangeli
2011-05-20 14:11 ` Andrew Lutomirski [this message]
2011-05-20 15:33 ` Minchan Kim
2011-05-20 16:01 ` Andrew Lutomirski
2011-05-20 16:19 ` Minchan Kim
2011-05-20 18:09 ` Andrew Lutomirski
2011-05-20 18:40 ` Andrew Lutomirski
2011-05-21 12:04 ` KOSAKI Motohiro
2011-05-21 13:34 ` Andrew Lutomirski
2011-05-21 14:14 ` KOSAKI Motohiro
2011-05-21 14:44 ` Minchan Kim
2011-05-22 12:22 ` Andrew Lutomirski
2011-05-22 23:12 ` Minchan Kim
2011-05-23 16:42 ` Andrea Arcangeli
2011-05-23 17:35 ` Mel Gorman
2011-05-24 1:19 ` Andrew Lutomirski
2011-05-24 1:34 ` Minchan Kim
2011-05-24 11:24 ` Andrew Lutomirski
2011-05-24 11:55 ` Andrew Lutomirski
2011-05-25 0:43 ` KOSAKI Motohiro
2011-05-21 14:31 ` Minchan Kim
2011-05-19 14:51 ` Wu Fengguang
2011-05-19 15:00 ` Andrew Lutomirski
2011-05-20 0:20 ` Minchan Kim
2011-05-15 22:40 ` Minchan Kim
2011-05-17 5:52 ` Wu Fengguang
2011-05-17 6:26 ` Minchan Kim
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='BANLkTikAFMvpgHR2dopd+Nvjfyw_XT5=LA@mail.gmail.com' \
--to=luto@mit.edu \
--cc=aarcange@redhat.com \
--cc=andi@firstfloor.org \
--cc=fengguang.wu@intel.com \
--cc=hannes@cmpxchg.org \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=minchan.kim@gmail.com \
--cc=riel@redhat.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;
as well as URLs for NNTP newsgroup(s).