From: Joe Damato <jdamato@fastly.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, kuba@kernel.org, Joe Damato <jdamato@fastly.com>
Subject: [PATCH net-next] sock: add sndbuff full perf trace event
Date: Thu, 20 Jan 2022 14:02:30 -0800 [thread overview]
Message-ID: <1642716150-100589-1-git-send-email-jdamato@fastly.com> (raw)
Calls to sock_alloc_send_pskb can fail or trigger a wait if there is no
sndbuf space available.
Add a perf trace event to help users monitor when and how this occurs so
appropriate application level changes can be made, if necessary.
Signed-off-by: Joe Damato <jdamato@fastly.com>
---
include/trace/events/sock.h | 21 +++++++++++++++++++++
net/core/sock.c | 1 +
2 files changed, 22 insertions(+)
diff --git a/include/trace/events/sock.h b/include/trace/events/sock.h
index 12c3157..de6f6a7 100644
--- a/include/trace/events/sock.h
+++ b/include/trace/events/sock.h
@@ -68,6 +68,27 @@ skmem_kind_names
#define show_skmem_kind_names(val) \
__print_symbolic(val, skmem_kind_names)
+TRACE_EVENT(sock_sndbuf_full,
+ TP_PROTO(struct sock *sk, long timeo),
+
+ TP_ARGS(sk, timeo),
+
+ TP_STRUCT__entry(
+ __field(int, wmem_alloc)
+ __field(int, sk_sndbuf)
+ __field(long, timeo)
+ ),
+
+ TP_fast_assign(
+ __entry->wmem_alloc = refcount_read(&sk->sk_wmem_alloc);
+ __entry->sk_sndbuf = READ_ONCE(sk->sk_sndbuf);
+ __entry->timeo = timeo;
+ ),
+
+ TP_printk("wmem_alloc=%d sk_sndbf=%d timeo=%ld",
+ __entry->wmem_alloc, __entry->sk_sndbuf, __entry->timeo)
+);
+
TRACE_EVENT(sock_rcvqueue_full,
TP_PROTO(struct sock *sk, struct sk_buff *skb),
diff --git a/net/core/sock.c b/net/core/sock.c
index e21485a..674627c 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -2571,6 +2571,7 @@ struct sk_buff *sock_alloc_send_pskb(struct sock *sk, unsigned long header_len,
sk_set_bit(SOCKWQ_ASYNC_NOSPACE, sk);
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
+ trace_sock_sndbuf_full(sk, timeo);
err = -EAGAIN;
if (!timeo)
goto failure;
--
2.7.4
next reply other threads:[~2022-01-20 22:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-20 22:02 Joe Damato [this message]
2022-01-23 20:17 ` [PATCH net-next] sock: add sndbuff full perf trace event Cong Wang
2022-01-25 19:51 ` Joe Damato
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=1642716150-100589-1-git-send-email-jdamato@fastly.com \
--to=jdamato@fastly.com \
--cc=davem@davemloft.net \
--cc=kuba@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