Skip to content

Commit

Permalink
net-timestamp: optimize sock_tx_timestamp default path
Browse files Browse the repository at this point in the history
Few packets have timestamping enabled. Exit sock_tx_timestamp quickly
in this common case.

Signed-off-by: Willem de Bruijn <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
wdebruij authored and davem330 committed Sep 10, 2014
1 parent 17448e5 commit 67cc0d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
10 changes: 9 additions & 1 deletion include/net/sock.h
Original file line number Diff line number Diff line change
Expand Up @@ -2199,14 +2199,22 @@ 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
* @tx_flags: completed with instructions for time stamping
*
* 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))
__sock_tx_timestamp(sk, tx_flags);
if (unlikely(sock_flag(sk, SOCK_WIFI_STATUS)))
*tx_flags |= SKBTX_WIFI_STATUS;
}

/**
* sk_eat_skb - Release a skb if it is no longer needed
Expand Down
7 changes: 2 additions & 5 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -626,12 +626,9 @@ void sock_tx_timestamp(const struct sock *sk, __u8 *tx_flags)
if (sk->sk_tsflags & SOF_TIMESTAMPING_TX_ACK)
flags |= SKBTX_ACK_TSTAMP;

if (sock_flag(sk, SOCK_WIFI_STATUS))
flags |= SKBTX_WIFI_STATUS;

*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)
Expand Down

0 comments on commit 67cc0d4

Please sign in to comment.