From: Paolo Abeni <pabeni@redhat.com>
To: Yunsheng Lin <linyunsheng@huawei.com>,
davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexander Duyck <alexander.duyck@gmail.com>,
Ayush Sawal <ayush.sawal@chelsio.com>,
Eric Dumazet <edumazet@google.com>,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Jason Wang <jasowang@redhat.com>, Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Vincent Guittot <vincent.guittot@linaro.org>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
Ben Segall <bsegall@google.com>, Mel Gorman <mgorman@suse.de>,
Valentin Schneider <vschneid@redhat.com>,
John Fastabend <john.fastabend@gmail.com>,
Jakub Sitnicki <jakub@cloudflare.com>,
David Ahern <dsahern@kernel.org>,
Matthieu Baerts <matttbe@kernel.org>,
Mat Martineau <martineau@kernel.org>,
Geliang Tang <geliang@kernel.org>,
Jamal Hadi Salim <jhs@mojatatu.com>,
Cong Wang <xiyou.wangcong@gmail.com>,
Jiri Pirko <jiri@resnulli.us>, Boris Pismenny <borisp@nvidia.com>,
bpf@vger.kernel.org, mptcp@lists.linux.dev
Subject: Re: [PATCH net-next v18 12/14] net: replace page_frag with page_frag_cache
Date: Tue, 10 Sep 2024 16:04:05 +0200 [thread overview]
Message-ID: <1884e171-cc87-4238-abd1-0f6be1e0b279@redhat.com> (raw)
In-Reply-To: <20240906073646.2930809-13-linyunsheng@huawei.com>
On 9/6/24 09:36, Yunsheng Lin wrote:
> diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
> index 49811c9281d4..6190d9bfd618 100644
> --- a/net/ipv4/ip_output.c
> +++ b/net/ipv4/ip_output.c
> @@ -953,7 +953,7 @@ static int __ip_append_data(struct sock *sk,
> struct flowi4 *fl4,
> struct sk_buff_head *queue,
> struct inet_cork *cork,
> - struct page_frag *pfrag,
> + struct page_frag_cache *nc,
> int getfrag(void *from, char *to, int offset,
> int len, int odd, struct sk_buff *skb),
> void *from, int length, int transhdrlen,
> @@ -1228,13 +1228,19 @@ static int __ip_append_data(struct sock *sk,
> copy = err;
> wmem_alloc_delta += copy;
> } else if (!zc) {
> + struct page_frag page_frag, *pfrag;
> int i = skb_shinfo(skb)->nr_frags;
> + void *va;
>
> err = -ENOMEM;
> - if (!sk_page_frag_refill(sk, pfrag))
> + pfrag = &page_frag;
> + va = sk_page_frag_alloc_refill_prepare(sk, nc, pfrag);
> + if (!va)
> goto error;
>
> skb_zcopy_downgrade_managed(skb);
> + copy = min_t(int, copy, pfrag->size);
> +
> if (!skb_can_coalesce(skb, i, pfrag->page,
> pfrag->offset)) {
> err = -EMSGSIZE;
> @@ -1242,18 +1248,18 @@ static int __ip_append_data(struct sock *sk,
> goto error;
>
> __skb_fill_page_desc(skb, i, pfrag->page,
> - pfrag->offset, 0);
> + pfrag->offset, copy);
> skb_shinfo(skb)->nr_frags = ++i;
> - get_page(pfrag->page);
> + page_frag_commit(nc, pfrag, copy);
> + } else {
> + skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1],
> + copy);
> + page_frag_commit_noref(nc, pfrag, copy);
> }
> - copy = min_t(int, copy, pfrag->size - pfrag->offset);
> - if (getfrag(from,
> - page_address(pfrag->page) + pfrag->offset,
> - offset, copy, skb->len, skb) < 0)
> +
> + if (getfrag(from, va, offset, copy, skb->len, skb) < 0)
> goto error_efault;
Should the 'commit' happen only when 'getfrag' is successful?
Similar question in the ipv6 code.
Thanks,
Paolo
next prev parent reply other threads:[~2024-09-10 14:04 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-06 7:36 [PATCH net-next v18 00/14] Replace page_frag with page_frag_cache for sk_page_frag() Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 01/14] mm: page_frag: add a test module for page_frag Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 02/14] mm: move the page fragment allocator from page_alloc into its own file Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 03/14] mm: page_frag: use initial zero offset for page_frag_alloc_align() Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 04/14] mm: page_frag: avoid caller accessing 'page_frag_cache' directly Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 05/14] xtensa: remove the get_order() implementation Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 06/14] mm: page_frag: reuse existing space for 'size' and 'pfmemalloc' Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 07/14] mm: page_frag: some minor refactoring before adding new API Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 08/14] mm: page_frag: use __alloc_pages() to replace alloc_pages_node() Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 09/14] net: rename skb_copy_to_page_nocache() helper Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 10/14] mm: page_frag: introduce prepare/probe/commit API Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 11/14] mm: page_frag: add testing for the newly added prepare API Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 12/14] net: replace page_frag with page_frag_cache Yunsheng Lin
2024-09-10 14:04 ` Paolo Abeni [this message]
2024-09-11 11:31 ` Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 13/14] mm: page_frag: update documentation for page_frag Yunsheng Lin
2024-09-06 7:36 ` [PATCH net-next v18 14/14] mm: page_frag: add an entry in MAINTAINERS " Yunsheng Lin
2024-09-10 15:11 ` [PATCH net-next v18 00/14] Replace page_frag with page_frag_cache for sk_page_frag() Jakub Kicinski
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=1884e171-cc87-4238-abd1-0f6be1e0b279@redhat.com \
--to=pabeni@redhat.com \
--cc=alexander.duyck@gmail.com \
--cc=ayush.sawal@chelsio.com \
--cc=borisp@nvidia.com \
--cc=bpf@vger.kernel.org \
--cc=bsegall@google.com \
--cc=davem@davemloft.net \
--cc=dietmar.eggemann@arm.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=jakub@cloudflare.com \
--cc=jasowang@redhat.com \
--cc=jhs@mojatatu.com \
--cc=jiri@resnulli.us \
--cc=john.fastabend@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linyunsheng@huawei.com \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=xiyou.wangcong@gmail.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
all inboxes | Powered by JetHome®