Message ID | 20231113130041.58124-5-linyunsheng@huawei.com (mailing list archive) |
---|---|
State | RFC |
Headers | show |
Series | A possible proposal for intergating dmabuf to page pool | expand |
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 27998f73183e..3e2f806c8ed8 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2423,6 +2423,14 @@ static inline void skb_frag_fill_page_desc(skb_frag_t *frag, struct page *page, int off, int size) { + /* expect head page for compound page */ + if (WARN_ON_ONCE(PageTail(page))) { + struct page *head = compound_head(page); + + off += (page_to_pfn(page) - page_to_pfn(head)) * PAGE_SIZE; + page = head; + } + frag->bv_page = page; frag->bv_offset = off; skb_frag_size_set(frag, size);
As we have ensured that the page and the offset to the page for the skb frag is passed togetherly in one function call, see [1], make it explicit that skb_frag_fill_page_desc() expect a base page or head page for a compound page, so that we can avoid the compound_head() in the net stack. Log a warning if the caller passes a tail page of compoud page and adjust 'page' to point to it's head page and 'offset' to point to start of it's head page. The warning can be removed if we have ensured all the caller is passing non tail page to skb_frag_fill_page_desc() in the future. 1. https://lore.kernel.org/all/20230511011213.59091-2-linyunsheng@huawei.com/ Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com> --- include/linux/skbuff.h | 8 ++++++++ 1 file changed, 8 insertions(+)