Skip to content

Commit de55be4

Browse files
ryncsnakpm00
authored andcommitted
mm/shmem, swap: fix major fault counting
If the swapin failed, don't update the major fault count. There is a long existing comment for doing it this way, now with previous cleanups, we can finally fix it. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kairui Song <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Cc: Baoquan He <[email protected]> Cc: Barry Song <[email protected]> Cc: Chris Li <[email protected]> Cc: Dev Jain <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Kemeng Shi <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Nhat Pham <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 93c0476 commit de55be4

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

mm/shmem.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,13 +2356,6 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
23562356
/* Look it up and read it in.. */
23572357
folio = swap_cache_get_folio(swap, NULL, 0);
23582358
if (!folio) {
2359-
/* Or update major stats only when swapin succeeds?? */
2360-
if (fault_type) {
2361-
*fault_type |= VM_FAULT_MAJOR;
2362-
count_vm_event(PGMAJFAULT);
2363-
count_memcg_event_mm(fault_mm, PGMAJFAULT);
2364-
}
2365-
23662359
if (data_race(si->flags & SWP_SYNCHRONOUS_IO)) {
23672360
/* Direct swapin skipping swap cache & readahead */
23682361
folio = shmem_swap_alloc_folio(inode, vma, index,
@@ -2381,6 +2374,11 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
23812374
goto failed;
23822375
}
23832376
}
2377+
if (fault_type) {
2378+
*fault_type |= VM_FAULT_MAJOR;
2379+
count_vm_event(PGMAJFAULT);
2380+
count_memcg_event_mm(fault_mm, PGMAJFAULT);
2381+
}
23842382
}
23852383

23862384
if (order > folio_order(folio)) {

0 commit comments

Comments
 (0)