Re: [PATCH v3 7/9] RFC: net: limit folio refcount when rearranging skb frags
From: Pedro Falcato
Date: Thu Nov 12 2026 - 11:10:02 EST
On Tue, Nov 10, 2026 at 09:35:47PM +0100, David Hildenbrand (Arm) wrote:
> Various networking features take additional references to frag pages
> that are still referenced elsewhere when rearranging skb frags, for
> example software GSO segmentation, TCP receive coalescing of clones, SACK
> shifting and MTU probing. This is an effective way for multiplying folio
> references held by an skb, allowing for exceeding folio refcount limits.
>
> This is not specific to large pagecache folios, but with them it is a
> lot easier to reach the refcount limit, as page table mappings can cheaply
> create many references.
>
> Let's use skb_frag_try_ref() and skb_frags_try_ref() in skb_segment(),
> skb_try_coalesce(), skb_shift() and tcp_clone_payload(). All of these can
> already fail, and their callers handle that.
>
> skb_split() can still add one reference when splitting a frag. But each
> split also allocates a new skb that is charged to the socket, reaching
> the refcount limit that way would require a lot of socket memory, and the
> references go away once the data was acked, so it's not that relevant in
> practice. Making skb_split() fail is more involved, so let's leave it alone
> for now.
>
> Fixes: 800d8c63b2e9 ("shmem: add huge pages support")
> Fixes: 99cb0dbd47a1 ("mm,thp: add read-only THP support for (non-shmem) FS")
> Fixes: 793917d997df ("mm/readahead: Add large folio readahead")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: David Hildenbrand (Arm) <david@xxxxxxxxxx>
Acked-by: Pedro Falcato <pfalcato@xxxxxxx>
--
Pedro