Commit b96c51bd authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

tcp: tp->urg_data is unlikely to be set

Use some unlikely() hints in the fast path.
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 7b6a893a
...@@ -547,7 +547,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait) ...@@ -547,7 +547,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
int target = sock_rcvlowat(sk, 0, INT_MAX); int target = sock_rcvlowat(sk, 0, INT_MAX);
u16 urg_data = READ_ONCE(tp->urg_data); u16 urg_data = READ_ONCE(tp->urg_data);
if (urg_data && if (unlikely(urg_data) &&
READ_ONCE(tp->urg_seq) == READ_ONCE(tp->copied_seq) && READ_ONCE(tp->urg_seq) == READ_ONCE(tp->copied_seq) &&
!sock_flag(sk, SOCK_URGINLINE)) !sock_flag(sk, SOCK_URGINLINE))
target++; target++;
...@@ -1633,7 +1633,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc, ...@@ -1633,7 +1633,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
len = skb->len - offset; len = skb->len - offset;
/* Stop reading if we hit a patch of urgent data */ /* Stop reading if we hit a patch of urgent data */
if (tp->urg_data) { if (unlikely(tp->urg_data)) {
u32 urg_offset = tp->urg_seq - seq; u32 urg_offset = tp->urg_seq - seq;
if (urg_offset < len) if (urg_offset < len)
len = urg_offset; len = urg_offset;
...@@ -2326,7 +2326,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -2326,7 +2326,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
u32 offset; u32 offset;
/* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */ /* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */
if (tp->urg_data && tp->urg_seq == *seq) { if (unlikely(tp->urg_data) && tp->urg_seq == *seq) {
if (copied) if (copied)
break; break;
if (signal_pending(current)) { if (signal_pending(current)) {
...@@ -2431,7 +2431,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -2431,7 +2431,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
used = len; used = len;
/* Do we have urgent data here? */ /* Do we have urgent data here? */
if (tp->urg_data) { if (unlikely(tp->urg_data)) {
u32 urg_offset = tp->urg_seq - *seq; u32 urg_offset = tp->urg_seq - *seq;
if (urg_offset < used) { if (urg_offset < used) {
if (!urg_offset) { if (!urg_offset) {
...@@ -2465,7 +2465,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len, ...@@ -2465,7 +2465,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
tcp_rcv_space_adjust(sk); tcp_rcv_space_adjust(sk);
skip_copy: skip_copy:
if (tp->urg_data && after(tp->copied_seq, tp->urg_seq)) { if (unlikely(tp->urg_data) && after(tp->copied_seq, tp->urg_seq)) {
WRITE_ONCE(tp->urg_data, 0); WRITE_ONCE(tp->urg_data, 0);
tcp_fast_path_check(sk); tcp_fast_path_check(sk);
} }
......
...@@ -5604,11 +5604,11 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t ...@@ -5604,11 +5604,11 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t
struct tcp_sock *tp = tcp_sk(sk); struct tcp_sock *tp = tcp_sk(sk);
/* Check if we get a new urgent pointer - normally not. */ /* Check if we get a new urgent pointer - normally not. */
if (th->urg) if (unlikely(th->urg))
tcp_check_urg(sk, th); tcp_check_urg(sk, th);
/* Do we wait for any urgent data? - normally not... */ /* Do we wait for any urgent data? - normally not... */
if (tp->urg_data == TCP_URG_NOTYET) { if (unlikely(tp->urg_data == TCP_URG_NOTYET)) {
u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff * 4) - u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff * 4) -
th->syn; th->syn;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment