Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1304232 > unrolled thread
| Started by | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> |
|---|---|
| First post | 2016-01-08 08:30 +0100 |
| Last post | 2016-01-13 01:00 +0100 |
| Articles | 6 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v1] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2016-01-08 08:30 +0100
Re: [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp Andrew Morton <akpm@linux-foundation.org> - 2016-01-08 21:40 +0100
Re: [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2016-01-12 04:20 +0100
[PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page() Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2016-01-12 04:20 +0100
[PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> - 2016-01-12 04:20 +0100
Re: [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp Andrew Morton <akpm@linux-foundation.org> - 2016-01-13 01:00 +0100
| From | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> |
|---|---|
| Date | 2016-01-08 08:30 +0100 |
| Subject | [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp |
| Message-ID | <qOzEK-3rg-19@gated-at.bofh.it> |
Currently memory_failure() doesn't handle non anonymous thp case, because we
can hardly expect the error handling to be successful, and it can just hit
some corner case which results in BUG_ON or something severe like that.
This is also a case for soft offline code, so let's make it in the same way.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
mm/memory-failure.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git v4.4-rc8/mm/memory-failure.c v4.4-rc8_patched/mm/memory-failure.c
index 750b789..30e9085 100644
--- v4.4-rc8/mm/memory-failure.c
+++ v4.4-rc8_patched/mm/memory-failure.c
@@ -1751,9 +1751,11 @@ int soft_offline_page(struct page *page, int flags)
return -EBUSY;
}
if (!PageHuge(page) && PageTransHuge(hpage)) {
- if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
- pr_info("soft offline: %#lx: failed to split THP\n",
- pfn);
+ if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
+ if (!PageAnon(hpage))
+ pr_info("soft offline: %#lx: non anonymous thp\n", pfn);
+ else
+ pr_info("soft offline: %#lx: thp split failed\n", pfn);
if (flags & MF_COUNT_INCREASED)
put_hwpoison_page(page);
return -EBUSY;
--
1.7.1
[toc] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2016-01-08 21:40 +0100 |
| Subject | Re: [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp |
| Message-ID | <qOLZg-3xd-9@gated-at.bofh.it> |
| In reply to | #1304232 |
On Fri, 8 Jan 2016 16:24:02 +0900 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:
> Currently memory_failure() doesn't handle non anonymous thp case, because we
> can hardly expect the error handling to be successful, and it can just hit
> some corner case which results in BUG_ON or something severe like that.
> This is also a case for soft offline code, so let's make it in the same way.
>
> ...
>
> --- v4.4-rc8/mm/memory-failure.c
> +++ v4.4-rc8_patched/mm/memory-failure.c
> @@ -1751,9 +1751,11 @@ int soft_offline_page(struct page *page, int flags)
> return -EBUSY;
> }
> if (!PageHuge(page) && PageTransHuge(hpage)) {
> - if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
> - pr_info("soft offline: %#lx: failed to split THP\n",
> - pfn);
> + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
> + if (!PageAnon(hpage))
> + pr_info("soft offline: %#lx: non anonymous thp\n", pfn);
> + else
> + pr_info("soft offline: %#lx: thp split failed\n", pfn);
> if (flags & MF_COUNT_INCREASED)
> put_hwpoison_page(page);
> return -EBUSY;
Kirill's
http://ozlabs.org/~akpm/mmots/broken-out/thp-mm-split_huge_page-caller-need-to-lock-page.patch
mucks with this code as well. Could you please redo this patch against
linux-next?
Thanks.
[toc] | [prev] | [next] | [standalone]
| From | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> |
|---|---|
| Date | 2016-01-12 04:20 +0100 |
| Message-ID | <qPXEZ-3xb-9@gated-at.bofh.it> |
| In reply to | #1304998 |
On Fri, Jan 08, 2016 at 12:33:00PM -0800, Andrew Morton wrote:
> On Fri, 8 Jan 2016 16:24:02 +0900 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:
>
> > Currently memory_failure() doesn't handle non anonymous thp case, because we
> > can hardly expect the error handling to be successful, and it can just hit
> > some corner case which results in BUG_ON or something severe like that.
> > This is also a case for soft offline code, so let's make it in the same way.
> >
> > ...
> >
> > --- v4.4-rc8/mm/memory-failure.c
> > +++ v4.4-rc8_patched/mm/memory-failure.c
> > @@ -1751,9 +1751,11 @@ int soft_offline_page(struct page *page, int flags)
> > return -EBUSY;
> > }
> > if (!PageHuge(page) && PageTransHuge(hpage)) {
> > - if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) {
> > - pr_info("soft offline: %#lx: failed to split THP\n",
> > - pfn);
> > + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
> > + if (!PageAnon(hpage))
> > + pr_info("soft offline: %#lx: non anonymous thp\n", pfn);
> > + else
> > + pr_info("soft offline: %#lx: thp split failed\n", pfn);
> > if (flags & MF_COUNT_INCREASED)
> > put_hwpoison_page(page);
> > return -EBUSY;
>
> Kirill's
> http://ozlabs.org/~akpm/mmots/broken-out/thp-mm-split_huge_page-caller-need-to-lock-page.patch
> mucks with this code as well. Could you please redo this patch against
> linux-next?
OK, I did it, which will come after this email.
Thanks,
Naoya Horiguchi
[toc] | [prev] | [next] | [standalone]
| From | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> |
|---|---|
| Date | 2016-01-12 04:20 +0100 |
| Subject | [PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page() |
| Message-ID | <qPXEZ-3xb-11@gated-at.bofh.it> |
| In reply to | #1306957 |
soft_offline_page() has some deeply indented code, that's the sign of demand
for cleanup. So let's do this. No functionality change.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
mm/memory-failure.c | 78 ++++++++++++++++++++++++++++++++---------------------
1 file changed, 47 insertions(+), 31 deletions(-)
diff --git next-20160111/mm/memory-failure.c next-20160111_patched/mm/memory-failure.c
index 1b99403..2015c9a 100644
--- next-20160111/mm/memory-failure.c
+++ next-20160111_patched/mm/memory-failure.c
@@ -1684,6 +1684,49 @@ static int __soft_offline_page(struct page *page, int flags)
return ret;
}
+static int soft_offline_in_use_page(struct page *page, int flags)
+{
+ int ret;
+ struct page *hpage = compound_head(page);
+
+ if (!PageHuge(page) && PageTransHuge(hpage)) {
+ lock_page(hpage);
+ ret = split_huge_page(hpage);
+ unlock_page(hpage);
+ if (unlikely(ret || PageTransCompound(page) ||
+ !PageAnon(page))) {
+ pr_info("soft offline: %#lx: failed to split THP\n",
+ page_to_pfn(page));
+ if (flags & MF_COUNT_INCREASED)
+ put_hwpoison_page(hpage);
+ return -EBUSY;
+ }
+ get_hwpoison_page(page);
+ put_hwpoison_page(hpage);
+ }
+
+ if (PageHuge(page))
+ ret = soft_offline_huge_page(page, flags);
+ else
+ ret = __soft_offline_page(page, flags);
+
+ return ret;
+}
+
+static void soft_offline_free_page(struct page *page)
+{
+ if (PageHuge(page)) {
+ struct page *hpage = compound_head(page);
+
+ set_page_hwpoison_huge_page(hpage);
+ if (!dequeue_hwpoisoned_huge_page(hpage))
+ num_poisoned_pages_add(1 << compound_order(hpage));
+ } else {
+ if (!TestSetPageHWPoison(page))
+ num_poisoned_pages_inc();
+ }
+}
+
/**
* soft_offline_page - Soft offline a page.
* @page: page to offline
@@ -1710,7 +1753,6 @@ int soft_offline_page(struct page *page, int flags)
{
int ret;
unsigned long pfn = page_to_pfn(page);
- struct page *hpage = compound_head(page);
if (PageHWPoison(page)) {
pr_info("soft offline: %#lx page already poisoned\n", pfn);
@@ -1723,36 +1765,10 @@ int soft_offline_page(struct page *page, int flags)
ret = get_any_page(page, pfn, flags);
put_online_mems();
- if (ret > 0) { /* for in-use pages */
- if (!PageHuge(page) && PageTransHuge(hpage)) {
- lock_page(hpage);
- ret = split_huge_page(hpage);
- unlock_page(hpage);
- if (unlikely(ret || PageTransCompound(page) ||
- !PageAnon(page))) {
- pr_info("soft offline: %#lx: failed to split THP\n",
- pfn);
- if (flags & MF_COUNT_INCREASED)
- put_hwpoison_page(hpage);
- return -EBUSY;
- }
- get_hwpoison_page(page);
- put_hwpoison_page(hpage);
- }
+ if (ret > 0)
+ ret = soft_offline_in_use_page(page, flags);
+ else if (ret == 0)
+ soft_offline_free_page(page);
- if (PageHuge(page))
- ret = soft_offline_huge_page(page, flags);
- else
- ret = __soft_offline_page(page, flags);
- } else if (ret == 0) { /* for free pages */
- if (PageHuge(page)) {
- set_page_hwpoison_huge_page(hpage);
- if (!dequeue_hwpoisoned_huge_page(hpage))
- num_poisoned_pages_add(1 << compound_order(hpage));
- } else {
- if (!TestSetPageHWPoison(page))
- num_poisoned_pages_inc();
- }
- }
return ret;
}
--
2.7.0
[toc] | [prev] | [next] | [standalone]
| From | Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> |
|---|---|
| Date | 2016-01-12 04:20 +0100 |
| Subject | [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp |
| Message-ID | <qPXEZ-3xb-15@gated-at.bofh.it> |
| In reply to | #1306957 |
Currently memory_failure() doesn't handle non anonymous thp case, because we
can hardly expect the error handling to be successful, and it can just hit
some corner case which results in BUG_ON or something severe like that.
This is also the case for soft offline code, so let's make it in the same way.
Orignal code has a MF_COUNT_INCREASED check before put_hwpoison_page(), but
it's unnecessary because get_any_page() is already called when running on
this code, which takes a refcount of the target page regardress of the flag.
So this patch also removes it.
Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
---
ChangeLog v1->v2:
- rebased to next-20160111
---
mm/memory-failure.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git next-20160111/mm/memory-failure.c next-20160111_patched/mm/memory-failure.c
index 2015c9a..6a2f290 100644
--- next-20160111/mm/memory-failure.c
+++ next-20160111_patched/mm/memory-failure.c
@@ -1691,16 +1691,16 @@ static int soft_offline_in_use_page(struct page *page, int flags)
if (!PageHuge(page) && PageTransHuge(hpage)) {
lock_page(hpage);
- ret = split_huge_page(hpage);
- unlock_page(hpage);
- if (unlikely(ret || PageTransCompound(page) ||
- !PageAnon(page))) {
- pr_info("soft offline: %#lx: failed to split THP\n",
- page_to_pfn(page));
- if (flags & MF_COUNT_INCREASED)
- put_hwpoison_page(hpage);
+ if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
+ unlock_page(hpage);
+ if (!PageAnon(hpage))
+ pr_info("soft offline: %#lx: non anonymous thp\n", pfn);
+ else
+ pr_info("soft offline: %#lx: thp split failed\n", pfn);
+ put_hwpoison_page(hpage);
return -EBUSY;
}
+ unlock_page(hpage);
get_hwpoison_page(page);
put_hwpoison_page(hpage);
}
--
2.7.0
[toc] | [prev] | [next] | [standalone]
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Date | 2016-01-13 01:00 +0100 |
| Subject | Re: [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp |
| Message-ID | <qQh10-88E-13@gated-at.bofh.it> |
| In reply to | #1306959 |
On Tue, 12 Jan 2016 12:10:45 +0900 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote:
> Currently memory_failure() doesn't handle non anonymous thp case, because we
> can hardly expect the error handling to be successful, and it can just hit
> some corner case which results in BUG_ON or something severe like that.
> This is also the case for soft offline code, so let's make it in the same way.
>
> Orignal code has a MF_COUNT_INCREASED check before put_hwpoison_page(), but
> it's unnecessary because get_any_page() is already called when running on
> this code, which takes a refcount of the target page regardress of the flag.
> So this patch also removes it.
>
> ...
>
> --- next-20160111/mm/memory-failure.c
> +++ next-20160111_patched/mm/memory-failure.c
> @@ -1691,16 +1691,16 @@ static int soft_offline_in_use_page(struct page *page, int flags)
>
> if (!PageHuge(page) && PageTransHuge(hpage)) {
> lock_page(hpage);
> - ret = split_huge_page(hpage);
> - unlock_page(hpage);
> - if (unlikely(ret || PageTransCompound(page) ||
> - !PageAnon(page))) {
> - pr_info("soft offline: %#lx: failed to split THP\n",
> - page_to_pfn(page));
> - if (flags & MF_COUNT_INCREASED)
> - put_hwpoison_page(hpage);
> + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
> + unlock_page(hpage);
> + if (!PageAnon(hpage))
> + pr_info("soft offline: %#lx: non anonymous thp\n", pfn);
> + else
> + pr_info("soft offline: %#lx: thp split failed\n", pfn);
> + put_hwpoison_page(hpage);
> return -EBUSY;
> }
hm, what happened there.
mm/memory-failure.c: In function 'soft_offline_in_use_page':
mm/memory-failure.c:1697: error: 'pfn' undeclared (first use in this function)
mm/memory-failure.c:1697: error: (Each undeclared identifier is reported only once
mm/memory-failure.c:1697: error: for each function it appears in.)
--- a/mm/memory-failure.c~mm-soft-offline-exit-with-failure-for-non-anonymous-thp-fix
+++ a/mm/memory-failure.c
@@ -1694,9 +1694,9 @@ static int soft_offline_in_use_page(stru
if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) {
unlock_page(hpage);
if (!PageAnon(hpage))
- pr_info("soft offline: %#lx: non anonymous thp\n", pfn);
+ pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page));
else
- pr_info("soft offline: %#lx: thp split failed\n", pfn);
+ pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page));
put_hwpoison_page(hpage);
return -EBUSY;
}
_
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web