From: John Fastabend <john.fastabend@gmail.com>
To: Eric Dumazet <edumazet@google.com>, Liu Jian <liujian56@huawei.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
john.fastabend@gmail.com, jakub@cloudflare.com,
dsahern@kernel.org, ast@kernel.org, daniel@iogearbox.net,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf 1/2] net: introduce __sk_rmem_schedule() helper
Date: Thu, 27 Jul 2023 12:16:02 -0700 [thread overview]
Message-ID: <64c2c272c111_831d20880@john.notmuch> (raw)
In-Reply-To: <CANn89i+DuhGRXj9U-iXcEA__j6jvV5FC+tLNkGBCSqMCPpuFaA@mail.gmail.com>
Eric Dumazet wrote:
> On Wed, Jul 26, 2023 at 4:15 PM Liu Jian <liujian56@huawei.com> wrote:
> >
> > Compared with sk_wmem_schedule(), sk_rmem_schedule() not only performs
> > rmem accounting, but also checks skb_pfmemalloc. The __sk_rmem_schedule()
> > helper function is introduced here to perform only rmem accounting related
> > activities.
> >
>
> Why not care about pfmemalloc ? Why is it safe ?
>
> You need to give more details, or simply reuse the existing helper.
I would just use the existing helper. Seems it should be fine.
>
> > Signed-off-by: Liu Jian <liujian56@huawei.com>
> > ---
> > include/net/sock.h | 12 ++++++++----
> > 1 file changed, 8 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/net/sock.h b/include/net/sock.h
> > index 2eb916d1ff64..58bf26c5c041 100644
> > --- a/include/net/sock.h
> > +++ b/include/net/sock.h
> > @@ -1617,16 +1617,20 @@ static inline bool sk_wmem_schedule(struct sock *sk, int size)
> > return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_SEND);
> > }
> >
> > -static inline bool
> > -sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
> > +static inline bool __sk_rmem_schedule(struct sock *sk, int size)
> > {
> > int delta;
> >
> > if (!sk_has_account(sk))
> > return true;
> > delta = size - sk->sk_forward_alloc;
> > - return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_RECV) ||
> > - skb_pfmemalloc(skb);
> > + return delta <= 0 || __sk_mem_schedule(sk, delta, SK_MEM_RECV);
> > +}
> > +
> > +static inline bool
> > +sk_rmem_schedule(struct sock *sk, struct sk_buff *skb, int size)
> > +{
> > + return __sk_rmem_schedule(sk, size) || skb_pfmemalloc(skb);
> > }
> >
> > static inline int sk_unused_reserved_mem(const struct sock *sk)
> > --
> > 2.34.1
> >
next prev parent reply other threads:[~2023-07-27 19:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-26 14:20 [PATCH bpf 0/2] fix rmem incorrect accounting in bpf_tcp_ingress() Liu Jian
2023-07-26 14:20 ` [PATCH bpf 1/2] net: introduce __sk_rmem_schedule() helper Liu Jian
2023-07-26 14:25 ` Eric Dumazet
2023-07-27 19:16 ` John Fastabend [this message]
2023-07-28 12:36 ` liujian (CE)
2023-07-26 14:20 ` [PATCH bpf 2/2] bpf, sockmap: fix rmem incorrect accounting in bpf_tcp_ingress() Liu Jian
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=64c2c272c111_831d20880@john.notmuch \
--to=john.fastabend@gmail.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=jakub@cloudflare.com \
--cc=kuba@kernel.org \
--cc=liujian56@huawei.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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