aboutsummaryrefslogtreecommitdiff
path: root/mm/slob.c
diff options
context:
space:
mode:
authorMatthew Wilcox (Oracle)2021-10-04 14:45:54 +0100
committerVlastimil Babka2022-01-06 12:25:51 +0100
commit0c24811b12ba29a6881e8ec0d01ad3f3b091da02 (patch)
treea90af2ea9e658285a479510f066c17d477cd8be9 /mm/slob.c
parent82c1775dc11a954f3d8c4cb875dff24ea97bc82b (diff)
mm: Convert __ksize() to struct slab
In SLUB, use folios, and struct slab to access slab_cache field. In SLOB, use folios to properly resolve pointers beyond PAGE_SIZE offset of the object. [ vbabka@suse.cz: use folios, and only convert folio_test_slab() == true folios to struct slab ] Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Signed-off-by: Vlastimil Babka <vbabka@suse.cz> Acked-by: Johannes Weiner <hannes@cmpxchg.org> Reviewed-by: Roman Gushchin <guro@fb.com>
Diffstat (limited to 'mm/slob.c')
-rw-r--r--mm/slob.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/mm/slob.c b/mm/slob.c
index 03deee1e6a94..c8a4290012a6 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -570,7 +570,7 @@ EXPORT_SYMBOL(kfree);
/* can't use ksize for kmem_cache_alloc memory, only kmalloc */
size_t __ksize(const void *block)
{
- struct page *sp;
+ struct folio *folio;
int align;
unsigned int *m;
@@ -578,9 +578,9 @@ size_t __ksize(const void *block)
if (unlikely(block == ZERO_SIZE_PTR))
return 0;
- sp = virt_to_page(block);
- if (unlikely(!PageSlab(sp)))
- return page_size(sp);
+ folio = virt_to_folio(block);
+ if (unlikely(!folio_test_slab(folio)))
+ return folio_size(folio);
align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
m = (unsigned int *)(block - align);