Re: [PATCH RFC 2/2] mm, hugetlb: do not rely on overcommit limit during migration
From: Michal Hocko
Date: Wed Nov 29 2017 - 04:51:15 EST
On Tue 28-11-17 15:12:11, Michal Hocko wrote:
[...]
> +/*
> + * Internal hugetlb specific page flag. Do not use outside of the hugetlb
> + * code
> + */
> +static inline bool PageHugeTemporary(struct page *page)
> +{
> + if (!PageHuge(page))
> + return false;
> +
> + return page[2].flags == -1U;
> +}
> +
> +static inline void SetPageHugeTemporary(struct page *page)
> +{
> + page[2].flags = -1U;
> +}
> +
> +static inline void ClearPageHugeTemporary(struct page *page)
> +{
> + page[2].flags = 0;
> +}
Ups, this is obviously not OK. I was just lucky to not hit BUG_ONs
because I am clearly overwriting node/zone data in flags. I will have to
find something else to abuse. I will go with my favorite mapping pointer
which is not used at all.
---
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 1be43563e226..db7544a0b7b6 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1259,17 +1259,17 @@ static inline bool PageHugeTemporary(struct page *page)
if (!PageHuge(page))
return false;
- return page[2].flags == -1U;
+ return page[2].mapping == -1U;
}
static inline void SetPageHugeTemporary(struct page *page)
{
- page[2].flags = -1U;
+ page[2].mapping = -1U;
}
static inline void ClearPageHugeTemporary(struct page *page)
{
- page[2].flags = 0;
+ page[2].mapping = NULL;
}
void free_huge_page(struct page *page)
--
Michal Hocko
SUSE Labs