From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Wanpeng Li <wanpeng.li@hotmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/hwpoison: fix race between soft_offline_page and unpoison_memory
Date: Fri, 14 Aug 2015 08:02:37 +0000 [thread overview]
Message-ID: <20150814080237.GA6956@hori1.linux.bs1.fc.nec.co.jp> (raw)
In-Reply-To: <BLU437-SMTP24AA9CF28EF66D040D079B807C0@phx.gbl>
On Fri, Aug 14, 2015 at 03:54:36PM +0800, Wanpeng Li wrote:
> On 8/14/15 3:26 PM, Naoya Horiguchi wrote:
> > On Fri, Aug 14, 2015 at 01:03:53PM +0800, Wanpeng Li wrote:
> >> On 8/14/15 12:19 PM, Naoya Horiguchi wrote:
> > ...
> >>>>>>> If I read correctly, the old migratetype approach has a few problems:
> >>>>>>> 1) it doesn't fix the problem completely, because
> >>>>>>> set_migratetype_isolate() can fail to set MIGRATE_ISOLATE to the
> >>>>>>> target page if the pageblock of the page contains one or more
> >>>>>>> unmovable pages (i.e. has_unmovable_pages() returns true).
> >>>>>>> 2) the original code changes migratetype to MIGRATE_ISOLATE forcibly,
> >>>>>>> and sets it to MIGRATE_MOVABLE forcibly after soft offline, regardless
> >>>>>>> of the original migratetype state, which could impact other subsystems
> >>>>>>> like memory hotplug or compaction.
> >>>>>> Maybe we can add a "FIXME" comment on the Migratetype stuff, since the
> >>>>>> current linus tree calltrace and it should be fixed immediately, and I
> >>>>>> don't see obvious bugs appear on migratetype stuffs at least currently,
> >>>>>> so "FIXME" is enough. :-)
> >>>>> Sorry if confusing, but my intention in saying about "FIXME" comment was
> >>>>> that we can find another solution for this race rather than just reverting,
> >>>>> so adding comment about the reported bug in current code (keeping code from
> >>>>> 4491f712606) is OK for very short term.
> >>>>> I understand that leaving a race window of BUG_ON is not the best thing, but
> >>>>> as I said, this race shouldn't affect end-users, so this is not an urgent bug.
> >>>>> # It's enough if testers know this.
> >>>> The 4.2 is coming, this patch can be applied as a temporal solution in
> >>>> order to fix the broken linus tree, and the any final solution can be
> >>>> figured out later.
> >>> I didn't reproduce this problem yet in my environment, but from code reading
> >>> I guess that checking PageHWPoison flag in unmap_and_move() like below could
> >>> avoid the problem. Could you testing with this, please?
> >> I have already try to modify unmap_and_move() the same as what you do
> >> before I post migratetype stuff. It doesn't work and have other calltrace.
> > OK, then I rethink of handling the race in unpoison_memory().
> >
> > Currently properly contained/hwpoisoned pages should have page refcount 1
> > (when the memory error hits LRU pages or hugetlb pages) or refcount 0
> > (when the memory error hits the buddy page.) And current unpoison_memory()
> > implicitly assumes this because otherwise the unpoisoned page has no place
> > to go and it's just leaked.
> > So to avoid the kernel panic, adding prechecks of refcount and mapcount
> > to limit the page to unpoison for only unpoisonable pages looks OK to me.
> > The page under soft offlining always has refcount >=2 and/or mapcount > 0,
> > so such pages should be filtered out.
> >
> > Here's a patch. In my testing (run soft offline stress testing then repeat
> > unpoisoning in background,) the reported (or similar) bug doesn't happen.
> > Can I have your comments?
>
> As page_action() prints out page maybe still referenced by some users,
> however, PageHWPoison has already set. So you will leak many poison pages.
Right, but it isn't a problem, because error handling doesn't always succeed.
Our basic policy for such case is to leak the page intentionally. IOW, the
memory leakage happen even in current kernel (unpoison doesn't work because
leaked page never return to buddy.) So my suggestion doesn't make things worse.
Thanks,
Naoya Horiguchi
--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
prev parent reply other threads:[~2015-08-14 8:09 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-13 7:09 Wanpeng Li
2015-08-13 8:53 ` Naoya Horiguchi
2015-08-13 9:18 ` Wanpeng Li
2015-08-13 10:04 ` Naoya Horiguchi
2015-08-13 10:27 ` Wanpeng Li
2015-08-14 4:19 ` Naoya Horiguchi
2015-08-14 5:03 ` Wanpeng Li
2015-08-14 7:26 ` Naoya Horiguchi
2015-08-14 7:54 ` Wanpeng Li
2015-08-14 7:59 ` Wanpeng Li
2015-08-14 8:38 ` Naoya Horiguchi
2015-08-14 9:01 ` Wanpeng Li
2015-08-17 4:32 ` Naoya Horiguchi
2015-08-17 4:32 ` [PATCH v2 3/3] mm/hwpoison: don't try to unpoison containment-failed pages Naoya Horiguchi
2015-08-17 4:32 ` [PATCH v2 1/3] mm/hwpoison: introduce num_poisoned_pages wrappers Naoya Horiguchi
2015-08-17 4:32 ` [PATCH v2 2/3] mm/hwpoison: fix race between soft_offline_page and unpoison_memory Naoya Horiguchi
2015-08-17 5:29 ` [PATCH] " Wanpeng Li
2015-08-14 8:02 ` Naoya Horiguchi [this message]
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=20150814080237.GA6956@hori1.linux.bs1.fc.nec.co.jp \
--to=n-horiguchi@ah.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=wanpeng.li@hotmail.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