From: bot+bpf-ci@kernel.org
To: zirajs7@gmail.com,john.fastabend@gmail.com,jakub@cloudflare.com,jiayuan.chen@linux.dev
Cc: davem@davemloft.net,edumazet@google.com,kuba@kernel.org,pabeni@redhat.com,horms@kernel.org,andrii@kernel.org,eddyz87@gmail.com,linux-kernel@vger.kernel.org,bpf@vger.kernel.org,netdev@vger.kernel.org,rhkrqnwk98@gmail.com,daniel@iogearbox.net,emil@etsalapatis.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf v3 1/2] bpf, sockmap: settle sk_forward_alloc for strparser SK_PASS
Date: Mon, 17 Aug 2026 17:13:13 +0000 (UTC) [thread overview]
Message-ID: <254f3972f477e13f89ac620d447750799144c889188ddd6de1bb9bd9e2f34039@mail.kernel.org> (raw)
In-Reply-To: <20260817155009.232670-2-zirajs7@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4936 bytes --]
> diff --git a/net/core/skmsg.c b/net/core/skmsg.c
> index 2521b643fa05..347cb168f749 100644
> --- a/net/core/skmsg.c
> +++ b/net/core/skmsg.c
> @@ -586,21 +586,24 @@ static int sk_psock_skb_ingress_enqueue(struct sk_buff *skb,
> }
>
> static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,
> - u32 off, u32 len, bool take_ref);
> + u32 off, u32 len, bool take_ref,
> + bool settle_fwd_alloc);
> +static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
> + struct sk_buff *skb,
> + u32 off, u32 len, bool take_ref,
> + bool settle_fwd_alloc);
The forward declaration of sk_psock_skb_ingress_self() at line 588 is
now dead code. Before the commit, sk_psock_skb_ingress() (defined at
line 596) called it for the skb->sk == psock->sk case, which required
the forward declaration. This commit redirects that call site to
sk_psock_skb_ingress_self_backlog() instead. The only remaining caller
is sk_psock_verdict_apply(), which is well after the definition. Should
this prototype be removed?
[ ... ]
> @@ -618,34 +621,100 @@ static int sk_psock_skb_ingress(struct sk_psock *psock, struct sk_buff *skb,
> return err;
> }
>
> -/* Puts an skb on the ingress queue of the socket already assigned to the
> - * skb. In this case we do not need to check memory limits or skb_set_owner_r
> - * because the skb is already accounted for here.
> +static int sk_psock_skb_ingress_self_assign(struct sock *sk,
> + struct sk_buff *skb,
> + bool settle_fwd_alloc)
> +{
> + /* Leave skbs already receive-accounted to sk untouched. */
> + if (skb->sk == sk && skb->destructor == sock_rfree)
> + return 0;
> +
> + if (settle_fwd_alloc) {
> + sock_owned_by_me(sk);
> +
> + if (!sk_rmem_schedule(sk, skb, 0))
> + return -EAGAIN;
> + }
> +
> + skb_set_owner_r(skb, sk);
> + return 0;
> +}
> +
> +/* Puts an skb on the ingress queue for psock->sk.
> + *
> + * If the skb already has receive ownership for this socket, leave socket
> + * memory accounting untouched. Otherwise, before assigning receive ownership
> + * to an unowned strparser SK_PASS skb, settle any existing sk_forward_alloc
> + * deficit from earlier clone charges.
> */
> static int sk_psock_skb_ingress_self(struct sk_psock *psock, struct sk_buff *skb,
> - u32 off, u32 len, bool take_ref)
> + u32 off, u32 len, bool take_ref,
> + bool settle_fwd_alloc)
> {
> + struct sock *sk = psock->sk;
> struct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);
> + int err;
> +
> + if (unlikely(!msg))
> + return -EAGAIN;
> +
> + err = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);
> + if (err)
> + goto free;
> +
> + /* This is used in tcp_bpf_recvmsg_parser() to determine whether the
> + * data originates from the socket's own protocol stack. No need to
> + * refcount sk because msg's lifetime is bound to sk via the ingress_msg.
> + */
> + msg->sk = sk;
> + err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,
> + take_ref);
> + if (err < 0)
> + goto free;
> +
> + return err;
> +free:
> + kfree(msg);
> + return err;
> +}
> +
> +static int sk_psock_skb_ingress_self_backlog(struct sk_psock *psock,
> + struct sk_buff *skb,
> + u32 off, u32 len, bool take_ref,
> + bool settle_fwd_alloc)
> +{
> struct sock *sk = psock->sk;
> + struct sk_msg *msg = alloc_sk_msg(GFP_ATOMIC);
> int err;
>
> if (unlikely(!msg))
> return -EAGAIN;
> - skb_set_owner_r(skb, sk);
> +
> + lock_sock(sk);
> + err = sk_psock_skb_ingress_self_assign(sk, skb, settle_fwd_alloc);
> + release_sock(sk);
> + if (err)
> + goto free;
>
> /* This is used in tcp_bpf_recvmsg_parser() to determine whether the
> * data originates from the socket's own protocol stack. No need to
> * refcount sk because msg's lifetime is bound to sk via the ingress_msg.
> */
> msg->sk = sk;
> - err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg, take_ref);
> + err = sk_psock_skb_ingress_enqueue(skb, off, len, psock, sk, msg,
> + take_ref);
> if (err < 0)
> - kfree(msg);
> + goto free;
> +
> + return err;
> +free:
> + kfree(msg);
> return err;
> }
Is GFP_ATOMIC necessary in sk_psock_skb_ingress_self_backlog()? The
function is only called from sk_psock_backlog(), which is the psock
backlog worker running in plain process context - the lock_sock() call
proves it can sleep. Before this commit, these same skbs were allocated
by sk_psock_create_ingress_msg() with alloc_sk_msg(GFP_KERNEL). Would
GFP_KERNEL be more appropriate here to avoid draining atomic reserves
and reduce the chance of allocation failure under memory pressure?
[ ... ]
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/32045036810
next prev parent reply other threads:[~2026-08-17 17:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 15:50 [PATCH bpf v3 0/2] bpf, sockmap: fix forward allocation accounting in strparser self-pass path Junseo Lim
2026-08-17 15:50 ` [PATCH bpf v3 1/2] bpf, sockmap: settle sk_forward_alloc for strparser SK_PASS Junseo Lim
2026-08-17 17:13 ` bot+bpf-ci [this message]
2026-08-17 15:50 ` [PATCH bpf v3 2/2] selftests/bpf: Cover strparser self-pass forward allocation Junseo Lim
2026-08-17 16:52 ` bot+bpf-ci
2026-09-02 8:40 ` Emil Tsalapatis
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=254f3972f477e13f89ac620d447750799144c889188ddd6de1bb9bd9e2f34039@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=edumazet@google.com \
--cc=emil@etsalapatis.com \
--cc=horms@kernel.org \
--cc=ihor.solodrai@linux.dev \
--cc=jakub@cloudflare.com \
--cc=jiayuan.chen@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rhkrqnwk98@gmail.com \
--cc=yonghong.song@linux.dev \
--cc=zirajs7@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®