]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - mm/rmap.c
mm, shmem: add internal shmem resident memory accounting
[mirror_ubuntu-bionic-kernel.git] / mm / rmap.c
index 3c3f1d21f07585e1fd49b2e5003f65051c89a921..622756c16ac84ccc905355d3d6b59a9b9dca35e4 100644 (file)
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -1364,10 +1364,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                if (PageHuge(page)) {
                        hugetlb_count_sub(1 << compound_order(page), mm);
                } else {
-                       if (PageAnon(page))
-                               dec_mm_counter(mm, MM_ANONPAGES);
-                       else
-                               dec_mm_counter(mm, MM_FILEPAGES);
+                       dec_mm_counter(mm, mm_counter(page));
                }
                set_pte_at(mm, address, pte,
                           swp_entry_to_pte(make_hwpoison_entry(page)));
@@ -1377,10 +1374,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                 * interest anymore. Simply discard the pte, vmscan
                 * will take care of the rest.
                 */
-               if (PageAnon(page))
-                       dec_mm_counter(mm, MM_ANONPAGES);
-               else
-                       dec_mm_counter(mm, MM_FILEPAGES);
+               dec_mm_counter(mm, mm_counter(page));
        } else if (IS_ENABLED(CONFIG_MIGRATION) && (flags & TTU_MIGRATION)) {
                swp_entry_t entry;
                pte_t swp_pte;
@@ -1420,7 +1414,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
                        swp_pte = pte_swp_mksoft_dirty(swp_pte);
                set_pte_at(mm, address, pte, swp_pte);
        } else
-               dec_mm_counter(mm, MM_FILEPAGES);
+               dec_mm_counter(mm, mm_counter_file(page));
 
        page_remove_rmap(page);
        page_cache_release(page);