* [PATCH] mm,numa,THP: initialize hstate for THP page size
@ 2013-12-18 22:03 Rik van Riel
2013-12-18 22:08 ` Andrew Morton
0 siblings, 1 reply; 5+ messages in thread
From: Rik van Riel @ 2013-12-18 22:03 UTC (permalink / raw)
To: linux-kernel
Cc: Chao Yang, linux-mm, akpm, aarcange, mgorman, Veaceslav Falico,
Naoya Horiguchi, David Rientjes, Michel Lespinasse, Michal Hocko
When hugetlbfs is started with a non-default page size, it is
possible that no hstate is initialized for the page sized used
by transparent huge pages.
This causes copy_huge_page to crash on a null pointer. Make
sure we always have an hpage initialized for the page sized
used by THP.
Signed-off-by: Rik van Riel <riel@redhat.com>
Reported-by: Chao Yang <chayang@redhat.com>
---
mm/huge_memory.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/mm/huge_memory.c b/mm/huge_memory.c
index 5749bcf..583e9d3 100644
--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -624,6 +624,13 @@ static int __init hugepage_init(void)
return -EINVAL;
}
+ /*
+ * Make sure an hstate is initialized for our page size,
+ * even if hugetlbfs is using a non-default page size.
+ */
+ if (!size_to_hstate(PMD_PAGE_SIZE))
+ hugetlb_add_hstate(HUGETLB_PAGE_ORDER);
+
err = hugepage_init_sysfs(&hugepage_kobj);
if (err)
return err;
--
All Rights Reversed
--
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>
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] mm,numa,THP: initialize hstate for THP page size
2013-12-18 22:03 [PATCH] mm,numa,THP: initialize hstate for THP page size Rik van Riel
@ 2013-12-18 22:08 ` Andrew Morton
2013-12-18 22:20 ` Rik van Riel
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Morton @ 2013-12-18 22:08 UTC (permalink / raw)
To: Rik van Riel
Cc: linux-kernel, Chao Yang, linux-mm, aarcange, mgorman,
Veaceslav Falico, Naoya Horiguchi, David Rientjes,
Michel Lespinasse, Michal Hocko
On Wed, 18 Dec 2013 17:03:14 -0500 Rik van Riel <riel@redhat.com> wrote:
> When hugetlbfs is started with a non-default page size, it is
> possible that no hstate is initialized for the page sized used
> by transparent huge pages.
>
> This causes copy_huge_page to crash on a null pointer. Make
> sure we always have an hpage initialized for the page sized
> used by THP.
>
A bit more context is needed here please - so that people can decide
which kernel version(s) need patching.
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm,numa,THP: initialize hstate for THP page size
2013-12-18 22:08 ` Andrew Morton
@ 2013-12-18 22:20 ` Rik van Riel
2013-12-19 10:22 ` Michal Hocko
0 siblings, 1 reply; 5+ messages in thread
From: Rik van Riel @ 2013-12-18 22:20 UTC (permalink / raw)
To: Andrew Morton
Cc: linux-kernel, Chao Yang, linux-mm, aarcange, mgorman,
Veaceslav Falico, Naoya Horiguchi, David Rientjes,
Michel Lespinasse, Michal Hocko
On 12/18/2013 05:08 PM, Andrew Morton wrote:
> On Wed, 18 Dec 2013 17:03:14 -0500 Rik van Riel <riel@redhat.com> wrote:
>
>> When hugetlbfs is started with a non-default page size, it is
>> possible that no hstate is initialized for the page sized used
>> by transparent huge pages.
>>
>> This causes copy_huge_page to crash on a null pointer. Make
>> sure we always have an hstate initialized for the page sized
>> used by THP.
>>
>
> A bit more context is needed here please - so that people can decide
> which kernel version(s) need patching.
That is a good question.
Looking at the git log, this might go back to 2008,
when the hugepagesz and default_hugepagesz boot
options were introduced.
Of course, back then there was no way to use 2MB
pages together with 1GB pages.
That did not come until transparent huge pages were
introduced back in 2011. It looks like the transparent
huge page code avoids the bug (accidentally?) by calling
copy_user_huge_page when COWing a THP, instead of
copy_huge_page, this avoids iterating over hstates[].
That means it should not be possible for the bug to
have been triggered until the numa balancing code
got merged.
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm,numa,THP: initialize hstate for THP page size
2013-12-18 22:20 ` Rik van Riel
@ 2013-12-19 10:22 ` Michal Hocko
2013-12-19 15:18 ` Rik van Riel
0 siblings, 1 reply; 5+ messages in thread
From: Michal Hocko @ 2013-12-19 10:22 UTC (permalink / raw)
To: Rik van Riel, Dave Hansen
Cc: Andrew Morton, linux-kernel, Chao Yang, linux-mm, aarcange,
mgorman, Veaceslav Falico, Naoya Horiguchi, David Rientjes,
Michel Lespinasse
[Adding Dave and Mel]
On Wed 18-12-13 17:20:55, Rik van Riel wrote:
> On 12/18/2013 05:08 PM, Andrew Morton wrote:
> >On Wed, 18 Dec 2013 17:03:14 -0500 Rik van Riel <riel@redhat.com> wrote:
> >
> >>When hugetlbfs is started with a non-default page size, it is
> >>possible that no hstate is initialized for the page sized used
> >>by transparent huge pages.
> >>
> >>This causes copy_huge_page to crash on a null pointer. Make
> >>sure we always have an hstate initialized for the page sized
> >>used by THP.
> >>
> >
> >A bit more context is needed here please - so that people can decide
> >which kernel version(s) need patching.
>
> That is a good question.
>
> Looking at the git log, this might go back to 2008,
> when the hugepagesz and default_hugepagesz boot
> options were introduced.
>
> Of course, back then there was no way to use 2MB
> pages together with 1GB pages.
>
> That did not come until transparent huge pages were
> introduced back in 2011. It looks like the transparent
> huge page code avoids the bug (accidentally?) by calling
> copy_user_huge_page when COWing a THP, instead of
> copy_huge_page, this avoids iterating over hstates[].
>
> That means it should not be possible for the bug to
> have been triggered until the numa balancing code
> got merged.
>
copy_huge_page as hugetlb specific thing. It relies on hstate which is
obviously not existing for THP pages. So why do we use it for thp pages
in the first place?
Mel, your "mm: numa: Add THP migration for the NUMA working set scanning
fault case." has added check for PageTransHuge in migrate_page_copy so
it uses the shared copy_huge_page now. Dave has already tried to fix it
by https://lkml.org/lkml/2013/10/28/592 but this one has been dropped
later with "to-be-updated".
Dave do you have an alternative for your patch?
--
Michal Hocko
SUSE Labs
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] mm,numa,THP: initialize hstate for THP page size
2013-12-19 10:22 ` Michal Hocko
@ 2013-12-19 15:18 ` Rik van Riel
0 siblings, 0 replies; 5+ messages in thread
From: Rik van Riel @ 2013-12-19 15:18 UTC (permalink / raw)
To: Michal Hocko
Cc: Dave Hansen, Andrew Morton, linux-kernel, Chao Yang, linux-mm,
aarcange, mgorman, Veaceslav Falico, Naoya Horiguchi,
David Rientjes, Michel Lespinasse
On 12/19/2013 05:22 AM, Michal Hocko wrote:
> [Adding Dave and Mel]
> copy_huge_page as hugetlb specific thing. It relies on hstate which is
> obviously not existing for THP pages. So why do we use it for thp pages
> in the first place?
>
> Mel, your "mm: numa: Add THP migration for the NUMA working set scanning
> fault case." has added check for PageTransHuge in migrate_page_copy so
> it uses the shared copy_huge_page now. Dave has already tried to fix it
> by https://lkml.org/lkml/2013/10/28/592 but this one has been dropped
> later with "to-be-updated".
>
> Dave do you have an alternative for your patch?
Gah, never mind me. This oops happened on a slightly older tree,
that did not have Dave's patch yet...
Andrew, you can drop the patch. Sorry for the noise.
--
All rights reversed
--
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>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-12-19 16:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18 22:03 [PATCH] mm,numa,THP: initialize hstate for THP page size Rik van Riel
2013-12-18 22:08 ` Andrew Morton
2013-12-18 22:20 ` Rik van Riel
2013-12-19 10:22 ` Michal Hocko
2013-12-19 15:18 ` Rik van Riel
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).