From: Björn Töpel <[email protected]>
Date: Tue, 01 Dec 2026 08:12:05 +0100

> Alexander Lobakin <[email protected]> writes:
> 
>> From: Björn Töpel <[email protected]>
>> Date: Mon, 30 Nov 2026 13:37:33 +0100
>>> diff --git a/net/core/xdp.c b/net/core/xdp.c
>>> index 1d679e8fd649..33a6740b411f 100644
>>> --- a/net/core/xdp.c
>>> +++ b/net/core/xdp.c
>>> @@ -738,33 +760,27 @@ static noinline bool xdp_copy_frags_from_zc(struct 
>>> sk_buff *skb,
>>>   */
>>>  struct sk_buff *xdp_build_skb_from_zc(struct xdp_buff *xdp)
>>>  {
>>> +   u32 size = xdp->data_end - xdp->data_hard_start;
>>>     const struct xdp_rxq_info *rxq = xdp->rxq;
>>>     u32 len = xdp->data_end - xdp->data_meta;
>>> -   u32 truesize = xdp->frame_sz;
>>>     struct sk_buff *skb = NULL;
>>>     struct page_pool *pp;
>>>     int metalen;
>>> -   void *data;
>>>  
>>>     if (!IS_ENABLED(CONFIG_PAGE_POOL))
>>>             return NULL;
>>>  
>>>     local_lock_nested_bh(&system_page_pool.bh_lock);
>>>     pp = this_cpu_read(system_page_pool.pool);
>>> -   data = page_pool_dev_alloc_va(pp, &truesize);
>>> -   if (unlikely(!data))
>>> -           goto out;
>>>  
>>> -   skb = napi_build_skb(data, truesize);
>>> -   if (unlikely(!skb)) {
>>> -           page_pool_free_va(pp, data, true);
>>> +   skb = xdp_zc_alloc_head(pp, rxq->dev, size);
>>> +   if (unlikely(!skb))
>>>             goto out;
>>> -   }
>>>  
>>>     skb_mark_for_recycle(skb);
>>
>> I'd move this call to the bottom of xdp_zc_alloc_head() -- kmalloc'd
>> skbs shouldn't be marked for PP recycling.
> 
> Thanks for the acks, Olek!
> 
> I think we need to keep the mark here. A head from kmalloc can still
> carry pp frags from xdp_copy_frags_from_zc(). pp_recycle applies to
> those frags too, so marking only the pp head would make the kmalloc case
> bypass the pp release path.
> 
> The mark does not change how the head is freed. __alloc_skb() leaves
> head_frag clear, so skb_free_head() calls kfree() without checking
> pp_recycle.

Ack, I completely forgot about the frags =\

Thanks,
Olek

Reply via email to