From: Simon Horman <simon.horman@corigine.com>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
Lorenzo Bianconi <lorenzo@kernel.org>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
bpf@vger.kernel.org
Subject: Re: [PATCH net-next v1 1/2] net: introduce and use skb_frag_fill_page_desc()
Date: Wed, 10 May 2023 10:40:50 +0200 [thread overview]
Message-ID: <ZFtYkmvQ01YxHf9s@corigine.com> (raw)
In-Reply-To: <20230509114146.20962-2-linyunsheng@huawei.com>
+ XDP people and ML
On Tue, May 09, 2023 at 07:41:45PM +0800, Yunsheng Lin wrote:
> Most users use __skb_frag_set_page()/skb_frag_off_set()/
> skb_frag_size_set() to fill the page desc for a skb frag.
>
> Introduce skb_frag_fill_page_desc() to do that.
>
> net/bpf/test_run.c does not call skb_frag_off_set() to
> set the offset, "copy_from_user(page_address(page), ...)"
> suggest that it is assuming offset to be initialized as
> zero, so call skb_frag_fill_page_desc() with offset being
> zero for this case.
I think the question is, what is the value of bv_offset before this patch.
Lorenzo and Stanislav, do you have any insight here?
>
> Also, skb_frag_set_page() is not used anymore, so remove
> it.
>
> Signed-off-by: Yunsheng Lin <linyunsheng@huawei.com>
...
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 738776ab8838..30be21c7d05f 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2411,6 +2411,15 @@ static inline unsigned int skb_pagelen(const struct sk_buff *skb)
> return skb_headlen(skb) + __skb_pagelen(skb);
> }
>
> +static inline void skb_frag_fill_page_desc(skb_frag_t *frag,
> + struct page *page,
> + int off, int size)
> +{
> + frag->bv_page = page;
> + frag->bv_offset = off;
Maybe it is slightly nicer to use skb_frag_off_set() here.
> + skb_frag_size_set(frag, size);
> +}
> +
> static inline void __skb_fill_page_desc_noacc(struct skb_shared_info *shinfo,
> int i, struct page *page,
> int off, int size)
> @@ -2422,9 +2431,7 @@ static inline void __skb_fill_page_desc_noacc(struct skb_shared_info *shinfo,
> * that not all callers have unique ownership of the page but rely
> * on page_is_pfmemalloc doing the right thing(tm).
> */
> - frag->bv_page = page;
> - frag->bv_offset = off;
> - skb_frag_size_set(frag, size);
> + skb_frag_fill_page_desc(frag, page, off, size);
> }
>
> /**
> @@ -3496,20 +3503,6 @@ static inline void __skb_frag_set_page(skb_frag_t *frag, struct page *page)
> frag->bv_page = page;
> }
>
> -/**
> - * skb_frag_set_page - sets the page contained in a paged fragment of an skb
> - * @skb: the buffer
> - * @f: the fragment offset
> - * @page: the page to set
> - *
> - * Sets the @f'th fragment of @skb to contain @page.
> - */
> -static inline void skb_frag_set_page(struct sk_buff *skb, int f,
> - struct page *page)
> -{
> - __skb_frag_set_page(&skb_shinfo(skb)->frags[f], page);
> -}
> -
> bool skb_page_frag_refill(unsigned int sz, struct page_frag *pfrag, gfp_t prio);
>
> /**
> diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c
> index e79e3a415ca9..98143b86a9dd 100644
> --- a/net/bpf/test_run.c
> +++ b/net/bpf/test_run.c
> @@ -1415,11 +1415,10 @@ int bpf_prog_test_run_xdp(struct bpf_prog *prog, const union bpf_attr *kattr,
> }
>
> frag = &sinfo->frags[sinfo->nr_frags++];
> - __skb_frag_set_page(frag, page);
>
> data_len = min_t(u32, kattr->test.data_size_in - size,
> PAGE_SIZE);
> - skb_frag_size_set(frag, data_len);
> + skb_frag_fill_page_desc(frag, page, 0, data_len);
>
> if (copy_from_user(page_address(page), data_in + size,
> data_len)) {
next parent reply other threads:[~2023-05-10 8:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230509114146.20962-1-linyunsheng@huawei.com>
[not found] ` <20230509114146.20962-2-linyunsheng@huawei.com>
2023-05-10 8:40 ` Simon Horman [this message]
2023-05-10 12:07 ` [PATCH net-next v1 1/2] net: introduce and use skb_frag_fill_page_desc() Yunsheng Lin
2023-05-10 13:02 ` Simon Horman
2023-05-10 14:27 ` Stanislav Fomichev
2023-05-10 14:46 ` Simon Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZFtYkmvQ01YxHf9s@corigine.com \
--to=simon.horman@corigine.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linyunsheng@huawei.com \
--cc=lorenzo@kernel.org \
--cc=martin.lau@linux.dev \
--cc=pabeni@redhat.com \
--cc=sdf@google.com \
--cc=song@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox