]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm: filemap: use xa_get_order() to get the swap entry order
authorBaolin Wang <baolin.wang@linux.alibaba.com>
Mon, 12 Aug 2024 07:42:05 +0000 (15:42 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sat, 17 Aug 2024 00:53:14 +0000 (17:53 -0700)
In the following patches, shmem will support the swap out of large folios,
which means the shmem mappings may contain large order swap entries, so
using xa_get_order() to get the folio order of the shmem swap entry to
update the '*start' correctly.

Link: https://lkml.kernel.org/r/6876d55145c1cc80e79df7884aa3a62e397b101d.1723434324.git.baolin.wang@linux.alibaba.com
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Cc: Barry Song <baohua@kernel.org>
Cc: Chris Li <chrisl@kernel.org>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: "Huang, Ying" <ying.huang@intel.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Kefeng Wang <wangkefeng.wang@huawei.com>
Cc: Lance Yang <ioworker0@gmail.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Pankaj Raghav <p.raghav@samsung.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Yang Shi <shy828301@gmail.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/filemap.c

index fcfec2a78a309df56f8cf18a21f14c713c5d240d..5985382adb6adb5fe00a3ff337eb2722ca04a860 100644 (file)
@@ -2055,6 +2055,8 @@ unsigned find_get_entries(struct address_space *mapping, pgoff_t *start,
                folio = fbatch->folios[idx];
                if (!xa_is_value(folio))
                        nr = folio_nr_pages(folio);
+               else
+                       nr = 1 << xa_get_order(&mapping->i_pages, indices[idx]);
                *start = indices[idx] + nr;
        }
        return folio_batch_count(fbatch);
@@ -2119,6 +2121,8 @@ put:
                folio = fbatch->folios[idx];
                if (!xa_is_value(folio))
                        nr = folio_nr_pages(folio);
+               else
+                       nr = 1 << xa_get_order(&mapping->i_pages, indices[idx]);
                *start = indices[idx] + nr;
        }
        return folio_batch_count(fbatch);