]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mm/nommu: convert kobjsize() to folios
authorSidhartha Kumar <sidhartha.kumar@oracle.com>
Mon, 4 Aug 2025 14:51:17 +0000 (14:51 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Fri, 12 Sep 2025 00:24:40 +0000 (17:24 -0700)
Simple folio conversion to remove a user of PageSlab() and PageCompound().

Link: https://lkml.kernel.org/r/20250804145117.3857308-1-sidhartha.kumar@oracle.com
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/nommu.c

index 6fff462f90d38298f6833a98637eb65cbb9457c5..c3a23b082adb94e2fcb91bbd3c604ac09291c849 100644 (file)
@@ -64,7 +64,7 @@ const struct vm_operations_struct generic_file_vm_ops = {
  */
 unsigned int kobjsize(const void *objp)
 {
-       struct page *page;
+       struct folio *folio;
 
        /*
         * If the object we have should not have ksize performed on it,
@@ -73,22 +73,22 @@ unsigned int kobjsize(const void *objp)
        if (!objp || !virt_addr_valid(objp))
                return 0;
 
-       page = virt_to_head_page(objp);
+       folio = virt_to_folio(objp);
 
        /*
         * If the allocator sets PageSlab, we know the pointer came from
         * kmalloc().
         */
-       if (PageSlab(page))
+       if (folio_test_slab(folio))
                return ksize(objp);
 
        /*
-        * If it's not a compound page, see if we have a matching VMA
+        * If it's not a large folio, see if we have a matching VMA
         * region. This test is intentionally done in reverse order,
         * so if there's no VMA, we still fall through and hand back
-        * PAGE_SIZE for 0-order pages.
+        * PAGE_SIZE for 0-order folios.
         */
-       if (!PageCompound(page)) {
+       if (!folio_test_large(folio)) {
                struct vm_area_struct *vma;
 
                vma = find_vma(current->mm, (unsigned long)objp);
@@ -100,7 +100,7 @@ unsigned int kobjsize(const void *objp)
         * The ksize() function is only guaranteed to work for pointers
         * returned by kmalloc(). So handle arbitrary pointers here.
         */
-       return page_size(page);
+       return folio_size(folio);
 }
 
 void vfree(const void *addr)