Please add this fix after
huge-tmpfs-fix-mlocked-meminfo-track-huge-unhuge-mlocks.patch
for later merging into it.  I expect this to fix a build problem found
by robot on an x86_64 randconfig.  I was not able to reproduce the error,
but I'm growing to realize that different optimizers behave differently.

Reported-by: kbuild test robot <fengguang...@intel.com>
Signed-off-by: Hugh Dickins <hu...@google.com>
---
 mm/rmap.c |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1445,8 +1445,12 @@ static int try_to_unmap_one(struct page
         */
        if (!(flags & TTU_IGNORE_MLOCK)) {
                if (vma->vm_flags & VM_LOCKED) {
+                       int nr_pages = 1;
+
+                       if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE) && !pte)
+                               nr_pages = HPAGE_PMD_NR;
                        /* Holding pte lock, we do *not* need mmap_sem here */
-                       mlock_vma_pages(page, pte ? 1 : HPAGE_PMD_NR);
+                       mlock_vma_pages(page, nr_pages);
                        ret = SWAP_MLOCK;
                        goto out_unmap;
                }

Reply via email to