Re: [PATCH v10 10/11] mm/hugetlb: Gather discrete indexes of tail page

From: Oscar Salvador
Date: Fri Dec 18 2020 - 04:07:43 EST


On Thu, Dec 17, 2020 at 08:13:02PM +0800, Muchun Song wrote:
> diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> index 6c02f49959fd..78dd88dda857 100644
> --- a/mm/hugetlb.c
> +++ b/mm/hugetlb.c
> @@ -1360,7 +1360,7 @@ static inline void hwpoison_subpage_deliver(struct hstate *h, struct page *head)
> if (!PageHWPoison(head) || !free_vmemmap_pages_per_hpage(h))
> return;
>
> - page = head + page_private(head + 4);
> + page = head + page_private(head + SUBPAGE_INDEX_HWPOISON);
>
> /*
> * Move PageHWPoison flag from head page to the raw error page,
> @@ -1379,7 +1379,7 @@ static inline void hwpoison_subpage_set(struct hstate *h, struct page *head,
> return;
>
> if (free_vmemmap_pages_per_hpage(h)) {
> - set_page_private(head + 4, page - head);
> + set_page_private(head + SUBPAGE_INDEX_HWPOISON, page - head);

Ok, I was too eager here.

If CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is not set for whatever reason
(e.g: CONFIG_MEMORY_HOTREMOVE is disabled), when you convert "+4"
to its index (SUBPAGE_INDEX_HWPOISON), this will no longer build
since we only define SUBPAGE_INDEX_HWPOISON when the config
option CONFIG_HUGETLB_PAGE_FREE_VMEMMAP is set.

Different things can be done to fix this:

e.g:

- Define a two different hwpoison_subpage_{deliver,set}
and have them under
#ifdef CONFIG_HUGETLB_PAGE_FREE_VMEMMAP
...
#else
...
#endif

- Work it around as is with IS_ENABLED(CONFIG_HUGETLB_...
- Have a common entry and decide depending on whether
the config is enabled.

I guess option #1 might be cleaner.

--
Oscar Salvador
SUSE L3