* Trying to allocate a page for migration. Ignore allocation
         * failure warnings. We don't force __GFP_THISNODE here because
         * this node here is the node where we have CMA reservation and
-        * in some case these nodes will have really less non movable
+        * in some case these nodes will have really less non CMA
         * allocation memory.
+        *
+        * Note that CMA region is prohibited by allocation scope.
         */
-       gfp_t gfp_mask = GFP_USER | __GFP_NOWARN;
+       gfp_t gfp_mask = GFP_USER | __GFP_MOVABLE | __GFP_NOWARN;
 
        if (PageHighMem(page))
                gfp_mask |= __GFP_HIGHMEM;
 #ifdef CONFIG_HUGETLB_PAGE
        if (PageHuge(page)) {
                struct hstate *h = page_hstate(page);
+
+               gfp_mask = htlb_modify_alloc_mask(h, gfp_mask);
                /*
                 * We don't want to dequeue from the pool because pool pages will
                 * mostly be from the CMA region.
                 */
                gfp_t thp_gfpmask = GFP_TRANSHUGE | __GFP_NOWARN;
 
-               /*
-                * Remove the movable mask so that we don't allocate from
-                * CMA area again.
-                */
-               thp_gfpmask &= ~__GFP_MOVABLE;
                thp = __alloc_pages_node(nid, thp_gfpmask, HPAGE_PMD_ORDER);
                if (!thp)
                        return NULL;
                                     vmas_tmp, NULL, gup_flags);
 
        if (gup_flags & FOLL_LONGTERM) {
-               memalloc_nocma_restore(flags);
                if (rc < 0)
                        goto out;
 
 
                rc = check_and_migrate_cma_pages(tsk, mm, start, rc, pages,
                                                 vmas_tmp, gup_flags);
+out:
+               memalloc_nocma_restore(flags);
        }
 
-out:
        if (vmas_tmp != vmas)
                kfree(vmas_tmp);
        return rc;