mm/smaps: use vma->vm_pgoff directly when counting partial swap
authorPeter Xu <peterx@redhat.com>
Fri, 5 Nov 2021 20:36:02 +0000 (13:36 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Sat, 6 Nov 2021 20:30:33 +0000 (13:30 -0700)
As it's trying to cover the whole vma anyways, use direct vm_pgoff value
and vma_pages() rather than linear_page_index.

Link: https://lkml.kernel.org/r/20210917164756.8586-3-peterx@redhat.com
Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/shmem.c

index b5860f4a2738ee3861e30bd4e506578a0f9218ba..7cd976b588ff1c5f06d7abde610655c449ef4db7 100644 (file)
@@ -856,9 +856,8 @@ unsigned long shmem_swap_usage(struct vm_area_struct *vma)
                return swapped << PAGE_SHIFT;
 
        /* Here comes the more involved part */
-       return shmem_partial_swap_usage(mapping,
-                       linear_page_index(vma, vma->vm_start),
-                       linear_page_index(vma, vma->vm_end));
+       return shmem_partial_swap_usage(mapping, vma->vm_pgoff,
+                                       vma->vm_pgoff + vma_pages(vma));
 }
 
 /*