From: Willem de Bruijn <willemb@google.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, eric.dumazet@gmail.com,
richardcochran@gmail.com, Willem de Bruijn <willemb@google.com>
Subject: [PATCH net-next] net-timestamp: optimize sock_tx_timestamp default path
Date: Mon, 8 Sep 2014 19:27:04 -0400 [thread overview]
Message-ID: <1410218824-18296-1-git-send-email-willemb@google.com> (raw)
Few packets have timestamping enabled. Exit sock_tx_timestamp quickly
in this common case.
Packets are only possibly timestamped if one of
SOF_TIMESTAMPING_(SOFTWARE|RAW_HARDWARE) is enabled.
Signed-off-by: Willem de Bruijn <willemb@google.com>
----
I have one more short timestamping patch after this, to remove
SOCK_TIMESTAMPING_RX_SOFTWARE and simplify the receive timestamp
path a bit. I have not forgotten about the timestamp cookies: once
these smaller changes are in, I'll take another look at that. It
is a more complex change, and I didn't want to block these in the
meantime.
---
include/net/sock.h | 8 +++++++-
net/socket.c | 4 ++--
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/include/net/sock.h b/include/net/sock.h
index 049ab1b..245136e 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2199,6 +2199,8 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
sk->sk_stamp = skb->tstamp;
}
+void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags);
+
/**
* sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
* @sk: socket sending this packet
@@ -2206,7 +2208,11 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
*
* Note : callers should take care of initial *tx_flags value (usually 0)
*/
-void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags);
+static inline void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
+{
+ if (unlikely(sk->sk_tsflags & SOF_TIMESTAMPING_MASK))
+ __sock_tx_timestamp(sk, tx_flags);
+}
/**
* sk_eat_skb - Release a skb if it is no longer needed
diff --git a/net/socket.c b/net/socket.c
index 2e2586e..2d1c2c8 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -610,7 +610,7 @@ void sock_release(struct socket *sock)
}
EXPORT_SYMBOL(sock_release);
-void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
+void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
{
u8 flags = *tx_flags;
@@ -631,7 +631,7 @@ void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
*tx_flags = flags;
}
-EXPORT_SYMBOL(sock_tx_timestamp);
+EXPORT_SYMBOL(__sock_tx_timestamp);
static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock,
struct msghdr *msg, size_t size)
--
2.1.0.rc2.206.gedb03e5
next reply other threads:[~2014-09-08 23:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-08 23:27 Willem de Bruijn [this message]
2014-09-08 23:29 ` [PATCH net-next] net-timestamp: optimize sock_tx_timestamp default path Willem de Bruijn
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=1410218824-18296-1-git-send-email-willemb@google.com \
--to=willemb@google.com \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=richardcochran@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