summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/s390/mm/pgtable.c5
-rw-r--r--fs/proc/task_mmu.c3
-rw-r--r--include/linux/mm.h18
-rw-r--r--include/linux/mm_types.h7
-rw-r--r--kernel/events/uprobes.c2
-rw-r--r--mm/memory.c30
-rw-r--r--mm/oom_kill.c5
-rw-r--r--mm/rmap.c12
8 files changed, 41 insertions, 41 deletions
diff --git a/arch/s390/mm/pgtable.c b/arch/s390/mm/pgtable.c
index 63b039899a5e..aa34af0a0b26 100644
--- a/arch/s390/mm/pgtable.c
+++ b/arch/s390/mm/pgtable.c
@@ -603,10 +603,7 @@ static void gmap_zap_swap_entry(swp_entry_t entry, struct mm_struct *mm)
603 else if (is_migration_entry(entry)) { 603 else if (is_migration_entry(entry)) {
604 struct page *page = migration_entry_to_page(entry); 604 struct page *page = migration_entry_to_page(entry);
605 605
606 if (PageAnon(page)) 606 dec_mm_counter(mm, mm_counter(page));
607 dec_mm_counter(mm, MM_ANONPAGES);
608 else
609 dec_mm_counter(mm, MM_FILEPAGES);
610 } 607 }
611 free_swap_and_cache(entry); 608 free_swap_and_cache(entry);
612} 609}
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
index 8a03759bda38..45eb24145978 100644
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -83,7 +83,8 @@ unsigned long task_statm(struct mm_struct *mm,
83 unsigned long *shared, unsigned long *text, 83 unsigned long *shared, unsigned long *text,
84 unsigned long *data, unsigned long *resident) 84 unsigned long *data, unsigned long *resident)
85{ 85{
86 *shared = get_mm_counter(mm, MM_FILEPAGES); 86 *shared = get_mm_counter(mm, MM_FILEPAGES) +
87 get_mm_counter(mm, MM_SHMEMPAGES);
87 *text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) 88 *text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK))
88 >> PAGE_SHIFT; 89 >> PAGE_SHIFT;
89 *data = mm->total_vm - mm->shared_vm; 90 *data = mm->total_vm - mm->shared_vm;
diff --git a/include/linux/mm.h b/include/linux/mm.h
index 00bad7793788..a8ab1fc0e9bc 100644
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1361,10 +1361,26 @@ static inline void dec_mm_counter(struct mm_struct *mm, int member)
1361 atomic_long_dec(&mm->rss_stat.count[member]); 1361 atomic_long_dec(&mm->rss_stat.count[member]);
1362} 1362}
1363 1363
1364/* Optimized variant when page is already known not to be PageAnon */
1365static inline int mm_counter_file(struct page *page)
1366{
1367 if (PageSwapBacked(page))
1368 return MM_SHMEMPAGES;
1369 return MM_FILEPAGES;
1370}
1371
1372static inline int mm_counter(struct page *page)
1373{
1374 if (PageAnon(page))
1375 return MM_ANONPAGES;
1376 return mm_counter_file(page);
1377}
1378
1364static inline unsigned long get_mm_rss(struct mm_struct *mm) 1379static inline unsigned long get_mm_rss(struct mm_struct *mm)
1365{ 1380{
1366 return get_mm_counter(mm, MM_FILEPAGES) + 1381 return get_mm_counter(mm, MM_FILEPAGES) +
1367 get_mm_counter(mm, MM_ANONPAGES); 1382 get_mm_counter(mm, MM_ANONPAGES) +
1383 get_mm_counter(mm, MM_SHMEMPAGES);
1368} 1384}
1369 1385
1370static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm) 1386static inline unsigned long get_mm_hiwater_rss(struct mm_struct *mm)
diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
index f8d1492a114f..207890be93c8 100644
--- a/include/linux/mm_types.h
+++ b/include/linux/mm_types.h
@@ -369,9 +369,10 @@ struct core_state {
369}; 369};
370 370
371enum { 371enum {
372 MM_FILEPAGES, 372 MM_FILEPAGES, /* Resident file mapping pages */
373 MM_ANONPAGES, 373 MM_ANONPAGES, /* Resident anonymous pages */
374 MM_SWAPENTS, 374 MM_SWAPENTS, /* Anonymous swap entries */
375 MM_SHMEMPAGES, /* Resident shared memory pages */
375 NR_MM_COUNTERS 376 NR_MM_COUNTERS
376}; 377};
377 378
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 7dad84913abf..bb0669169716 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -180,7 +180,7 @@ static int __replace_page(struct vm_area_struct *vma, unsigned long addr,
180 lru_cache_add_active_or_unevictable(kpage, vma); 180 lru_cache_add_active_or_unevictable(kpage, vma);
181 181
182 if (!PageAnon(page)) { 182 if (!PageAnon(page)) {
183 dec_mm_counter(mm, MM_FILEPAGES); 183 dec_mm_counter(mm, mm_counter_file(page));
184 inc_mm_counter(mm, MM_ANONPAGES); 184 inc_mm_counter(mm, MM_ANONPAGES);
185 } 185 }
186 186
diff --git a/mm/memory.c b/mm/memory.c
index c387430f06c3..f7026c035940 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -832,10 +832,7 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
832 } else if (is_migration_entry(entry)) { 832 } else if (is_migration_entry(entry)) {
833 page = migration_entry_to_page(entry); 833 page = migration_entry_to_page(entry);
834 834
835 if (PageAnon(page)) 835 rss[mm_counter(page)]++;
836 rss[MM_ANONPAGES]++;
837 else
838 rss[MM_FILEPAGES]++;
839 836
840 if (is_write_migration_entry(entry) && 837 if (is_write_migration_entry(entry) &&
841 is_cow_mapping(vm_flags)) { 838 is_cow_mapping(vm_flags)) {
@@ -874,10 +871,7 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm,
874 if (page) { 871 if (page) {
875 get_page(page); 872 get_page(page);
876 page_dup_rmap(page); 873 page_dup_rmap(page);
877 if (PageAnon(page)) 874 rss[mm_counter(page)]++;
878 rss[MM_ANONPAGES]++;
879 else
880 rss[MM_FILEPAGES]++;
881 } 875 }
882 876
883out_set_pte: 877out_set_pte:
@@ -1113,9 +1107,8 @@ again:
1113 tlb_remove_tlb_entry(tlb, pte, addr); 1107 tlb_remove_tlb_entry(tlb, pte, addr);
1114 if (unlikely(!page)) 1108 if (unlikely(!page))
1115 continue; 1109 continue;
1116 if (PageAnon(page)) 1110
1117 rss[MM_ANONPAGES]--; 1111 if (!PageAnon(page)) {
1118 else {
1119 if (pte_dirty(ptent)) { 1112 if (pte_dirty(ptent)) {
1120 force_flush = 1; 1113 force_flush = 1;
1121 set_page_dirty(page); 1114 set_page_dirty(page);
@@ -1123,8 +1116,8 @@ again:
1123 if (pte_young(ptent) && 1116 if (pte_young(ptent) &&
1124 likely(!(vma->vm_flags & VM_SEQ_READ))) 1117 likely(!(vma->vm_flags & VM_SEQ_READ)))
1125 mark_page_accessed(page); 1118 mark_page_accessed(page);
1126 rss[MM_FILEPAGES]--;
1127 } 1119 }
1120 rss[mm_counter(page)]--;
1128 page_remove_rmap(page); 1121 page_remove_rmap(page);
1129 if (unlikely(page_mapcount(page) < 0)) 1122 if (unlikely(page_mapcount(page) < 0))
1130 print_bad_pte(vma, addr, ptent, page); 1123 print_bad_pte(vma, addr, ptent, page);
@@ -1146,11 +1139,7 @@ again:
1146 struct page *page; 1139 struct page *page;
1147 1140
1148 page = migration_entry_to_page(entry); 1141 page = migration_entry_to_page(entry);
1149 1142 rss[mm_counter(page)]--;
1150 if (PageAnon(page))
1151 rss[MM_ANONPAGES]--;
1152 else
1153 rss[MM_FILEPAGES]--;
1154 } 1143 }
1155 if (unlikely(!free_swap_and_cache(entry))) 1144 if (unlikely(!free_swap_and_cache(entry)))
1156 print_bad_pte(vma, addr, ptent, NULL); 1145 print_bad_pte(vma, addr, ptent, NULL);
@@ -1460,7 +1449,7 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
1460 1449
1461 /* Ok, finally just insert the thing.. */ 1450 /* Ok, finally just insert the thing.. */
1462 get_page(page); 1451 get_page(page);
1463 inc_mm_counter_fast(mm, MM_FILEPAGES); 1452 inc_mm_counter_fast(mm, mm_counter_file(page));
1464 page_add_file_rmap(page); 1453 page_add_file_rmap(page);
1465 set_pte_at(mm, addr, pte, mk_pte(page, prot)); 1454 set_pte_at(mm, addr, pte, mk_pte(page, prot));
1466 1455
@@ -2097,7 +2086,8 @@ static int wp_page_copy(struct mm_struct *mm, struct vm_area_struct *vma,
2097 if (likely(pte_same(*page_table, orig_pte))) { 2086 if (likely(pte_same(*page_table, orig_pte))) {
2098 if (old_page) { 2087 if (old_page) {
2099 if (!PageAnon(old_page)) { 2088 if (!PageAnon(old_page)) {
2100 dec_mm_counter_fast(mm, MM_FILEPAGES); 2089 dec_mm_counter_fast(mm,
2090 mm_counter_file(old_page));
2101 inc_mm_counter_fast(mm, MM_ANONPAGES); 2091 inc_mm_counter_fast(mm, MM_ANONPAGES);
2102 } 2092 }
2103 } else { 2093 } else {
@@ -2820,7 +2810,7 @@ void do_set_pte(struct vm_area_struct *vma, unsigned long address,
2820 inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES); 2810 inc_mm_counter_fast(vma->vm_mm, MM_ANONPAGES);
2821 page_add_new_anon_rmap(page, vma, address); 2811 page_add_new_anon_rmap(page, vma, address);
2822 } else { 2812 } else {
2823 inc_mm_counter_fast(vma->vm_mm, MM_FILEPAGES); 2813 inc_mm_counter_fast(vma->vm_mm, mm_counter_file(page));
2824 page_add_file_rmap(page); 2814 page_add_file_rmap(page);
2825 } 2815 }
2826 set_pte_at(vma->vm_mm, address, pte, entry); 2816 set_pte_at(vma->vm_mm, address, pte, entry);
diff --git a/mm/oom_kill.c b/mm/oom_kill.c
index c12680993ff3..dc490c06941b 100644
--- a/mm/oom_kill.c
+++ b/mm/oom_kill.c
@@ -585,10 +585,11 @@ void oom_kill_process(struct oom_control *oc, struct task_struct *p,
585 */ 585 */
586 do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true); 586 do_send_sig_info(SIGKILL, SEND_SIG_FORCED, victim, true);
587 mark_oom_victim(victim); 587 mark_oom_victim(victim);
588 pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB\n", 588 pr_err("Killed process %d (%s) total-vm:%lukB, anon-rss:%lukB, file-rss:%lukB, shmem-rss:%lukB\n",
589 task_pid_nr(victim), victim->comm, K(victim->mm->total_vm), 589 task_pid_nr(victim), victim->comm, K(victim->mm->total_vm),
590 K(get_mm_counter(victim->mm, MM_ANONPAGES)), 590 K(get_mm_counter(victim->mm, MM_ANONPAGES)),
591 K(get_mm_counter(victim->mm, MM_FILEPAGES))); 591 K(get_mm_counter(victim->mm, MM_FILEPAGES)),
592 K(get_mm_counter(victim->mm, MM_SHMEMPAGES)));
592 task_unlock(victim); 593 task_unlock(victim);
593 594
594 /* 595 /*
diff --git a/mm/rmap.c b/mm/rmap.c
index 3c3f1d21f075..622756c16ac8 100644
--- 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,
1364 if (PageHuge(page)) { 1364 if (PageHuge(page)) {
1365 hugetlb_count_sub(1 << compound_order(page), mm); 1365 hugetlb_count_sub(1 << compound_order(page), mm);
1366 } else { 1366 } else {
1367 if (PageAnon(page)) 1367 dec_mm_counter(mm, mm_counter(page));
1368 dec_mm_counter(mm, MM_ANONPAGES);
1369 else
1370 dec_mm_counter(mm, MM_FILEPAGES);
1371 } 1368 }
1372 set_pte_at(mm, address, pte, 1369 set_pte_at(mm, address, pte,
1373 swp_entry_to_pte(make_hwpoison_entry(page))); 1370 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,
1377 * interest anymore. Simply discard the pte, vmscan 1374 * interest anymore. Simply discard the pte, vmscan
1378 * will take care of the rest. 1375 * will take care of the rest.
1379 */ 1376 */
1380 if (PageAnon(page)) 1377 dec_mm_counter(mm, mm_counter(page));
1381 dec_mm_counter(mm, MM_ANONPAGES);
1382 else
1383 dec_mm_counter(mm, MM_FILEPAGES);
1384 } else if (IS_ENABLED(CONFIG_MIGRATION) && (flags & TTU_MIGRATION)) { 1378 } else if (IS_ENABLED(CONFIG_MIGRATION) && (flags & TTU_MIGRATION)) {
1385 swp_entry_t entry; 1379 swp_entry_t entry;
1386 pte_t swp_pte; 1380 pte_t swp_pte;
@@ -1420,7 +1414,7 @@ static int try_to_unmap_one(struct page *page, struct vm_area_struct *vma,
1420 swp_pte = pte_swp_mksoft_dirty(swp_pte); 1414 swp_pte = pte_swp_mksoft_dirty(swp_pte);
1421 set_pte_at(mm, address, pte, swp_pte); 1415 set_pte_at(mm, address, pte, swp_pte);
1422 } else 1416 } else
1423 dec_mm_counter(mm, MM_FILEPAGES); 1417 dec_mm_counter(mm, mm_counter_file(page));
1424 1418
1425 page_remove_rmap(page); 1419 page_remove_rmap(page);
1426 page_cache_release(page); 1420 page_cache_release(page);