Skip to content

Commit bbe7117

Browse files
Matthew Wilcox (Oracle)tehcaster
authored andcommitted
kasan: Remove references to folio in __kasan_mempool_poison_object()
In preparation for splitting struct slab from struct page and struct folio, remove mentions of struct folio from this function. There is a mild improvement for large kmalloc objects as we will avoid calling compound_head() for them. We can discard the comment as using PageLargeKmalloc() rather than !folio_test_slab() makes it obvious. Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org> Acked-by: David Hildenbrand <david@redhat.com> Cc: Alexander Potapenko <glider@google.com> Cc: Andrey Konovalov <andreyknvl@gmail.com> Cc: Dmitry Vyukov <dvyukov@google.com> Cc: Vincenzo Frascino <vincenzo.frascino@arm.com> Cc: kasan-dev <kasan-dev@googlegroups.com> Link: https://patch.msgid.link/20251113000932.1589073-16-willy@infradead.org Acked-by: Harry Yoo <harry.yoo@oracle.com> Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
1 parent b8557d1 commit bbe7117

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

mm/kasan/common.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -520,24 +520,20 @@ void __kasan_mempool_unpoison_pages(struct page *page, unsigned int order,
520520

521521
bool __kasan_mempool_poison_object(void *ptr, unsigned long ip)
522522
{
523-
struct folio *folio = virt_to_folio(ptr);
523+
struct page *page = virt_to_page(ptr);
524524
struct slab *slab;
525525

526-
/*
527-
* This function can be called for large kmalloc allocation that get
528-
* their memory from page_alloc. Thus, the folio might not be a slab.
529-
*/
530-
if (unlikely(!folio_test_slab(folio))) {
526+
if (unlikely(PageLargeKmalloc(page))) {
531527
if (check_page_allocation(ptr, ip))
532528
return false;
533-
kasan_poison(ptr, folio_size(folio), KASAN_PAGE_FREE, false);
529+
kasan_poison(ptr, page_size(page), KASAN_PAGE_FREE, false);
534530
return true;
535531
}
536532

537533
if (is_kfence_address(ptr))
538534
return true;
539535

540-
slab = folio_slab(folio);
536+
slab = page_slab(page);
541537

542538
if (check_slab_allocation(slab->slab_cache, ptr, ip))
543539
return false;

0 commit comments

Comments
 (0)