skb: Add skb_head_is_locked helper function
This patch adds support for a skb_head_is_locked helper function. It is meant to be used any time we are considering transferring the head from skb->head to a paged frag. If the head is locked it means we cannot remove the head from the skb so it must be copied or we must take the skb as a whole. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
715dc1f342
commit
3a7c1ee4ab
|
@ -2566,5 +2566,19 @@ static inline bool skb_is_recycleable(const struct sk_buff *skb, int skb_size)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* skb_head_is_locked - Determine if the skb->head is locked down
|
||||||
|
* @skb: skb to check
|
||||||
|
*
|
||||||
|
* The head on skbs build around a head frag can be removed if they are
|
||||||
|
* not cloned. This function returns true if the skb head is locked down
|
||||||
|
* due to either being allocated via kmalloc, or by being a clone with
|
||||||
|
* multiple references to the head.
|
||||||
|
*/
|
||||||
|
static inline bool skb_head_is_locked(const struct sk_buff *skb)
|
||||||
|
{
|
||||||
|
return !skb->head_frag || skb_cloned(skb);
|
||||||
|
}
|
||||||
#endif /* __KERNEL__ */
|
#endif /* __KERNEL__ */
|
||||||
#endif /* _LINUX_SKBUFF_H */
|
#endif /* _LINUX_SKBUFF_H */
|
||||||
|
|
|
@ -1699,7 +1699,6 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
|
||||||
struct splice_pipe_desc *spd, struct sock *sk)
|
struct splice_pipe_desc *spd, struct sock *sk)
|
||||||
{
|
{
|
||||||
int seg;
|
int seg;
|
||||||
bool head_is_locked = !skb->head_frag || skb_cloned(skb);
|
|
||||||
|
|
||||||
/* map the linear part :
|
/* map the linear part :
|
||||||
* If skb->head_frag is set, this 'linear' part is backed by a
|
* If skb->head_frag is set, this 'linear' part is backed by a
|
||||||
|
@ -1710,7 +1709,7 @@ static bool __skb_splice_bits(struct sk_buff *skb, struct pipe_inode_info *pipe,
|
||||||
(unsigned long) skb->data & (PAGE_SIZE - 1),
|
(unsigned long) skb->data & (PAGE_SIZE - 1),
|
||||||
skb_headlen(skb),
|
skb_headlen(skb),
|
||||||
offset, len, skb, spd,
|
offset, len, skb, spd,
|
||||||
head_is_locked,
|
skb_head_is_locked(skb),
|
||||||
sk, pipe))
|
sk, pipe))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
|
@ -4568,7 +4568,7 @@ static bool tcp_try_coalesce(struct sock *sk,
|
||||||
skb_shinfo(from)->nr_frags >= MAX_SKB_FRAGS)
|
skb_shinfo(from)->nr_frags >= MAX_SKB_FRAGS)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!from->head_frag || skb_cloned(from))
|
if (skb_head_is_locked(from))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
delta = from->truesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));
|
delta = from->truesize - SKB_DATA_ALIGN(sizeof(struct sk_buff));
|
||||||
|
|
Loading…
Reference in New Issue