diff mbox series

[net-next,v10,01/22] net: make page_pool_ref_netmem work with net iovs

Message ID 20250108220644.3528845-2-dw@davidwei.uk (mailing list archive)
State New
Headers show
Series io_uring zero copy rx | expand

Commit Message

David Wei Jan. 8, 2025, 10:06 p.m. UTC
From: Pavel Begunkov <asml.silence@gmail.com>

page_pool_ref_netmem() should work with either netmem representation, but
currently it casts to a page with netmem_to_page(), which will fail with
net iovs. Use netmem_get_pp_ref_count_ref() instead.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: David Wei <dw@davidwei.uk>
---
 include/net/page_pool/helpers.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Jan. 16, 2025, 12:30 a.m. UTC | #1
On Wed,  8 Jan 2025 14:06:22 -0800 David Wei wrote:
> From: Pavel Begunkov <asml.silence@gmail.com>
> 
> page_pool_ref_netmem() should work with either netmem representation, but
> currently it casts to a page with netmem_to_page(), which will fail with
> net iovs. Use netmem_get_pp_ref_count_ref() instead.

This is a fix, right? If we try to coalesce a cloned netmem skb 
we'll crash.
Pavel Begunkov Jan. 16, 2025, 2:12 a.m. UTC | #2
On 1/16/25 00:30, Jakub Kicinski wrote:
> On Wed,  8 Jan 2025 14:06:22 -0800 David Wei wrote:
>> From: Pavel Begunkov <asml.silence@gmail.com>
>>
>> page_pool_ref_netmem() should work with either netmem representation, but
>> currently it casts to a page with netmem_to_page(), which will fail with
>> net iovs. Use netmem_get_pp_ref_count_ref() instead.
> 
> This is a fix, right? If we try to coalesce a cloned netmem skb
> we'll crash.

True, I missed it it's actually used.
Jakub Kicinski Jan. 16, 2025, 2:48 a.m. UTC | #3
On Thu, 16 Jan 2025 02:12:06 +0000 Pavel Begunkov wrote:
> On 1/16/25 00:30, Jakub Kicinski wrote:
> > On Wed,  8 Jan 2025 14:06:22 -0800 David Wei wrote:  
> >> From: Pavel Begunkov <asml.silence@gmail.com>
> >>
> >> page_pool_ref_netmem() should work with either netmem representation, but
> >> currently it casts to a page with netmem_to_page(), which will fail with
> >> net iovs. Use netmem_get_pp_ref_count_ref() instead.  
> > 
> > This is a fix, right? If we try to coalesce a cloned netmem skb
> > we'll crash.  
> 
> True, I missed it it's actually used.

I'll add:

Fixes: 8ab79ed50cf1 ("page_pool: devmem support")

and we'll send it to Linus tomorrow. Hope that's okay.
Pavel Begunkov Jan. 16, 2025, 4:45 p.m. UTC | #4
On 1/16/25 02:48, Jakub Kicinski wrote:
> On Thu, 16 Jan 2025 02:12:06 +0000 Pavel Begunkov wrote:
>> On 1/16/25 00:30, Jakub Kicinski wrote:
>>> On Wed,  8 Jan 2025 14:06:22 -0800 David Wei wrote:
>>>> From: Pavel Begunkov <asml.silence@gmail.com>
>>>>
>>>> page_pool_ref_netmem() should work with either netmem representation, but
>>>> currently it casts to a page with netmem_to_page(), which will fail with
>>>> net iovs. Use netmem_get_pp_ref_count_ref() instead.
>>>
>>> This is a fix, right? If we try to coalesce a cloned netmem skb
>>> we'll crash.
>>
>> True, I missed it it's actually used.
> 
> I'll add:
> 
> Fixes: 8ab79ed50cf1 ("page_pool: devmem support")
> 
> and we'll send it to Linus tomorrow. Hope that's okay.

Sounds good to me
diff mbox series

Patch

diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h
index 543f54fa3020..582a3d00cbe2 100644
--- a/include/net/page_pool/helpers.h
+++ b/include/net/page_pool/helpers.h
@@ -307,7 +307,7 @@  static inline long page_pool_unref_page(struct page *page, long nr)
 
 static inline void page_pool_ref_netmem(netmem_ref netmem)
 {
-	atomic_long_inc(&netmem_to_page(netmem)->pp_ref_count);
+	atomic_long_inc(netmem_get_pp_ref_count_ref(netmem));
 }
 
 static inline void page_pool_ref_page(struct page *page)