Skip to content

Commit b96c51b

Browse files
edumazetdavem330
authored andcommitted
tcp: tp->urg_data is unlikely to be set
Use some unlikely() hints in the fast path. Signed-off-by: Eric Dumazet <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7b6a893 commit b96c51b

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

net/ipv4/tcp.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ __poll_t tcp_poll(struct file *file, struct socket *sock, poll_table *wait)
547547
int target = sock_rcvlowat(sk, 0, INT_MAX);
548548
u16 urg_data = READ_ONCE(tp->urg_data);
549549

550-
if (urg_data &&
550+
if (unlikely(urg_data) &&
551551
READ_ONCE(tp->urg_seq) == READ_ONCE(tp->copied_seq) &&
552552
!sock_flag(sk, SOCK_URGINLINE))
553553
target++;
@@ -1633,7 +1633,7 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
16331633

16341634
len = skb->len - offset;
16351635
/* Stop reading if we hit a patch of urgent data */
1636-
if (tp->urg_data) {
1636+
if (unlikely(tp->urg_data)) {
16371637
u32 urg_offset = tp->urg_seq - seq;
16381638
if (urg_offset < len)
16391639
len = urg_offset;
@@ -2326,7 +2326,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
23262326
u32 offset;
23272327

23282328
/* Are we at urgent data? Stop if we have read anything or have SIGURG pending. */
2329-
if (tp->urg_data && tp->urg_seq == *seq) {
2329+
if (unlikely(tp->urg_data) && tp->urg_seq == *seq) {
23302330
if (copied)
23312331
break;
23322332
if (signal_pending(current)) {
@@ -2431,7 +2431,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
24312431
used = len;
24322432

24332433
/* Do we have urgent data here? */
2434-
if (tp->urg_data) {
2434+
if (unlikely(tp->urg_data)) {
24352435
u32 urg_offset = tp->urg_seq - *seq;
24362436
if (urg_offset < used) {
24372437
if (!urg_offset) {
@@ -2465,7 +2465,7 @@ static int tcp_recvmsg_locked(struct sock *sk, struct msghdr *msg, size_t len,
24652465
tcp_rcv_space_adjust(sk);
24662466

24672467
skip_copy:
2468-
if (tp->urg_data && after(tp->copied_seq, tp->urg_seq)) {
2468+
if (unlikely(tp->urg_data) && after(tp->copied_seq, tp->urg_seq)) {
24692469
WRITE_ONCE(tp->urg_data, 0);
24702470
tcp_fast_path_check(sk);
24712471
}

net/ipv4/tcp_input.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5604,11 +5604,11 @@ static void tcp_urg(struct sock *sk, struct sk_buff *skb, const struct tcphdr *t
56045604
struct tcp_sock *tp = tcp_sk(sk);
56055605

56065606
/* Check if we get a new urgent pointer - normally not. */
5607-
if (th->urg)
5607+
if (unlikely(th->urg))
56085608
tcp_check_urg(sk, th);
56095609

56105610
/* Do we wait for any urgent data? - normally not... */
5611-
if (tp->urg_data == TCP_URG_NOTYET) {
5611+
if (unlikely(tp->urg_data == TCP_URG_NOTYET)) {
56125612
u32 ptr = tp->urg_seq - ntohl(th->seq) + (th->doff * 4) -
56135613
th->syn;
56145614

0 commit comments

Comments
 (0)