If I am not wrong, that triggers:
VM_WARN_ON_FOLIO(folio_test_large(folio) &&
!folio_test_large_rmappable(folio), folio);
So we are trying to rmap a large folio that did not go through
folio_prep_large_rmappable().
Would someone mind explaining the rules to me for this? As far as I can see,
folio_prep_large_rmappable() just inits the _deferred_list and sets a flag so we
remember to deinit the list on destruction. Why can't we just init that list for
all folios order-2 or greater? Then everything is rmappable?
Looks like:
net/packet/af_packet.c calls vm_insert_page() on some pages/folios stoed
in the "struct packet_ring_buffer". No idea where that comes from, but I
suspect it's simply some compound allocation.
alloc_pg_vec
alloc_one_pg_vec_page
gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP |
__GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY;
buffer = (char *) __get_free_pages(gfp_flags, order);
So you are right here... :).
Hm, but I wonder if this something that's supposed to work or is this one of
the cases where we should actually use a VM_PFN mapping?
It's not a pagecache(file/shmem) page after all.
We could relax that check and document why we expect something that is not
marked rmappable. But it fells wrong. I suspect this should be a VM_PFNMAP
instead (like recent udmabuf changes).
VM_PFNMAP looks correct.
And why is making the folio rmappable and mapping it the normal way not the
right solution here? Because the folio could be order-1? Or something more profound?
I do have another question: why do we just check the large folio
rmappable? Does that mean order0 folio is always rmappable?
I ask this because vm_insert_pages() is called in net/ipv4/tcp.c
and drivers call vm_insert_page. I suppose they all need be VM_PFNMAP.