mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
net: skb_queue_purge_reason() optimizations
1) Exit early if the list is empty. 2) splice the list into a local list, so that we block hard irqs only once. Signed-off-by: Eric Dumazet <edumazet@google.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20231003181920.3280453-1-edumazet@google.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
397f70e3be
commit
d86e5fbd4c
@ -3722,10 +3722,19 @@ EXPORT_SYMBOL(skb_dequeue_tail);
|
||||
void skb_queue_purge_reason(struct sk_buff_head *list,
|
||||
enum skb_drop_reason reason)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
struct sk_buff_head tmp;
|
||||
unsigned long flags;
|
||||
|
||||
while ((skb = skb_dequeue(list)) != NULL)
|
||||
kfree_skb_reason(skb, reason);
|
||||
if (skb_queue_empty_lockless(list))
|
||||
return;
|
||||
|
||||
__skb_queue_head_init(&tmp);
|
||||
|
||||
spin_lock_irqsave(&list->lock, flags);
|
||||
skb_queue_splice_init(list, &tmp);
|
||||
spin_unlock_irqrestore(&list->lock, flags);
|
||||
|
||||
__skb_queue_purge_reason(&tmp, reason);
|
||||
}
|
||||
EXPORT_SYMBOL(skb_queue_purge_reason);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user