aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2014-09-08 19:58:58 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-09 20:34:41 -0400
commit67cc0d4077951295f42bed63805e91b46c24477b (patch)
tree7a0170e8cd1d6bbef0e09869c5a7eda347d92424
parent17448e5f63c8f36d00532327ae65e253d1395b08 (diff)
net-timestamp: optimize sock_tx_timestamp default path
Few packets have timestamping enabled. Exit sock_tx_timestamp quickly in this common case. Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/sock.h10
-rw-r--r--net/socket.c7
2 files changed, 11 insertions, 6 deletions
diff --git a/include/net/sock.h b/include/net/sock.h
index 049ab1b732a6..515a4d01e932 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,
2199 sk->sk_stamp = skb->tstamp; 2199 sk->sk_stamp = skb->tstamp;
2200} 2200}
2201 2201
2202void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags);
2203
2202/** 2204/**
2203 * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped 2205 * sock_tx_timestamp - checks whether the outgoing packet is to be time stamped
2204 * @sk: socket sending this packet 2206 * @sk: socket sending this packet
@@ -2206,7 +2208,13 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
2206 * 2208 *
2207 * Note : callers should take care of initial *tx_flags value (usually 0) 2209 * Note : callers should take care of initial *tx_flags value (usually 0)
2208 */ 2210 */
2209void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags); 2211static inline void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
2212{
2213 if (unlikely(sk->sk_tsflags))
2214 __sock_tx_timestamp(sk, tx_flags);
2215 if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS)))
2216 *tx_flags |= SKBTX_WIFI_STATUS;
2217}
2210 2218
2211/** 2219/**
2212 * sk_eat_skb - Release a skb if it is no longer needed 2220 * sk_eat_skb - Release a skb if it is no longer needed
diff --git a/net/socket.c b/net/socket.c
index 2e2586e2dee1..d40f522541aa 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -610,7 +610,7 @@ void sock_release(struct socket *sock)
610} 610}
611EXPORT_SYMBOL(sock_release); 611EXPORT_SYMBOL(sock_release);
612 612
613void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags) 613void __sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
614{ 614{
615 u8 flags = *tx_flags; 615 u8 flags = *tx_flags;
616 616
@@ -626,12 +626,9 @@ void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
626 if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK) 626 if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)
627 flags |= SKBTX_ACK_TSTAMP; 627 flags |= SKBTX_ACK_TSTAMP;
628 628
629 if (sock_flag(sk, SOCK_WIFI_STATUS))
630 flags |= SKBTX_WIFI_STATUS;
631
632 *tx_flags = flags; 629 *tx_flags = flags;
633} 630}
634EXPORT_SYMBOL(sock_tx_timestamp); 631EXPORT_SYMBOL(__sock_tx_timestamp);
635 632
636static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock, 633static inline int __sock_sendmsg_nosec(struct kiocb *iocb, struct socket *sock,
637 struct msghdr *msg, size_t size) 634 struct msghdr *msg, size_t size)