Re: [PATCH] mm/Kconfig: allow user to select MIGRATION if MEMORY_FAILURE is enabled
From: David Hildenbrand (Arm)
Date: Thu Aug 13 2026 - 03:06:28 EST
On 8/13/26 04:26, Xie Yuanbin wrote:
> On Wed, 12 Aug 2026 13:45:30 +0300, Mike Rapoport wrote:
>> Do we want to make users decide if they need MIGRATION when MEMORY_FAILURE
>> is enabled?
>>
>> Just make MEMORY_FAILURE select MIGRATION.
>
> I agree with this solution, but I discovered another way: just like
> commit 6ebf98d71f9b509e833e ("mm: introduce CONFIG_NUMA_MIGRATION and
> simplify CONFIG_MIGRATION") done, add CONFIG_MEMORY_FAILURE_MIGRATION
> to select MIGRATION. The Modification is also very simple:
> ```patch
> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
> index a8b03e2920ba..500e54ace6c9 100644
> --- a/mm/memory-failure.c
> +++ b/mm/memory-failure.c
> @@ -1340,9 +1340,11 @@ static inline bool HWPoisonHandlable(struct page *page, unsigned long flags)
> if (PageSlab(page))
> return false;
>
> +#ifdef CONFIG_MEMORY_FAILURE_MIGRATION
> /* Soft offline could migrate movable_ops pages */
> if ((flags & MF_SOFT_OFFLINE) && page_has_movable_ops(page))
> return true;
> +#endif
>
> return PageLRU(page) || is_free_buddy_page(page);
> }
> @@ -2028,7 +2030,8 @@ static int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
> count_increased = true;
> } else if (folio_test_hugetlb_freed(folio)) {
> ret = MF_HUGETLB_FREED;
> - } else if (folio_test_hugetlb_migratable(folio)) {
> + } else if (IS_ENABLED(CONFIG_MEMORY_FAILURE_MIGRATION) &&
> + folio_test_hugetlb_migratable(folio)) {
> if (folio_try_get(folio)) {
> ret = MF_HUGETLB_IN_USED;
> count_increased = true;
> @@ -2051,10 +2054,12 @@ static int get_huge_page_for_hwpoison(unsigned long pfn, int flags,
> * Clearing hugetlb_migratable for hwpoisoned hugepages to prevent them
> * from being migrated by memory hotremove.
> */
> +#ifdef CONFIG_MEMORY_FAILURE_MIGRATION
> if (count_increased && folio_test_hugetlb_migratable(folio)) {
> folio_clear_hugetlb_migratable(folio);
> *migratable_cleared = true;
> }
> +#endif
>
> spin_unlock_irq(&hugetlb_lock);
> return ret;
> @@ -2903,7 +2908,7 @@ static int soft_offline_in_use_page(struct page *page)
> return 0;
> }
>
> - isolated = isolate_folio_to_list(folio, &pagelist);
> + isolated = IS_ENABLED(CONFIG_MEMORY_FAILURE_MIGRATION) && isolate_folio_to_list(folio, &pagelist);
>
> /*
> * If we succeed to isolate the folio, we grabbed another refcount on
> ```
>
> Would this be a better way?
Why add a new config option?
--
Cheers,
David