lkml.org 
[lkml]   [2023]   [Nov]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC PATCH v3 08/12] net: support non paged skb frags
From
Date
On 2023/11/6 10:44, Mina Almasry wrote:
> Make skb_frag_page() fail in the case where the frag is not backed
> by a page, and fix its relevent callers to handle this case.
>
> Correctly handle skb_frag refcounting in the page_pool_iovs case.
>
> Signed-off-by: Mina Almasry <almasrymina@google.com>
>

...

> /**
> * skb_frag_page - retrieve the page referred to by a paged fragment
> * @frag: the paged fragment
> *
> - * Returns the &struct page associated with @frag.
> + * Returns the &struct page associated with @frag. Returns NULL if this frag
> + * has no associated page.
> */
> static inline struct page *skb_frag_page(const skb_frag_t *frag)
> {
> - return frag->bv_page;
> + if (!page_is_page_pool_iov(frag->bv_page))
> + return frag->bv_page;
> +
> + return NULL;

It seems most of callers don't expect NULL returning for skb_frag_page(),
and this patch only changes a few relevant callers to handle the NULL case.

It may make more sense to add a new helper to do the above checking, and
add a warning in skb_frag_page() to catch any missing NULL checking for
skb_frag_page() caller, something like below?

static inline struct page *skb_frag_page(const skb_frag_t *frag)
{
- return frag->bv_page;
+ struct page *page = frag->bv_page;
+
+ BUG_ON(page_is_page_pool_iov(page));
+
+ return page;
+}
+
+static inline struct page *skb_frag_readable_page(const skb_frag_t *frag)
+{
+ struct page *page = frag->bv_page;
+
+ if (!page_is_page_pool_iov(page))
+ return page;
+
+ return NULL;
}


\
 
 \ /
  Last update: 2023-11-20 13:51    [W:0.405 / U:0.828 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site