diff mbox series

[RFC,5/8] mm: shmem: extend shmem_partial_swap_usage() to support large folio swap

Message ID e0009cd7362f64da08aea5883e753192e137da39.1716285099.git.baolin.wang@linux.alibaba.com (mailing list archive)
State New
Headers show
Series support large folio swap-out and swap-in for shmem | expand

Commit Message

Baolin Wang May 21, 2024, 11:03 a.m. UTC
To support shmem large folio swapout in the following patches, using
xa_get_order() to get the order of the swap entry to calculate the swap
usage of shmem.

Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/shmem.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/mm/shmem.c b/mm/shmem.c
index 74821a7031b8..bc099e8b9952 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -865,13 +865,16 @@  unsigned long shmem_partial_swap_usage(struct address_space *mapping,
 	struct page *page;
 	unsigned long swapped = 0;
 	unsigned long max = end - 1;
+	int order;
 
 	rcu_read_lock();
 	xas_for_each(&xas, page, max) {
 		if (xas_retry(&xas, page))
 			continue;
-		if (xa_is_value(page))
-			swapped++;
+		if (xa_is_value(page)) {
+			order = xa_get_order(xas.xa, xas.xa_index);
+			swapped += 1 << order;
+		}
 		if (xas.xa_index == max)
 			break;
 		if (need_resched()) {