Skip to content

Commit 6b92153

Browse files
edumazetgregkh
authored andcommitted
net: sk_buff rbnode reorg
commit bffa72c upstream skb->rbnode shares space with skb->next, skb->prev and skb->tstamp Current uses (TCP receive ofo queue and netem) need to save/restore tstamp, while skb->dev is either NULL (TCP) or a constant for a given queue (netem). Since we plan using an RB tree for TCP retransmit queue to speedup SACK processing with large BDP, this patch exchanges skb->dev and skb->tstamp. This saves some overhead in both TCP and netem. v2: removes the swtstamp field from struct tcp_skb_cb Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Soheil Hassas Yeganeh <soheil@google.com> Cc: Wei Wang <weiwan@google.com> Cc: Willem de Bruijn <willemb@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 37c7cc8 commit 6b92153

6 files changed

Lines changed: 129 additions & 98 deletions

File tree

include/linux/skbuff.h

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -663,23 +663,27 @@ struct sk_buff {
663663
struct sk_buff *prev;
664664

665665
union {
666-
ktime_t tstamp;
667-
u64 skb_mstamp;
666+
struct net_device *dev;
667+
/* Some protocols might use this space to store information,
668+
* while device pointer would be NULL.
669+
* UDP receive path is one user.
670+
*/
671+
unsigned long dev_scratch;
668672
};
669673
};
670-
struct rb_node rbnode; /* used in netem & tcp stack */
674+
struct rb_node rbnode; /* used in netem, ip4 defrag, and tcp stack */
675+
struct list_head list;
671676
};
672-
struct sock *sk;
673677

674678
union {
675-
struct net_device *dev;
676-
/* Some protocols might use this space to store information,
677-
* while device pointer would be NULL.
678-
* UDP receive path is one user.
679-
*/
680-
unsigned long dev_scratch;
679+
struct sock *sk;
681680
int ip_defrag_offset;
682681
};
682+
683+
union {
684+
ktime_t tstamp;
685+
u64 skb_mstamp;
686+
};
683687
/*
684688
* This is the control buffer. It is free to use for every
685689
* layer. Please put your private variables there. If you

include/net/inet_frag.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ struct inet_frag_queue {
7575
struct timer_list timer;
7676
spinlock_t lock;
7777
refcount_t refcnt;
78-
struct sk_buff *fragments;
78+
struct sk_buff *fragments; /* Used in IPv6. */
79+
struct rb_root rb_fragments; /* Used in IPv4. */
7980
struct sk_buff *fragments_tail;
8081
ktime_t stamp;
8182
int len;

net/ipv4/inet_fragment.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,16 @@ void inet_frag_destroy(struct inet_frag_queue *q)
136136
fp = q->fragments;
137137
nf = q->net;
138138
f = nf->f;
139-
while (fp) {
140-
struct sk_buff *xp = fp->next;
141-
142-
sum_truesize += fp->truesize;
143-
kfree_skb(fp);
144-
fp = xp;
139+
if (fp) {
140+
do {
141+
struct sk_buff *xp = fp->next;
142+
143+
sum_truesize += fp->truesize;
144+
kfree_skb(fp);
145+
fp = xp;
146+
} while (fp);
147+
} else {
148+
sum_truesize = skb_rbtree_purge(&q->rb_fragments);
145149
}
146150
sum = sum_truesize + f->qsize;
147151

0 commit comments

Comments
 (0)