From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: "David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Jason A. Donenfeld" <Jason@zx2c4.com>
Subject: [PATCH] sock: honor GFP_ATOMIC when allocating send skbs
Date: Mon, 29 Jun 2015 15:06:56 +0200 [thread overview]
Message-ID: <1435583216-19877-1-git-send-email-Jason@zx2c4.com> (raw)
Some sockets set sock->sk->sk_allocation = GFP_ATOMIC. In spite of this,
functions that call sock_alloc_send_skb will then call
sock_alloc_send_pskb, which very often results in sleeping. Since the
intention of callers setting sk_allocation = GFP_ATOMIC might be to be
able to send from atomic context, we need to honor this and not sleep.
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
---
net/core/sock.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/core/sock.c b/net/core/sock.c
index 1e1fe9a..f00e691 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -1804,34 +1804,37 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
unsigned long data_len, int noblock,
int *errcode, int max_page_order)
{
struct sk_buff *skb;
long timeo;
int err;
timeo = sock_sndtimeo(sk, noblock);
for (;;) {
err = sock_error(sk);
if (err != 0)
goto failure;
err = -EPIPE;
if (sk->sk_shutdown & SEND_SHUTDOWN)
goto failure;
+ if (sk->sk_allocation & GFP_ATOMIC)
+ break;
+
if (sk_wmem_alloc_get(sk) < sk->sk_sndbuf)
break;
set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags);
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
err = -EAGAIN;
if (!timeo)
goto failure;
if (signal_pending(current))
goto interrupted;
timeo = sock_wait_for_wmem(sk, timeo);
}
skb = alloc_skb_with_frags(header_len, data_len, max_page_order,
errcode, sk->sk_allocation);
if (skb)
skb_set_owner_w(skb, sk);
return skb;
--
2.4.2
next reply other threads:[~2015-06-29 13:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-29 13:06 Jason A. Donenfeld [this message]
2015-06-29 13:36 ` Eric Dumazet
2015-06-29 14:00 ` Jason A. Donenfeld
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=1435583216-19877-1-git-send-email-Jason@zx2c4.com \
--to=jason@zx2c4.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--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
all inboxes | Powered by JetHome®