* [PATCH v2] mm/nommu: convert kobjsize() to folios
@ 2025-08-04 14:51 Sidhartha Kumar
2025-08-04 15:33 ` Vlastimil Babka
0 siblings, 1 reply; 2+ messages in thread
From: Sidhartha Kumar @ 2025-08-04 14:51 UTC (permalink / raw)
To: linux-kernel
Cc: linux-mm, akpm, willy, vbabka, jannh, pfalcato, lorenzo.stoakes,
Liam.Howlett, Sidhartha Kumar, SeongJae Park
Simple folio conversion to remove a user of PageSlab() and
PageCompound().
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
---
v1 -> v2:
change "compound folio" to "large folio" in comment per SJ
mm/nommu.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/mm/nommu.c b/mm/nommu.c
index 07504d666d6a..75548fae28f7 100644
--- a/mm/nommu.c
+++ b/mm/nommu.c
@@ -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)
--
2.43.0
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH v2] mm/nommu: convert kobjsize() to folios
2025-08-04 14:51 [PATCH v2] mm/nommu: convert kobjsize() to folios Sidhartha Kumar
@ 2025-08-04 15:33 ` Vlastimil Babka
0 siblings, 0 replies; 2+ messages in thread
From: Vlastimil Babka @ 2025-08-04 15:33 UTC (permalink / raw)
To: Sidhartha Kumar, linux-kernel
Cc: linux-mm, akpm, willy, jannh, pfalcato, lorenzo.stoakes,
Liam.Howlett, SeongJae Park
On 8/4/25 16:51, Sidhartha Kumar wrote:
> Simple folio conversion to remove a user of PageSlab() and
> PageCompound().
>
> Reviewed-by: SeongJae Park <sj@kernel.org>
> Signed-off-by: Sidhartha Kumar <sidhartha.kumar@oracle.com>
Ok a stupid question maybe... why does this code exists at all? AFAICS only
that fs/proc/task_nommu.c can report how much bytes the kernel objects take
for a task? That code seems to be from pre-git era. Does anyone care today?
> ---
> v1 -> v2:
> change "compound folio" to "large folio" in comment per SJ
>
> mm/nommu.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/mm/nommu.c b/mm/nommu.c
> index 07504d666d6a..75548fae28f7 100644
> --- a/mm/nommu.c
> +++ b/mm/nommu.c
> @@ -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)
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-04 15:33 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-04 14:51 [PATCH v2] mm/nommu: convert kobjsize() to folios Sidhartha Kumar
2025-08-04 15:33 ` Vlastimil Babka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox