f2fs: remove the redundant variable definition
[linux-2.6-block.git] / mm / swapfile.c
index 2cac12cc9abe2dbbd7e5e385de91cf93a4ab61d1..178130880b908515a105eccf9fa428f7cf61719a 100644 (file)
@@ -6,6 +6,8 @@
  */
 
 #include <linux/mm.h>
+#include <linux/sched/mm.h>
+#include <linux/sched/task.h>
 #include <linux/hugetlb.h>
 #include <linux/mman.h>
 #include <linux/slab.h>
@@ -1515,7 +1517,7 @@ static inline int unuse_pmd_range(struct vm_area_struct *vma, pud_t *pud,
        return 0;
 }
 
-static inline int unuse_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
+static inline int unuse_pud_range(struct vm_area_struct *vma, p4d_t *p4d,
                                unsigned long addr, unsigned long end,
                                swp_entry_t entry, struct page *page)
 {
@@ -1523,7 +1525,7 @@ static inline int unuse_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
        unsigned long next;
        int ret;
 
-       pud = pud_offset(pgd, addr);
+       pud = pud_offset(p4d, addr);
        do {
                next = pud_addr_end(addr, end);
                if (pud_none_or_clear_bad(pud))
@@ -1535,6 +1537,26 @@ static inline int unuse_pud_range(struct vm_area_struct *vma, pgd_t *pgd,
        return 0;
 }
 
+static inline int unuse_p4d_range(struct vm_area_struct *vma, pgd_t *pgd,
+                               unsigned long addr, unsigned long end,
+                               swp_entry_t entry, struct page *page)
+{
+       p4d_t *p4d;
+       unsigned long next;
+       int ret;
+
+       p4d = p4d_offset(pgd, addr);
+       do {
+               next = p4d_addr_end(addr, end);
+               if (p4d_none_or_clear_bad(p4d))
+                       continue;
+               ret = unuse_pud_range(vma, p4d, addr, next, entry, page);
+               if (ret)
+                       return ret;
+       } while (p4d++, addr = next, addr != end);
+       return 0;
+}
+
 static int unuse_vma(struct vm_area_struct *vma,
                                swp_entry_t entry, struct page *page)
 {
@@ -1558,7 +1580,7 @@ static int unuse_vma(struct vm_area_struct *vma,
                next = pgd_addr_end(addr, end);
                if (pgd_none_or_clear_bad(pgd))
                        continue;
-               ret = unuse_pud_range(vma, pgd, addr, next, entry, page);
+               ret = unuse_p4d_range(vma, pgd, addr, next, entry, page);
                if (ret)
                        return ret;
        } while (pgd++, addr = next, addr != end);
@@ -1671,7 +1693,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
         * that.
         */
        start_mm = &init_mm;
-       atomic_inc(&init_mm.mm_users);
+       mmget(&init_mm);
 
        /*
         * Keep on scanning until all entries have gone.  Usually,
@@ -1720,7 +1742,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
                if (atomic_read(&start_mm->mm_users) == 1) {
                        mmput(start_mm);
                        start_mm = &init_mm;
-                       atomic_inc(&init_mm.mm_users);
+                       mmget(&init_mm);
                }
 
                /*
@@ -1757,13 +1779,13 @@ int try_to_unuse(unsigned int type, bool frontswap,
                        struct mm_struct *prev_mm = start_mm;
                        struct mm_struct *mm;
 
-                       atomic_inc(&new_start_mm->mm_users);
-                       atomic_inc(&prev_mm->mm_users);
+                       mmget(new_start_mm);
+                       mmget(prev_mm);
                        spin_lock(&mmlist_lock);
                        while (swap_count(*swap_map) && !retval &&
                                        (p = p->next) != &start_mm->mmlist) {
                                mm = list_entry(p, struct mm_struct, mmlist);
-                               if (!atomic_inc_not_zero(&mm->mm_users))
+                               if (!mmget_not_zero(mm))
                                        continue;
                                spin_unlock(&mmlist_lock);
                                mmput(prev_mm);
@@ -1781,7 +1803,7 @@ int try_to_unuse(unsigned int type, bool frontswap,
 
                                if (set_start_mm && *swap_map < swcount) {
                                        mmput(new_start_mm);
-                                       atomic_inc(&mm->mm_users);
+                                       mmget(mm);
                                        new_start_mm = mm;
                                        set_start_mm = 0;
                                }