From: Paolo Abeni <pabeni@redhat.com>
To: Benjamin Coddington <bcodding@redhat.com>, netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>
Subject: Re: [PATCH v1 3/3] net: simplify sk_page_frag
Date: Fri, 09 Dec 2022 17:44:25 +0100 [thread overview]
Message-ID: <59973b017cbd927b69d24f32cbac15f8245cc29c.camel@redhat.com> (raw)
In-Reply-To: <79b1009812b753c3a82d09271c4d655d644d37a6.1669036433.git.bcodding@redhat.com>
On Mon, 2022-11-21 at 08:35 -0500, Benjamin Coddington wrote:
> Now that in-kernel socket users that may recurse during reclaim have benn
> converted to sk_use_task_frag = false, we can have sk_page_frag() simply
> check that value.
>
> Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
> ---
> include/net/sock.h | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/include/net/sock.h b/include/net/sock.h
> index ffba9e95470d..fac24c6ee30d 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -2539,19 +2539,14 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
> * Both direct reclaim and page faults can nest inside other
> * socket operations and end up recursing into sk_page_frag()
> * while it's already in use: explicitly avoid task page_frag
> - * usage if the caller is potentially doing any of them.
> - * This assumes that page fault handlers use the GFP_NOFS flags or
> - * explicitly disable sk_use_task_frag.
> + * when users disable sk_use_task_frag.
> *
> * Return: a per task page_frag if context allows that,
> * otherwise a per socket one.
> */
> static inline struct page_frag *sk_page_frag(struct sock *sk)
> {
> - if (sk->sk_use_task_frag &&
> - (sk->sk_allocation & (__GFP_DIRECT_RECLAIM | __GFP_MEMALLOC |
> - __GFP_FS)) ==
> - (__GFP_DIRECT_RECLAIM | __GFP_FS))
> + if (sk->sk_use_task_frag)
> return ¤t->task_frag;
>
> return &sk->sk_frag;
To make the above as safe as possible I think we should double-check
the in-kernel users explicitly setting sk_allocation to GFP_ATOMIC, as
that has the side effect of disabling the task_frag usage, too.
Patch 2/3 already catches some of such users, and we can safely leave
alone few others, (specifically l2tp, fou and inet_ctl_sock_create()).
Even wireguard and tls looks safe IMHO.
So the only left-over should be espintcp, I suggest updating patch 2/3
clearing sk_use_task_frag even in espintcp_init_sk().
Other than that LGTM.
Cheers,
Paolo
next prev parent reply other threads:[~2022-12-09 16:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 13:35 [PATCH v1 0/3] Stop corrupting socket's task_frag Benjamin Coddington
2022-11-21 13:35 ` [PATCH v1 1/3] net: Introduce sk_use_task_frag in struct sock Benjamin Coddington
2022-12-09 12:09 ` Paolo Abeni
2022-12-09 14:16 ` Eric Dumazet
2022-11-21 13:35 ` [PATCH v1 2/3] Treewide: Stop corrupting socket's task_frag Benjamin Coddington
2022-11-29 14:02 ` Christoph Hellwig
2022-11-29 16:47 ` Benjamin Coddington
2022-11-30 12:07 ` Guillaume Nault
2022-11-29 17:42 ` Jeff Layton
2022-11-30 11:48 ` Guillaume Nault
2022-12-09 12:37 ` Paolo Abeni
2022-12-09 16:11 ` Jakub Kicinski
2022-12-09 16:50 ` Paolo Abeni
2022-11-21 13:35 ` [PATCH v1 3/3] net: simplify sk_page_frag Benjamin Coddington
2022-12-09 16:42 ` Paolo Abeni
2022-12-09 16:44 ` Paolo Abeni [this message]
2022-12-09 16:44 ` Paolo Abeni
2022-11-21 13:56 ` [PATCH v1 2/3] Treewide: Stop corrupting socket's task_frag David Howells
2022-11-21 14:34 ` Benjamin Coddington
2022-11-21 21:40 ` Shuah Khan
2022-11-21 21:43 ` Shuah Khan
2022-11-21 22:01 ` Benjamin Coddington
2022-11-21 22:32 ` Shuah Khan
2022-11-22 14:23 ` Benjamin Coddington
2022-12-07 11:44 ` [PATCH v1 0/3] " Benjamin Coddington
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=59973b017cbd927b69d24f32cbac15f8245cc29c.camel@redhat.com \
--to=pabeni@redhat.com \
--cc=bcodding@redhat.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).